From 11dab30be9917e169d6f18e8a46999a0d62dda71 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 29 Jun 2024 10:59:05 -0400 Subject: [PATCH] Update docs on the unit tests --- doc/manual/src/contributing/testing.md | 23 ++++++++++++++++++++--- src/nix-expr-tests/meson.build | 9 ++++++++- src/nix-fetchers-tests/meson.build | 9 ++++++++- src/nix-flake-tests/meson.build | 9 ++++++++- src/nix-store-tests/meson.build | 9 ++++++++- src/nix-util-tests/meson.build | 9 ++++++++- 6 files changed, 60 insertions(+), 8 deletions(-) diff --git a/doc/manual/src/contributing/testing.md b/doc/manual/src/contributing/testing.md index 399174de5..a96ba997b 100644 --- a/doc/manual/src/contributing/testing.md +++ b/doc/manual/src/contributing/testing.md @@ -76,8 +76,25 @@ there is no risk of any build-system wildcards for the library accidentally pick ### Running tests -You can run the whole testsuite with `make check`, or the tests for a specific component with `make libfoo-tests_RUN`. -Finer-grained filtering is also possible using the [--gtest_filter](https://google.github.io/googletest/advanced.html#running-a-subset-of-the-tests) command-line option, or the `GTEST_FILTER` environment variable, e.g. `GTEST_FILTER='ErrorTraceTest.*' make check`. +You can run the whole testsuite with `meson test` from the Meson build directory, or the tests for a specific component with `meson test nix-store-tests`. +A environment variables that Google Test accepts are also worth knowing: + +1. [`GTEST_FILTER`](https://google.github.io/googletest/advanced.html#running-a-subset-of-the-tests) + + This is used for finer-grained filtering of which tests to run. + + +2. [`GTEST_BRIEF`](https://google.github.io/googletest/advanced.html#suppressing-test-passes) + + This is used to avoid logging passing tests. + +Putting the two together, one might run + +```bash +GTEST_BREIF=1 GTEST_FILTER='ErrorTraceTest.*' meson test nix-expr-tests -v +``` + +for short but comprensive output. ### Characterisation testing { #characaterisation-testing-unit } @@ -86,7 +103,7 @@ See [functional characterisation testing](#characterisation-testing-functional) Like with the functional characterisation, `_NIX_TEST_ACCEPT=1` is also used. For example: ```shell-session -$ _NIX_TEST_ACCEPT=1 make libstore-tests_RUN +$ _NIX_TEST_ACCEPT=1 meson test nix-store-tests -v ... [ SKIPPED ] WorkerProtoTest.string_read [ SKIPPED ] WorkerProtoTest.string_write diff --git a/src/nix-expr-tests/meson.build b/src/nix-expr-tests/meson.build index 04b5ae66f..71865b59f 100644 --- a/src/nix-expr-tests/meson.build +++ b/src/nix-expr-tests/meson.build @@ -81,4 +81,11 @@ this_exe = executable( install : true, ) -test(meson.project_name(), this_exe, env : ['_NIX_TEST_UNIT_DATA=' + meson.current_source_dir() + '/data']) +test( + meson.project_name(), + this_exe, + env : { + '_NIX_TEST_UNIT_DATA': meson.current_source_dir() / 'data', + }, + protocol : 'gtest', +) diff --git a/src/nix-fetchers-tests/meson.build b/src/nix-fetchers-tests/meson.build index c4f18e278..b4bc77a97 100644 --- a/src/nix-fetchers-tests/meson.build +++ b/src/nix-fetchers-tests/meson.build @@ -61,4 +61,11 @@ this_exe = executable( install : true, ) -test(meson.project_name(), this_exe, env : ['_NIX_TEST_UNIT_DATA=' + meson.current_source_dir() + '/data']) +test( + meson.project_name(), + this_exe, + env : { + '_NIX_TEST_UNIT_DATA': meson.current_source_dir() / 'data', + }, + protocol : 'gtest', +) diff --git a/src/nix-flake-tests/meson.build b/src/nix-flake-tests/meson.build index 5afba2fec..2d6bbca0f 100644 --- a/src/nix-flake-tests/meson.build +++ b/src/nix-flake-tests/meson.build @@ -62,4 +62,11 @@ this_exe = executable( install : true, ) -test(meson.project_name(), this_exe, env : ['_NIX_TEST_UNIT_DATA=' + meson.current_source_dir() + '/data']) +test( + meson.project_name(), + this_exe, + env : { + '_NIX_TEST_UNIT_DATA': meson.current_source_dir() / 'data', + }, + protocol : 'gtest', +) diff --git a/src/nix-store-tests/meson.build b/src/nix-store-tests/meson.build index 2fde70d3b..90e7d3047 100644 --- a/src/nix-store-tests/meson.build +++ b/src/nix-store-tests/meson.build @@ -85,4 +85,11 @@ this_exe = executable( install : true, ) -test(meson.project_name(), this_exe, env : ['_NIX_TEST_UNIT_DATA=' + meson.current_source_dir() + '/data']) +test( + meson.project_name(), + this_exe, + env : { + '_NIX_TEST_UNIT_DATA': meson.current_source_dir() / 'data', + }, + protocol : 'gtest', +) diff --git a/src/nix-util-tests/meson.build b/src/nix-util-tests/meson.build index 67ae48f53..4f055cabd 100644 --- a/src/nix-util-tests/meson.build +++ b/src/nix-util-tests/meson.build @@ -81,4 +81,11 @@ this_exe = executable( install : true, ) -test(meson.project_name(), this_exe, env : ['_NIX_TEST_UNIT_DATA=' + meson.current_source_dir() + '/data']) +test( + meson.project_name(), + this_exe, + env : { + '_NIX_TEST_UNIT_DATA': meson.current_source_dir() / 'data', + }, + protocol : 'gtest', +)