Merge pull request #11708 from obsidiansystems/move-tests

Move unit tests to the location Meson expects them to be
This commit is contained in:
John Ericson 2024-10-17 16:15:34 -04:00 committed by GitHub
commit 694c378d14
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
270 changed files with 158 additions and 168 deletions

2
.github/labeler.yml vendored
View file

@ -1,7 +1,7 @@
"c api": "c api":
- changed-files: - changed-files:
- any-glob-to-any-file: "src/lib*-c/**/*" - any-glob-to-any-file: "src/lib*-c/**/*"
- any-glob-to-any-file: "test/unit/**/nix_api_*" - any-glob-to-any-file: "src/*test*/**/nix_api_*"
- any-glob-to-any-file: "doc/external-api/**/*" - any-glob-to-any-file: "doc/external-api/**/*"
"contributor-experience": "contributor-experience":

10
.gitignore vendored
View file

@ -49,22 +49,22 @@ perl/Makefile.config
/src/libexpr/parser-tab.output /src/libexpr/parser-tab.output
/src/libexpr/nix.tbl /src/libexpr/nix.tbl
/src/libexpr/tests /src/libexpr/tests
/tests/unit/libexpr/libnixexpr-tests /src/libexpr-tests/libnixexpr-tests
# /src/libfetchers # /src/libfetchers
/tests/unit/libfetchers/libnixfetchers-tests /src/libfetchers-tests/libnixfetchers-tests
# /src/libflake # /src/libflake
/tests/unit/libflake/libnixflake-tests /src/libflake-tests/libnixflake-tests
# /src/libstore/ # /src/libstore/
*.gen.* *.gen.*
/src/libstore/tests /src/libstore/tests
/tests/unit/libstore/libnixstore-tests /src/libstore-tests/libnixstore-tests
# /src/libutil/ # /src/libutil/
/src/libutil/tests /src/libutil/tests
/tests/unit/libutil/libnixutil-tests /src/libutil-tests/libnixutil-tests
/src/nix/nix /src/nix/nix

View file

@ -40,14 +40,14 @@ endif
ifeq ($(ENABLE_UNIT_TESTS), yes) ifeq ($(ENABLE_UNIT_TESTS), yes)
makefiles += \ makefiles += \
tests/unit/libutil/local.mk \ src/libutil-tests/local.mk \
tests/unit/libutil-support/local.mk \ src/libutil-test-support/local.mk \
tests/unit/libstore/local.mk \ src/libstore-tests/local.mk \
tests/unit/libstore-support/local.mk \ src/libstore-test-support/local.mk \
tests/unit/libfetchers/local.mk \ src/libfetchers-tests/local.mk \
tests/unit/libexpr/local.mk \ src/libexpr-tests/local.mk \
tests/unit/libexpr-support/local.mk \ src/libexpr-test-support/local.mk \
tests/unit/libflake/local.mk src/libflake-tests/local.mk
endif endif
ifeq ($(ENABLE_FUNCTIONAL_TESTS), yes) ifeq ($(ENABLE_FUNCTIONAL_TESTS), yes)

View file

@ -60,10 +60,10 @@ The unit tests are defined using the [googletest] and [rapidcheck] frameworks.
> ``` > ```
The tests for each Nix library (`libnixexpr`, `libnixstore`, etc..) live inside a directory `src/${library_name_without-nix}-test`. The tests for each Nix library (`libnixexpr`, `libnixstore`, etc..) live inside a directory `src/${library_name_without-nix}-test`.
Given an interface (header) and implementation pair in the original library, say, `src/libexpr/value/context.{hh,cc}`, we write tests for it in `src/nix-expr-tests/value/context.cc`, and (possibly) declare/define additional interfaces for testing purposes in `src/nix-expr-test-support/tests/value/context.{hh,cc}`. Given an interface (header) and implementation pair in the original library, say, `src/libexpr/value/context.{hh,cc}`, we write tests for it in `src/libexpr-tests/value/context.cc`, and (possibly) declare/define additional interfaces for testing purposes in `src/libexpr-test-support/tests/value/context.{hh,cc}`.
Data for unit tests is stored in a `data` subdir of the directory for each unit test executable. Data for unit tests is stored in a `data` subdir of the directory for each unit test executable.
For example, `libnixstore` code is in `src/libstore`, and its test data is in `src/nix-store-tests/data`. For example, `libnixstore` code is in `src/libstore`, and its test data is in `src/libstore-tests/data`.
The path to the `src/${library_name_without-nix}-test/data` directory is passed to the unit test executable with the environment variable `_NIX_TEST_UNIT_DATA`. The path to the `src/${library_name_without-nix}-test/data` directory is passed to the unit test executable with the environment variable `_NIX_TEST_UNIT_DATA`.
Note that each executable only gets the data for its tests. Note that each executable only gets the data for its tests.

View file

@ -15,7 +15,7 @@
excludes = [ excludes = [
# We don't want to format test data # We don't want to format test data
# ''tests/(?!nixos/).*\.nix'' # ''tests/(?!nixos/).*\.nix''
''^tests/unit/[^/]*/data/.*$'' ''^src/[^/]*-tests/data/.*$''
# Don't format vendored code # Don't format vendored code
''^doc/manual/redirects\.js$'' ''^doc/manual/redirects\.js$''
@ -427,64 +427,64 @@
''^tests/nixos/ca-fd-leak/sender\.c'' ''^tests/nixos/ca-fd-leak/sender\.c''
''^tests/nixos/ca-fd-leak/smuggler\.c'' ''^tests/nixos/ca-fd-leak/smuggler\.c''
''^tests/nixos/user-sandboxing/attacker\.c'' ''^tests/nixos/user-sandboxing/attacker\.c''
''^tests/unit/libexpr-support/tests/libexpr\.hh'' ''^src/libexpr-test-support/tests/libexpr\.hh''
''^tests/unit/libexpr-support/tests/value/context\.cc'' ''^src/libexpr-test-support/tests/value/context\.cc''
''^tests/unit/libexpr-support/tests/value/context\.hh'' ''^src/libexpr-test-support/tests/value/context\.hh''
''^tests/unit/libexpr/derived-path\.cc'' ''^src/libexpr-tests/derived-path\.cc''
''^tests/unit/libexpr/error_traces\.cc'' ''^src/libexpr-tests/error_traces\.cc''
''^tests/unit/libexpr/eval\.cc'' ''^src/libexpr-tests/eval\.cc''
''^tests/unit/libexpr/json\.cc'' ''^src/libexpr-tests/json\.cc''
''^tests/unit/libexpr/main\.cc'' ''^src/libexpr-tests/main\.cc''
''^tests/unit/libexpr/primops\.cc'' ''^src/libexpr-tests/primops\.cc''
''^tests/unit/libexpr/search-path\.cc'' ''^src/libexpr-tests/search-path\.cc''
''^tests/unit/libexpr/trivial\.cc'' ''^src/libexpr-tests/trivial\.cc''
''^tests/unit/libexpr/value/context\.cc'' ''^src/libexpr-tests/value/context\.cc''
''^tests/unit/libexpr/value/print\.cc'' ''^src/libexpr-tests/value/print\.cc''
''^tests/unit/libfetchers/public-key\.cc'' ''^src/libfetchers-tests/public-key\.cc''
''^tests/unit/libflake/flakeref\.cc'' ''^src/libflake-tests/flakeref\.cc''
''^tests/unit/libflake/url-name\.cc'' ''^src/libflake-tests/url-name\.cc''
''^tests/unit/libstore-support/tests/derived-path\.cc'' ''^src/libstore-test-support/tests/derived-path\.cc''
''^tests/unit/libstore-support/tests/derived-path\.hh'' ''^src/libstore-test-support/tests/derived-path\.hh''
''^tests/unit/libstore-support/tests/nix_api_store\.hh'' ''^src/libstore-test-support/tests/nix_api_store\.hh''
''^tests/unit/libstore-support/tests/outputs-spec\.cc'' ''^src/libstore-test-support/tests/outputs-spec\.cc''
''^tests/unit/libstore-support/tests/outputs-spec\.hh'' ''^src/libstore-test-support/tests/outputs-spec\.hh''
''^tests/unit/libstore-support/tests/path\.cc'' ''^src/libstore-test-support/tests/path\.cc''
''^tests/unit/libstore-support/tests/path\.hh'' ''^src/libstore-test-support/tests/path\.hh''
''^tests/unit/libstore-support/tests/protocol\.hh'' ''^src/libstore-test-support/tests/protocol\.hh''
''^tests/unit/libstore/common-protocol\.cc'' ''^src/libstore-tests/common-protocol\.cc''
''^tests/unit/libstore/content-address\.cc'' ''^src/libstore-tests/content-address\.cc''
''^tests/unit/libstore/derivation\.cc'' ''^src/libstore-tests/derivation\.cc''
''^tests/unit/libstore/derived-path\.cc'' ''^src/libstore-tests/derived-path\.cc''
''^tests/unit/libstore/downstream-placeholder\.cc'' ''^src/libstore-tests/downstream-placeholder\.cc''
''^tests/unit/libstore/machines\.cc'' ''^src/libstore-tests/machines\.cc''
''^tests/unit/libstore/nar-info-disk-cache\.cc'' ''^src/libstore-tests/nar-info-disk-cache\.cc''
''^tests/unit/libstore/nar-info\.cc'' ''^src/libstore-tests/nar-info\.cc''
''^tests/unit/libstore/outputs-spec\.cc'' ''^src/libstore-tests/outputs-spec\.cc''
''^tests/unit/libstore/path-info\.cc'' ''^src/libstore-tests/path-info\.cc''
''^tests/unit/libstore/path\.cc'' ''^src/libstore-tests/path\.cc''
''^tests/unit/libstore/serve-protocol\.cc'' ''^src/libstore-tests/serve-protocol\.cc''
''^tests/unit/libstore/worker-protocol\.cc'' ''^src/libstore-tests/worker-protocol\.cc''
''^tests/unit/libutil-support/tests/characterization\.hh'' ''^src/libutil-test-support/tests/characterization\.hh''
''^tests/unit/libutil-support/tests/hash\.cc'' ''^src/libutil-test-support/tests/hash\.cc''
''^tests/unit/libutil-support/tests/hash\.hh'' ''^src/libutil-test-support/tests/hash\.hh''
''^tests/unit/libutil/args\.cc'' ''^src/libutil-tests/args\.cc''
''^tests/unit/libutil/canon-path\.cc'' ''^src/libutil-tests/canon-path\.cc''
''^tests/unit/libutil/chunked-vector\.cc'' ''^src/libutil-tests/chunked-vector\.cc''
''^tests/unit/libutil/closure\.cc'' ''^src/libutil-tests/closure\.cc''
''^tests/unit/libutil/compression\.cc'' ''^src/libutil-tests/compression\.cc''
''^tests/unit/libutil/config\.cc'' ''^src/libutil-tests/config\.cc''
''^tests/unit/libutil/file-content-address\.cc'' ''^src/libutil-tests/file-content-address\.cc''
''^tests/unit/libutil/git\.cc'' ''^src/libutil-tests/git\.cc''
''^tests/unit/libutil/hash\.cc'' ''^src/libutil-tests/hash\.cc''
''^tests/unit/libutil/hilite\.cc'' ''^src/libutil-tests/hilite\.cc''
''^tests/unit/libutil/json-utils\.cc'' ''^src/libutil-tests/json-utils\.cc''
''^tests/unit/libutil/logging\.cc'' ''^src/libutil-tests/logging\.cc''
''^tests/unit/libutil/lru-cache\.cc'' ''^src/libutil-tests/lru-cache\.cc''
''^tests/unit/libutil/pool\.cc'' ''^src/libutil-tests/pool\.cc''
''^tests/unit/libutil/references\.cc'' ''^src/libutil-tests/references\.cc''
''^tests/unit/libutil/suggestions\.cc'' ''^src/libutil-tests/suggestions\.cc''
''^tests/unit/libutil/url\.cc'' ''^src/libutil-tests/url\.cc''
''^tests/unit/libutil/xml-writer\.cc'' ''^src/libutil-tests/xml-writer\.cc''
]; ];
}; };
shellcheck = { shellcheck = {
@ -650,7 +650,7 @@
''^tests/functional/user-envs\.sh$'' ''^tests/functional/user-envs\.sh$''
''^tests/functional/why-depends\.sh$'' ''^tests/functional/why-depends\.sh$''
''^tests/functional/zstd\.sh$'' ''^tests/functional/zstd\.sh$''
''^tests/unit/libutil/data/git/check-data\.sh$'' ''^src/libutil-tests/data/git/check-data\.sh$''
]; ];
}; };
# TODO: nixfmt, https://github.com/NixOS/nixfmt/issues/153 # TODO: nixfmt, https://github.com/NixOS/nixfmt/issues/153

View file

@ -40,12 +40,12 @@ if not meson.is_cross_build()
endif endif
# Testing # Testing
subproject('nix-util-test-support') subproject('libutil-test-support')
subproject('nix-util-tests') subproject('libutil-tests')
subproject('nix-store-test-support') subproject('libstore-test-support')
subproject('nix-store-tests') subproject('libstore-tests')
subproject('nix-fetchers-tests') subproject('libfetchers-tests')
subproject('nix-expr-test-support') subproject('libexpr-test-support')
subproject('nix-expr-tests') subproject('libexpr-tests')
subproject('nix-flake-tests') subproject('libflake-tests')
subproject('nix-functional-tests') subproject('nix-functional-tests')

View file

@ -176,8 +176,6 @@ in {
./scripts/local.mk ./scripts/local.mk
] ++ lib.optionals enableManual [ ] ++ lib.optionals enableManual [
./doc/manual ./doc/manual
] ++ lib.optionals buildUnitTests [
./tests/unit
] ++ lib.optionals doInstallCheck [ ] ++ lib.optionals doInstallCheck [
./tests/functional ./tests/functional
])); ]));

View file

@ -32,24 +32,24 @@ in
nix-util = callPackage ../src/libutil/package.nix { }; nix-util = callPackage ../src/libutil/package.nix { };
nix-util-c = callPackage ../src/libutil-c/package.nix { }; nix-util-c = callPackage ../src/libutil-c/package.nix { };
nix-util-test-support = callPackage ../tests/unit/libutil-support/package.nix { }; nix-util-test-support = callPackage ../src/libutil-test-support/package.nix { };
nix-util-tests = callPackage ../tests/unit/libutil/package.nix { }; nix-util-tests = callPackage ../src/libutil-tests/package.nix { };
nix-store = callPackage ../src/libstore/package.nix { }; nix-store = callPackage ../src/libstore/package.nix { };
nix-store-c = callPackage ../src/libstore-c/package.nix { }; nix-store-c = callPackage ../src/libstore-c/package.nix { };
nix-store-test-support = callPackage ../tests/unit/libstore-support/package.nix { }; nix-store-test-support = callPackage ../src/libstore-test-support/package.nix { };
nix-store-tests = callPackage ../tests/unit/libstore/package.nix { }; nix-store-tests = callPackage ../src/libstore-tests/package.nix { };
nix-fetchers = callPackage ../src/libfetchers/package.nix { }; nix-fetchers = callPackage ../src/libfetchers/package.nix { };
nix-fetchers-tests = callPackage ../tests/unit/libfetchers/package.nix { }; nix-fetchers-tests = callPackage ../src/libfetchers-tests/package.nix { };
nix-expr = callPackage ../src/libexpr/package.nix { }; nix-expr = callPackage ../src/libexpr/package.nix { };
nix-expr-c = callPackage ../src/libexpr-c/package.nix { }; nix-expr-c = callPackage ../src/libexpr-c/package.nix { };
nix-expr-test-support = callPackage ../tests/unit/libexpr-support/package.nix { }; nix-expr-test-support = callPackage ../src/libexpr-test-support/package.nix { };
nix-expr-tests = callPackage ../tests/unit/libexpr/package.nix { }; nix-expr-tests = callPackage ../src/libexpr-tests/package.nix { };
nix-flake = callPackage ../src/libflake/package.nix { }; nix-flake = callPackage ../src/libflake/package.nix { };
nix-flake-tests = callPackage ../tests/unit/libflake/package.nix { }; nix-flake-tests = callPackage ../src/libflake-tests/package.nix { };
nix-main = callPackage ../src/libmain/package.nix { }; nix-main = callPackage ../src/libmain/package.nix { };
nix-main-c = callPackage ../src/libmain-c/package.nix { }; nix-main-c = callPackage ../src/libmain-c/package.nix { };

View file

@ -41,21 +41,21 @@ INPUT = \
@src@/libcmd \ @src@/libcmd \
@src@/libexpr \ @src@/libexpr \
@src@/libexpr/flake \ @src@/libexpr/flake \
@src@/nix-expr-tests \ @src@/libexpr-tests \
@src@/nix-expr-tests/value \ @src@/libexpr-tests/value \
@src@/nix-expr-test-support/test \ @src@/libexpr-test-support/test \
@src@/nix-expr-test-support/test/value \ @src@/libexpr-test-support/test/value \
@src@/libexpr/value \ @src@/libexpr/value \
@src@/libfetchers \ @src@/libfetchers \
@src@/libmain \ @src@/libmain \
@src@/libstore \ @src@/libstore \
@src@/libstore/build \ @src@/libstore/build \
@src@/libstore/builtins \ @src@/libstore/builtins \
@src@/nix-store-tests \ @src@/libstore-tests \
@src@/nix-store-test-support/test \ @src@/libstore-test-support/test \
@src@/libutil \ @src@/libutil \
@src@/nix-util-tests \ @src@/libutil-tests \
@src@/nix-util-test-support/test \ @src@/libutil-test-support/test \
@src@/nix \ @src@/nix \
@src@/nix-env \ @src@/nix-env \
@src@/nix-store @src@/nix-store

View file

@ -0,0 +1 @@
../../.version

View file

@ -0,0 +1 @@
../../build-utils-meson

View file

@ -22,9 +22,9 @@ mkMesonLibrary (finalAttrs: {
workDir = ./.; workDir = ./.;
fileset = fileset.unions [ fileset = fileset.unions [
../../../build-utils-meson ../../build-utils-meson
./build-utils-meson ./build-utils-meson
../../../.version ../../.version
./.version ./.version
./meson.build ./meson.build
# ./meson.options # ./meson.options
@ -43,7 +43,7 @@ mkMesonLibrary (finalAttrs: {
# Do the meson utils, without modification. # Do the meson utils, without modification.
'' ''
chmod u+w ./.version chmod u+w ./.version
echo ${version} > ../../../.version echo ${version} > ../../.version
''; '';
mesonFlags = [ mesonFlags = [

1
src/libexpr-tests/.version Symbolic link
View file

@ -0,0 +1 @@
../../.version

View file

@ -0,0 +1 @@
../../build-utils-meson

View file

@ -20,9 +20,9 @@ libexpr-tests_SOURCES := \
$(wildcard $(d)/flake/*.cc) $(wildcard $(d)/flake/*.cc)
libexpr-tests_EXTRA_INCLUDES = \ libexpr-tests_EXTRA_INCLUDES = \
-I tests/unit/libexpr-support \ -I src/libexpr-test-support \
-I tests/unit/libstore-support \ -I src/libstore-test-support \
-I tests/unit/libutil-support \ -I src/libutil-test-support \
$(INCLUDE_libexpr) \ $(INCLUDE_libexpr) \
$(INCLUDE_libexprc) \ $(INCLUDE_libexprc) \
$(INCLUDE_libfetchers) \ $(INCLUDE_libfetchers) \

View file

@ -27,9 +27,9 @@ mkMesonExecutable (finalAttrs: {
workDir = ./.; workDir = ./.;
fileset = fileset.unions [ fileset = fileset.unions [
../../../build-utils-meson ../../build-utils-meson
./build-utils-meson ./build-utils-meson
../../../.version ../../.version
./.version ./.version
./meson.build ./meson.build
# ./meson.options # ./meson.options
@ -50,7 +50,7 @@ mkMesonExecutable (finalAttrs: {
# Do the meson utils, without modification. # Do the meson utils, without modification.
'' ''
chmod u+w ./.version chmod u+w ./.version
echo ${version} > ../../../.version echo ${version} > ../../.version
''; '';
mesonFlags = [ mesonFlags = [

View file

@ -0,0 +1 @@
../../.version

View file

@ -0,0 +1 @@
../../build-utils-meson

View file

@ -17,8 +17,8 @@ endif
libfetchers-tests_SOURCES := $(wildcard $(d)/*.cc) libfetchers-tests_SOURCES := $(wildcard $(d)/*.cc)
libfetchers-tests_EXTRA_INCLUDES = \ libfetchers-tests_EXTRA_INCLUDES = \
-I tests/unit/libstore-support \ -I src/libstore-test-support \
-I tests/unit/libutil-support \ -I src/libutil-test-support \
$(INCLUDE_libfetchers) \ $(INCLUDE_libfetchers) \
$(INCLUDE_libstore) \ $(INCLUDE_libstore) \
$(INCLUDE_libutil) $(INCLUDE_libutil)

View file

@ -26,9 +26,9 @@ mkMesonExecutable (finalAttrs: {
workDir = ./.; workDir = ./.;
fileset = fileset.unions [ fileset = fileset.unions [
../../../build-utils-meson ../../build-utils-meson
./build-utils-meson ./build-utils-meson
../../../.version ../../.version
./.version ./.version
./meson.build ./meson.build
# ./meson.options # ./meson.options
@ -48,7 +48,7 @@ mkMesonExecutable (finalAttrs: {
# Do the meson utils, without modification. # Do the meson utils, without modification.
'' ''
chmod u+w ./.version chmod u+w ./.version
echo ${version} > ../../../.version echo ${version} > ../../.version
''; '';
mesonFlags = [ mesonFlags = [

1
src/libflake-tests/.version Symbolic link
View file

@ -0,0 +1 @@
../../.version

View file

@ -0,0 +1 @@
../../build-utils-meson

View file

@ -20,9 +20,9 @@ libflake-tests_SOURCES := \
$(wildcard $(d)/flake/*.cc) $(wildcard $(d)/flake/*.cc)
libflake-tests_EXTRA_INCLUDES = \ libflake-tests_EXTRA_INCLUDES = \
-I tests/unit/libflake-support \ -I src/libflake-test-support \
-I tests/unit/libstore-support \ -I src/libstore-test-support \
-I tests/unit/libutil-support \ -I src/libutil-test-support \
$(INCLUDE_libflake) \ $(INCLUDE_libflake) \
$(INCLUDE_libexpr) \ $(INCLUDE_libexpr) \
$(INCLUDE_libfetchers) \ $(INCLUDE_libfetchers) \

View file

@ -26,9 +26,9 @@ mkMesonExecutable (finalAttrs: {
workDir = ./.; workDir = ./.;
fileset = fileset.unions [ fileset = fileset.unions [
../../../build-utils-meson ../../build-utils-meson
./build-utils-meson ./build-utils-meson
../../../.version ../../.version
./.version ./.version
./meson.build ./meson.build
# ./meson.options # ./meson.options
@ -48,7 +48,7 @@ mkMesonExecutable (finalAttrs: {
# Do the meson utils, without modification. # Do the meson utils, without modification.
'' ''
chmod u+w ./.version chmod u+w ./.version
echo ${version} > ../../../.version echo ${version} > ../../.version
''; '';
mesonFlags = [ mesonFlags = [

View file

@ -0,0 +1 @@
../../.version

View file

@ -0,0 +1 @@
../../build-utils-meson

View file

@ -22,9 +22,9 @@ mkMesonLibrary (finalAttrs: {
workDir = ./.; workDir = ./.;
fileset = fileset.unions [ fileset = fileset.unions [
../../../build-utils-meson ../../build-utils-meson
./build-utils-meson ./build-utils-meson
../../../.version ../../.version
./.version ./.version
./meson.build ./meson.build
# ./meson.options # ./meson.options
@ -43,7 +43,7 @@ mkMesonLibrary (finalAttrs: {
# Do the meson utils, without modification. # Do the meson utils, without modification.
'' ''
chmod u+w ./.version chmod u+w ./.version
echo ${version} > ../../../.version echo ${version} > ../../.version
''; '';
mesonFlags = [ mesonFlags = [

1
src/libstore-tests/.version Symbolic link
View file

@ -0,0 +1 @@
../../.version

View file

@ -0,0 +1 @@
../../build-utils-meson

View file

@ -0,0 +1 @@
../../../../tests/functional/derivation/advanced-attributes-defaults.drv

View file

@ -0,0 +1 @@
../../../../tests/functional/derivation/advanced-attributes-structured-attrs-defaults.drv

View file

@ -0,0 +1 @@
../../../../tests/functional/derivation/advanced-attributes-structured-attrs.drv

View file

@ -0,0 +1 @@
../../../../tests/functional/derivation/advanced-attributes.drv

Some files were not shown because too many files have changed in this diff Show more