From 5be4dfaa13b0bb1ece79adc84822067a93b88600 Mon Sep 17 00:00:00 2001 From: Benjamin Coe Date: Thu, 28 Sep 2017 18:29:54 -0700 Subject: test: make it easier to run tests for subsystems You can now run suites for subsystem using shorthand, e.g., http. Switch to black-list of default test folders from white-list. Tests run by 'make test', 'make coverage', etc., now configurable. Stop running known_issues suite when collecting test coverage. PR-URL: https://github.com/nodejs/node/pull/15450 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- CONTRIBUTING.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'CONTRIBUTING.md') diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 26b083b867..03d2cc1a13 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -404,6 +404,13 @@ If you are updating tests and just want to run a single test to check it: $ python tools/test.py -J --mode=release parallel/test-stream2-transform ``` +You can execute the entire suite of tests for a given subsystem +by providing the name of a subsystem: + +```text +$ python tools/test.py -J --mode=release child-process +``` + If you want to check the other options, please refer to the help by using the `--help` option @@ -420,6 +427,38 @@ $ ./node ./test/parallel/test-stream2-transform.js Remember to recompile with `make -j4` in between test runs if you change code in the `lib` or `src` directories. +##### Test Coverage + +It's good practice to ensure any code you add or change is covered by tests. +You can do so by running the test suite with coverage enabled: + +```text +$ ./configure --coverage && make coverage +``` + +A detailed coverage report will be written to `coverage/index.html` for +JavaScript coverage and to `coverage/cxxcoverage.html` for C++ coverage. + +_Note that generating a test coverage report can take several minutes._ + +To collect coverage for a subset of tests you can set the `CI_JS_SUITES` and +`CI_NATIVE_SUITES` variables: + +```text +$ CI_JS_SUITES=child-process CI_NATIVE_SUITES= make coverage +``` + +The above command executes tests for the `child-process` subsystem and +outputs the resulting coverage report. + +Running tests with coverage will create and modify several directories +and files. To clean up afterwards, run: + +```text +make coverage-clean +./configure && make -j4. +``` + #### Step 7: Push Once you are sure your commits are ready to go, with passing tests and linting, -- cgit v1.2.3