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":
- changed-files:
- 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/**/*"
"contributor-experience":

10
.gitignore vendored
View File

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

View File

@ -40,14 +40,14 @@ endif
ifeq ($(ENABLE_UNIT_TESTS), yes)
makefiles += \
tests/unit/libutil/local.mk \
tests/unit/libutil-support/local.mk \
tests/unit/libstore/local.mk \
tests/unit/libstore-support/local.mk \
tests/unit/libfetchers/local.mk \
tests/unit/libexpr/local.mk \
tests/unit/libexpr-support/local.mk \
tests/unit/libflake/local.mk
src/libutil-tests/local.mk \
src/libutil-test-support/local.mk \
src/libstore-tests/local.mk \
src/libstore-test-support/local.mk \
src/libfetchers-tests/local.mk \
src/libexpr-tests/local.mk \
src/libexpr-test-support/local.mk \
src/libflake-tests/local.mk
endif
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`.
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.
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`.
Note that each executable only gets the data for its tests.

View File

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

View File

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

View File

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

View File

@ -32,24 +32,24 @@ in
nix-util = callPackage ../src/libutil/package.nix { };
nix-util-c = callPackage ../src/libutil-c/package.nix { };
nix-util-test-support = callPackage ../tests/unit/libutil-support/package.nix { };
nix-util-tests = callPackage ../tests/unit/libutil/package.nix { };
nix-util-test-support = callPackage ../src/libutil-test-support/package.nix { };
nix-util-tests = callPackage ../src/libutil-tests/package.nix { };
nix-store = callPackage ../src/libstore/package.nix { };
nix-store-c = callPackage ../src/libstore-c/package.nix { };
nix-store-test-support = callPackage ../tests/unit/libstore-support/package.nix { };
nix-store-tests = callPackage ../tests/unit/libstore/package.nix { };
nix-store-test-support = callPackage ../src/libstore-test-support/package.nix { };
nix-store-tests = callPackage ../src/libstore-tests/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-c = callPackage ../src/libexpr-c/package.nix { };
nix-expr-test-support = callPackage ../tests/unit/libexpr-support/package.nix { };
nix-expr-tests = callPackage ../tests/unit/libexpr/package.nix { };
nix-expr-test-support = callPackage ../src/libexpr-test-support/package.nix { };
nix-expr-tests = callPackage ../src/libexpr-tests/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-c = callPackage ../src/libmain-c/package.nix { };

View File

@ -41,21 +41,21 @@ INPUT = \
@src@/libcmd \
@src@/libexpr \
@src@/libexpr/flake \
@src@/nix-expr-tests \
@src@/nix-expr-tests/value \
@src@/nix-expr-test-support/test \
@src@/nix-expr-test-support/test/value \
@src@/libexpr-tests \
@src@/libexpr-tests/value \
@src@/libexpr-test-support/test \
@src@/libexpr-test-support/test/value \
@src@/libexpr/value \
@src@/libfetchers \
@src@/libmain \
@src@/libstore \
@src@/libstore/build \
@src@/libstore/builtins \
@src@/nix-store-tests \
@src@/nix-store-test-support/test \
@src@/libstore-tests \
@src@/libstore-test-support/test \
@src@/libutil \
@src@/nix-util-tests \
@src@/nix-util-test-support/test \
@src@/libutil-tests \
@src@/libutil-test-support/test \
@src@/nix \
@src@/nix-env \
@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 = ./.;
fileset = fileset.unions [
../../../build-utils-meson
../../build-utils-meson
./build-utils-meson
../../../.version
../../.version
./.version
./meson.build
# ./meson.options
@ -43,7 +43,7 @@ mkMesonLibrary (finalAttrs: {
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../../.version
echo ${version} > ../../.version
'';
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)
libexpr-tests_EXTRA_INCLUDES = \
-I tests/unit/libexpr-support \
-I tests/unit/libstore-support \
-I tests/unit/libutil-support \
-I src/libexpr-test-support \
-I src/libstore-test-support \
-I src/libutil-test-support \
$(INCLUDE_libexpr) \
$(INCLUDE_libexprc) \
$(INCLUDE_libfetchers) \

View File

@ -27,9 +27,9 @@ mkMesonExecutable (finalAttrs: {
workDir = ./.;
fileset = fileset.unions [
../../../build-utils-meson
../../build-utils-meson
./build-utils-meson
../../../.version
../../.version
./.version
./meson.build
# ./meson.options
@ -50,7 +50,7 @@ mkMesonExecutable (finalAttrs: {
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../../.version
echo ${version} > ../../.version
'';
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_EXTRA_INCLUDES = \
-I tests/unit/libstore-support \
-I tests/unit/libutil-support \
-I src/libstore-test-support \
-I src/libutil-test-support \
$(INCLUDE_libfetchers) \
$(INCLUDE_libstore) \
$(INCLUDE_libutil)

View File

@ -26,9 +26,9 @@ mkMesonExecutable (finalAttrs: {
workDir = ./.;
fileset = fileset.unions [
../../../build-utils-meson
../../build-utils-meson
./build-utils-meson
../../../.version
../../.version
./.version
./meson.build
# ./meson.options
@ -48,7 +48,7 @@ mkMesonExecutable (finalAttrs: {
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../../.version
echo ${version} > ../../.version
'';
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)
libflake-tests_EXTRA_INCLUDES = \
-I tests/unit/libflake-support \
-I tests/unit/libstore-support \
-I tests/unit/libutil-support \
-I src/libflake-test-support \
-I src/libstore-test-support \
-I src/libutil-test-support \
$(INCLUDE_libflake) \
$(INCLUDE_libexpr) \
$(INCLUDE_libfetchers) \

View File

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

View File

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

View File

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

View File

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