From dee69d3c122605cb80e0f83b01c1f42f061bad24 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 21 Feb 2017 08:43:21 +0100 Subject: [PATCH] test: add support for --gtest_filter It might be useful to sometimes run a single cctest while debugging/ developing. This commit adds support for Google Test's --gtest_filter to enable this. To list the tests available: $ make list-gtests UtilTest. ListHead StringEqualNoCase StringEqualNoCaseN ToLower Malloc Calloc UncheckedMalloc UncheckedCalloc InspectorSocketTest. ReadsAndWritesInspectorMessage BufferEdgeCases AcceptsRequestInSeveralWrites ExtraTextBeforeRequest ExtraLettersBeforeRequest RequestWithoutKey KillsConnectionOnProtocolViolation CanStopReadingFromInspector CloseDoesNotNotifyReadCallback CloseWorksWithoutReadEnabled ReportsHttpGet HandshakeCanBeCanceled GetThenHandshake WriteBeforeHandshake CleanupSocketAfterEOF EOFBeforeHandshake Send1Mb ErrorCleansUpTheSocket InspectorSocketServerTest. InspectorSessions ServerDoesNothing ServerWithoutTargets ServerCannotStart StoppingServerDoesNotKillConnections Then run a single test: $ env GTEST_FILTER=InspectorSocketTest.GetThenHandshake make cctest Note: Google Test filter = InspectorSocketTest.GetThenHandshake [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from InspectorSocketTest [ RUN ] InspectorSocketTest.GetThenHandshake [ OK ] InspectorSocketTest.GetThenHandshake (0 ms) [----------] 1 test from InspectorSocketTest (0 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (0 ms total) [ PASSED ] 1 test. --- Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9c28a3e4f4f88e..fecffcd4fc0f36 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ STAGINGSERVER ?= node-www LOGLEVEL ?= silent OSTYPE := $(shell uname -s | tr '[A-Z]' '[a-z]') COVTESTS ?= test +GTEST_FILTER ?= "*" ifdef JOBS PARALLEL_ARGS = -j $(JOBS) @@ -178,7 +179,13 @@ coverage-test: coverage-build | sed 's/<[^>]*>//g'| sed 's/ //g' cctest: all - @out/$(BUILDTYPE)/$@ + @out/$(BUILDTYPE)/$@ --gtest_filter=$(GTEST_FILTER) + +list-gtests: +ifeq (,$(wildcard out/$(BUILDTYPE)/cctest)) + $(error Please run 'make cctest' first) +endif + @out/$(BUILDTYPE)/cctest --gtest_list_tests v8: tools/make-v8.sh @@ -846,4 +853,4 @@ endif bench-http bench-fs bench-tls cctest run-ci test-v8 test-v8-intl \ test-v8-benchmarks test-v8-all v8 lint-ci bench-ci jslint-ci doc-only \ $(TARBALL)-headers test-ci test-ci-native test-ci-js build-ci clear-stalled \ - coverage-clean coverage-build coverage-test coverage + coverage-clean coverage-build coverage-test coverage list-gtests