Skip to content

Commit

Permalink
test: add support for --gtest_filter
Browse files Browse the repository at this point in the history
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.

PR-URL: #11474
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
danbev authored and addaleax committed Feb 24, 2017
1 parent 64a9256 commit 000b2a1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 000b2a1

Please sign in to comment.