Unit tests and external libraries

This commit is contained in:
John Ericson 2024-06-27 11:28:08 -04:00
parent 4fa8068b78
commit 17a8c2bfce
215 changed files with 873 additions and 461 deletions

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-test/libnixexpr-tests
# /src/libfetchers # /src/libfetchers
/tests/unit/libfetchers/libnixfetchers-tests /src/libfetchers-test/libnixfetchers-tests
# /src/libflake # /src/libflake
/tests/unit/libflake/libnixflake-tests /src/libflake-test/libnixflake-tests
# /src/libstore/ # /src/libstore/
*.gen.* *.gen.*
/src/libstore/tests /src/libstore/tests
/tests/unit/libstore/libnixstore-tests /src/libstore-test/libnixstore-tests
# /src/libutil/ # /src/libutil/
/src/libutil/tests /src/libutil/tests
/tests/unit/libutil/libnixutil-tests /src/libutil-test/libnixutil-tests
/src/nix/nix /src/nix/nix

View file

@ -38,18 +38,6 @@ makefiles += \
endif endif
endif 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
endif
ifeq ($(ENABLE_FUNCTIONAL_TESTS), yes) ifeq ($(ENABLE_FUNCTIONAL_TESTS), yes)
ifdef HOST_UNIX ifdef HOST_UNIX
makefiles += \ makefiles += \
@ -103,13 +91,6 @@ include mk/lib.mk
# These must be defined after `mk/lib.mk`. Otherwise the first rule # These must be defined after `mk/lib.mk`. Otherwise the first rule
# incorrectly becomes the default target. # incorrectly becomes the default target.
ifneq ($(ENABLE_UNIT_TESTS), yes)
.PHONY: check
check:
@echo "Unit tests are disabled. Configure without '--disable-unit-tests', or avoid calling 'make check'."
@exit 1
endif
ifneq ($(ENABLE_FUNCTIONAL_TESTS), yes) ifneq ($(ENABLE_FUNCTIONAL_TESTS), yes)
.PHONY: installcheck .PHONY: installcheck
installcheck: installcheck:

View file

@ -12,7 +12,6 @@ ENABLE_BUILD = @ENABLE_BUILD@
ENABLE_DOC_GEN = @ENABLE_DOC_GEN@ ENABLE_DOC_GEN = @ENABLE_DOC_GEN@
ENABLE_FUNCTIONAL_TESTS = @ENABLE_FUNCTIONAL_TESTS@ ENABLE_FUNCTIONAL_TESTS = @ENABLE_FUNCTIONAL_TESTS@
ENABLE_S3 = @ENABLE_S3@ ENABLE_S3 = @ENABLE_S3@
ENABLE_UNIT_TESTS = @ENABLE_UNIT_TESTS@
GTEST_LIBS = @GTEST_LIBS@ GTEST_LIBS = @GTEST_LIBS@
HAVE_LIBCPUID = @HAVE_LIBCPUID@ HAVE_LIBCPUID = @HAVE_LIBCPUID@
HAVE_SECCOMP = @HAVE_SECCOMP@ HAVE_SECCOMP = @HAVE_SECCOMP@

View file

@ -141,18 +141,6 @@ AC_ARG_ENABLE(build, AS_HELP_STRING([--disable-build],[Do not build nix]),
ENABLE_BUILD=$enableval, ENABLE_BUILD=yes) ENABLE_BUILD=$enableval, ENABLE_BUILD=yes)
AC_SUBST(ENABLE_BUILD) AC_SUBST(ENABLE_BUILD)
# Building without unit tests is useful for bootstrapping with a smaller footprint
# or running the tests in a separate derivation. Otherwise, we do compile and
# run them.
AC_ARG_ENABLE(unit-tests, AS_HELP_STRING([--disable-unit-tests],[Do not build the tests]),
ENABLE_UNIT_TESTS=$enableval, ENABLE_UNIT_TESTS=$ENABLE_BUILD)
AC_SUBST(ENABLE_UNIT_TESTS)
AS_IF(
[test "$ENABLE_BUILD" == "no" && test "$ENABLE_UNIT_TESTS" == "yes"],
[AC_MSG_ERROR([Cannot enable unit tests when building overall is disabled. Please do not pass '--enable-unit-tests' or do not pass '--disable-build'.])])
AC_ARG_ENABLE(functional-tests, AS_HELP_STRING([--disable-functional-tests],[Do not build the tests]), AC_ARG_ENABLE(functional-tests, AS_HELP_STRING([--disable-functional-tests],[Do not build the tests]),
ENABLE_FUNCTIONAL_TESTS=$enableval, ENABLE_FUNCTIONAL_TESTS=yes) ENABLE_FUNCTIONAL_TESTS=$enableval, ENABLE_FUNCTIONAL_TESTS=yes)
AC_SUBST(ENABLE_FUNCTIONAL_TESTS) AC_SUBST(ENABLE_FUNCTIONAL_TESTS)
@ -365,16 +353,6 @@ if test "$gc" = yes; then
CFLAGS="$old_CFLAGS" CFLAGS="$old_CFLAGS"
fi fi
AS_IF([test "$ENABLE_UNIT_TESTS" == "yes"],[
# Look for gtest.
PKG_CHECK_MODULES([GTEST], [gtest_main gmock_main])
# Look for rapidcheck.
PKG_CHECK_MODULES([RAPIDCHECK], [rapidcheck rapidcheck_gtest])
])
# Look for nlohmann/json. # Look for nlohmann/json.
PKG_CHECK_MODULES([NLOHMANN_JSON], [nlohmann_json >= 3.9]) PKG_CHECK_MODULES([NLOHMANN_JSON], [nlohmann_json >= 3.9])

View file

@ -122,7 +122,6 @@ Run `make` with [`-e` / `--environment-overrides`](https://www.gnu.org/software/
The docs can take a while to build, so you may want to disable this for local development. The docs can take a while to build, so you may want to disable this for local development.
- `ENABLE_FUNCTIONAL_TESTS=yes` to enable building the functional tests. - `ENABLE_FUNCTIONAL_TESTS=yes` to enable building the functional tests.
- `ENABLE_UNIT_TESTS=yes` to enable building the unit tests.
- `OPTIMIZE=1` to enable optimizations. - `OPTIMIZE=1` to enable optimizations.
- `libraries=libutil programs=` to only build a specific library. - `libraries=libutil programs=` to only build a specific library.

View file

@ -59,15 +59,15 @@ The unit tests are defined using the [googletest] and [rapidcheck] frameworks.
> … > …
> ``` > ```
The tests for each Nix library (`libnixexpr`, `libnixstore`, etc..) live inside a directory `tests/unit/${library_name_without-nix}`. 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 `tests/unit/libexpr/tests/value/context.cc`, and (possibly) declare/define additional interfaces for testing purposes in `tests/unit/libexpr-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-test/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 `tests/unit/libstore/data`. For example, `libnixstore` code is in `src/libstore`, and its test data is in `src/libstore-test/data`.
The path to the `tests/unit/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.
The unit test libraries are in `tests/unit/${library_name_without-nix}-lib`. The unit test libraries are in `src/${library_name_without-nix}-test-support`.
All headers are in a `tests` subdirectory so they are included with `#include "tests/"`. All headers are in a `tests` subdirectory so they are included with `#include "tests/"`.
The use of all these separate directories for the unit tests might seem inconvenient, as for example the tests are not "right next to" the part of the code they are testing. The use of all these separate directories for the unit tests might seem inconvenient, as for example the tests are not "right next to" the part of the code they are testing.

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/[^/]*-test/[^/]*/data/.*$''
# Don't format vendored code # Don't format vendored code
''^doc/manual/redirects\.js$'' ''^doc/manual/redirects\.js$''
@ -429,65 +429,65 @@
''^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-test/derived-path\.cc''
''^tests/unit/libexpr/error_traces\.cc'' ''^src/libexpr-test/error_traces\.cc''
''^tests/unit/libexpr/eval\.cc'' ''^src/libexpr-test/eval\.cc''
''^tests/unit/libexpr/json\.cc'' ''^src/libexpr-test/json\.cc''
''^tests/unit/libexpr/main\.cc'' ''^src/libexpr-test/main\.cc''
''^tests/unit/libexpr/primops\.cc'' ''^src/libexpr-test/primops\.cc''
''^tests/unit/libexpr/search-path\.cc'' ''^src/libexpr-test/search-path\.cc''
''^tests/unit/libexpr/trivial\.cc'' ''^src/libexpr-test/trivial\.cc''
''^tests/unit/libexpr/value/context\.cc'' ''^src/libexpr-test/value/context\.cc''
''^tests/unit/libexpr/value/print\.cc'' ''^src/libexpr-test/value/print\.cc''
''^tests/unit/libfetchers/public-key\.cc'' ''^src/libfetchers-test/public-key\.cc''
''^tests/unit/libflake/flakeref\.cc'' ''^src/libflake-test/flakeref\.cc''
''^tests/unit/libflake/url-name\.cc'' ''^src/libflake-test/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-test/common-protocol\.cc''
''^tests/unit/libstore/content-address\.cc'' ''^src/libstore-test/content-address\.cc''
''^tests/unit/libstore/derivation\.cc'' ''^src/libstore-test/derivation\.cc''
''^tests/unit/libstore/derived-path\.cc'' ''^src/libstore-test/derived-path\.cc''
''^tests/unit/libstore/downstream-placeholder\.cc'' ''^src/libstore-test/downstream-placeholder\.cc''
''^tests/unit/libstore/machines\.cc'' ''^src/libstore-test/machines\.cc''
''^tests/unit/libstore/nar-info-disk-cache\.cc'' ''^src/libstore-test/nar-info-disk-cache\.cc''
''^tests/unit/libstore/nar-info\.cc'' ''^src/libstore-test/nar-info\.cc''
''^tests/unit/libstore/outputs-spec\.cc'' ''^src/libstore-test/outputs-spec\.cc''
''^tests/unit/libstore/path-info\.cc'' ''^src/libstore-test/path-info\.cc''
''^tests/unit/libstore/path\.cc'' ''^src/libstore-test/path\.cc''
''^tests/unit/libstore/serve-protocol\.cc'' ''^src/libstore-test/serve-protocol\.cc''
''^tests/unit/libstore/worker-protocol\.cc'' ''^src/libstore-test/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-test/args\.cc''
''^tests/unit/libutil/canon-path\.cc'' ''^src/libutil-test/canon-path\.cc''
''^tests/unit/libutil/chunked-vector\.cc'' ''^src/libutil-test/chunked-vector\.cc''
''^tests/unit/libutil/closure\.cc'' ''^src/libutil-test/closure\.cc''
''^tests/unit/libutil/compression\.cc'' ''^src/libutil-test/compression\.cc''
''^tests/unit/libutil/config\.cc'' ''^src/libutil-test/config\.cc''
''^tests/unit/libutil/file-content-address\.cc'' ''^src/libutil-test/file-content-address\.cc''
''^tests/unit/libutil/git\.cc'' ''^src/libutil-test/git\.cc''
''^tests/unit/libutil/hash\.cc'' ''^src/libutil-test/hash\.cc''
''^tests/unit/libutil/hilite\.cc'' ''^src/libutil-test/hilite\.cc''
''^tests/unit/libutil/json-utils\.cc'' ''^src/libutil-test/json-utils\.cc''
''^tests/unit/libutil/logging\.cc'' ''^src/libutil-test/logging\.cc''
''^tests/unit/libutil/lru-cache\.cc'' ''^src/libutil-test/lru-cache\.cc''
''^tests/unit/libutil/pool\.cc'' ''^src/libutil-test/pool\.cc''
''^tests/unit/libutil/references\.cc'' ''^src/libutil-test/references\.cc''
''^tests/unit/libutil/suggestions\.cc'' ''^src/libutil-test/suggestions\.cc''
''^tests/unit/libutil/tests\.cc'' ''^src/libutil-test/tests\.cc''
''^tests/unit/libutil/url\.cc'' ''^src/libutil-test/url\.cc''
''^tests/unit/libutil/xml-writer\.cc'' ''^src/libutil-test/xml-writer\.cc''
]; ];
}; };
shellcheck = { shellcheck = {
@ -666,7 +666,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-test/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

@ -27,8 +27,9 @@ subproject('perl')
# Testing # Testing
subproject('libutil-test-support') subproject('libutil-test-support')
subproject('libutil-test') subproject('libutil-test')
#subproject('libstore-test-support') subproject('libstore-test-support')
#subproject('libstore-test') subproject('libstore-test')
#subproject('libexpr-test-support') subproject('libfetchers-test')
#subproject('libexpr-test') subproject('libexpr-test-support')
#subproject('libflake-test') subproject('libexpr-test')
subproject('libflake-test')

View file

@ -4,7 +4,7 @@
# remove file extension. # remove file extension.
test_name=$(echo -n "${test?must be defined by caller (test runner)}" | sed \ test_name=$(echo -n "${test?must be defined by caller (test runner)}" | sed \
-e "s|^tests/unit/[^/]*/data/||" \ -e "s|^src/[^/]*-test/data/||" \
-e "s|^tests/functional/||" \ -e "s|^tests/functional/||" \
-e "s|\.sh$||" \ -e "s|\.sh$||" \
) )

View file

@ -52,10 +52,6 @@
# Whether to build Nix. Useful to skip for tasks like testing existing pre-built versions of Nix # Whether to build Nix. Useful to skip for tasks like testing existing pre-built versions of Nix
, doBuild ? true , doBuild ? true
# Run the unit tests as part of the build. See `installUnitTests` for an
# alternative to this.
, doCheck ? __forDefaults.canRunInstalled
# Run the functional tests as part of the build. # Run the functional tests as part of the build.
, doInstallCheck ? test-client != null || __forDefaults.canRunInstalled , doInstallCheck ? test-client != null || __forDefaults.canRunInstalled
@ -88,11 +84,6 @@
# - readline # - readline
, readlineFlavor ? if stdenv.hostPlatform.isWindows then "readline" else "editline" , readlineFlavor ? if stdenv.hostPlatform.isWindows then "readline" else "editline"
# Whether to install unit tests. This is useful when cross compiling
# since we cannot run them natively during the build, but can do so
# later.
, installUnitTests ? doBuild && !__forDefaults.canExecuteHost
# For running the functional tests against a pre-built Nix. Probably # For running the functional tests against a pre-built Nix. Probably
# want to use in conjunction with `doBuild = false;`. # want to use in conjunction with `doBuild = false;`.
, test-daemon ? null , test-daemon ? null
@ -118,7 +109,7 @@ let
# things which should instead be gotten via `finalAttrs` in order to # things which should instead be gotten via `finalAttrs` in order to
# work with overriding. # work with overriding.
attrs = { attrs = {
inherit doBuild doCheck doInstallCheck; inherit doBuild doInstallCheck;
}; };
mkDerivation = mkDerivation =
@ -134,16 +125,11 @@ in
mkDerivation (finalAttrs: let mkDerivation (finalAttrs: let
inherit (finalAttrs) inherit (finalAttrs)
doCheck
doInstallCheck doInstallCheck
; ;
doBuild = !finalAttrs.dontBuild; doBuild = !finalAttrs.dontBuild;
# Either running the unit tests during the build, or installing them
# to be run later, requiresthe unit tests to be built.
buildUnitTests = doCheck || installUnitTests;
in { in {
inherit pname version; inherit pname version;
@ -175,10 +161,8 @@ in {
(fileset.difference ./src ./src/perl) (fileset.difference ./src ./src/perl)
./COPYING ./COPYING
./scripts/local.mk ./scripts/local.mk
] ++ lib.optionals buildUnitTests [ ] ++ lib.optionals enableManual [
./doc/manual ./doc/manual
] ++ lib.optionals buildUnitTests [
./tests/unit
] ++ lib.optionals doInstallCheck [ ] ++ lib.optionals doInstallCheck [
./tests/functional ./tests/functional
])); ]));
@ -191,8 +175,6 @@ in {
# If we are doing just build or just docs, the one thing will use # If we are doing just build or just docs, the one thing will use
# "out". We only need additional outputs if we are doing both. # "out". We only need additional outputs if we are doing both.
++ lib.optional (doBuild && enableManual) "doc" ++ lib.optional (doBuild && enableManual) "doc"
++ lib.optional installUnitTests "check"
++ lib.optional doCheck "testresults"
; ;
nativeBuildInputs = [ nativeBuildInputs = [
@ -234,9 +216,6 @@ in {
({ inherit readline editline; }.${readlineFlavor}) ({ inherit readline editline; }.${readlineFlavor})
] ++ lib.optionals enableMarkdown [ ] ++ lib.optionals enableMarkdown [
lowdown lowdown
] ++ lib.optionals buildUnitTests [
gtest
rapidcheck
] ++ lib.optional stdenv.isLinux libseccomp ] ++ lib.optional stdenv.isLinux libseccomp
++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid ++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid
# There have been issues building these dependencies # There have been issues building these dependencies
@ -252,7 +231,6 @@ in {
] ++ lib.optional enableGC boehmgc; ] ++ lib.optional enableGC boehmgc;
dontBuild = !attrs.doBuild; dontBuild = !attrs.doBuild;
doCheck = attrs.doCheck;
disallowedReferences = [ boost ]; disallowedReferences = [ boost ];
@ -278,18 +256,13 @@ in {
configureFlags = [ configureFlags = [
(lib.enableFeature doBuild "build") (lib.enableFeature doBuild "build")
(lib.enableFeature buildUnitTests "unit-tests")
(lib.enableFeature doInstallCheck "functional-tests") (lib.enableFeature doInstallCheck "functional-tests")
(lib.enableFeature enableManual "doc-gen") (lib.enableFeature enableManual "doc-gen")
(lib.enableFeature enableGC "gc") (lib.enableFeature enableGC "gc")
(lib.enableFeature enableMarkdown "markdown") (lib.enableFeature enableMarkdown "markdown")
(lib.enableFeature installUnitTests "install-unit-tests")
(lib.withFeatureAs true "readline-flavor" readlineFlavor) (lib.withFeatureAs true "readline-flavor" readlineFlavor)
] ++ lib.optionals (!forDevShell) [ ] ++ lib.optionals (!forDevShell) [
"--sysconfdir=/etc" "--sysconfdir=/etc"
] ++ lib.optionals installUnitTests [
"--with-check-bin-dir=${builtins.placeholder "check"}/bin"
"--with-check-lib-dir=${builtins.placeholder "check"}/lib"
] ++ lib.optionals (doBuild) [ ] ++ lib.optionals (doBuild) [
"--with-boost=${boost}/lib" "--with-boost=${boost}/lib"
] ++ lib.optionals (doBuild && stdenv.isLinux) [ ] ++ lib.optionals (doBuild && stdenv.isLinux) [
@ -375,10 +348,6 @@ in {
platforms = lib.platforms.unix ++ lib.platforms.windows; platforms = lib.platforms.unix ++ lib.platforms.windows;
mainProgram = "nix"; mainProgram = "nix";
broken = !(lib.all (a: a) [ broken = !(lib.all (a: a) [
# We cannot run or install unit tests if we don't build them or
# Nix proper (which they depend on).
(installUnitTests -> doBuild)
(doCheck -> doBuild)
# The build process for the manual currently requires extracting # The build process for the manual currently requires extracting
# data from the Nix executable we are trying to document. # data from the Nix executable we are trying to document.
(enableManual -> doBuild) (enableManual -> doBuild)

View file

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

View file

@ -38,27 +38,27 @@ GENERATE_LATEX = NO
# so they can expand variables despite configure variables. # so they can expand variables despite configure variables.
INPUT = \ INPUT = \
@src@/src/libcmd \ @src@/libcmd \
@src@/src/libexpr \ @src@/libexpr \
@src@/src/libexpr/flake \ @src@/libexpr/flake \
@src@/tests/unit/libexpr \ @src@/libexpr-test \
@src@/tests/unit/libexpr/value \ @src@/libexpr-test/value \
@src@/tests/unit/libexpr/test \ @src@/libexpr-test-support/test \
@src@/tests/unit/libexpr/test/value \ @src@/libexpr-test-support/test/value \
@src@/src/libexpr/value \ @src@/libexpr/value \
@src@/src/libfetchers \ @src@/libfetchers \
@src@/src/libmain \ @src@/libmain \
@src@/src/libstore \ @src@/libstore \
@src@/src/libstore/build \ @src@/libstore/build \
@src@/src/libstore/builtins \ @src@/libstore/builtins \
@src@/tests/unit/libstore \ @src@/libstore-test \
@src@/tests/unit/libstore/test \ @src@/libstore-test-support/test \
@src@/src/libutil \ @src@/libutil \
@src@/tests/unit/libutil \ @src@/libutil-test \
@src@/tests/unit/libutil/test \ @src@/libutil-test-support/test \
@src@/src/nix \ @src@/nix \
@src@/src/nix-env \ @src@/nix-env \
@src@/src/nix-store @src@/nix-store
# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names # If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names
# in the source code. If set to NO, only conditional compilation will be # in the source code. If set to NO, only conditional compilation will be

View file

@ -28,7 +28,6 @@ stdenv.mkDerivation (finalAttrs: {
# Source is not compiled, but still must be available for Doxygen # Source is not compiled, but still must be available for Doxygen
# to gather comments. # to gather comments.
(cpp ../.) (cpp ../.)
(cpp ../../tests/unit)
]; ];
}; };

View file

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

View file

@ -0,0 +1,128 @@
project('nix-expr-test-support', 'cpp',
version : files('.version'),
default_options : [
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
)
cxx = meson.get_compiler('cpp')
# See note in ../nix-util/meson.build
deps_private = [ ]
# See note in ../nix-util/meson.build
deps_public = [ ]
# See note in ../nix-util/meson.build
deps_public_subproject = [ ]
# See note in ../nix-util/meson.build
deps_other = [ ]
foreach nix_dep : [
dependency('nix-util'),
dependency('nix-util-test-support'),
dependency('nix-store'),
dependency('nix-store-test-support'),
dependency('nix-expr'),
]
if nix_dep.type_name() == 'internal'
deps_public_subproject += nix_dep
# subproject sadly no good for pkg-config module
deps_other += nix_dep
else
deps_public += nix_dep
endif
endforeach
rapidcheck = dependency('rapidcheck')
deps_public += rapidcheck
add_project_arguments(
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
# It would be nice for our headers to be idempotent instead.
'-include', 'config-util.hh',
'-include', 'config-store.hh',
'-include', 'config-expr.hh',
'-Wno-deprecated-declarations',
'-Wimplicit-fallthrough',
'-Werror=switch',
'-Werror=switch-enum',
'-Wdeprecated-copy',
'-Wignored-qualifiers',
# Enable assertions in libstdc++ by default. Harmless on libc++. Benchmarked
# at ~1% overhead in `nix search`.
#
# FIXME: remove when we get meson 1.4.0 which will default this to on for us:
# https://mesonbuild.com/Release-notes-for-1-4-0.html#ndebug-setting-now-controls-c-stdlib-assertions
'-D_GLIBCXX_ASSERTIONS=1',
language : 'cpp',
)
sources = files(
'tests/value/context.cc',
)
include_dirs = [include_directories('.')]
headers = files(
'tests/libexpr.hh',
'tests/nix_api_expr.hh',
'tests/value/context.hh',
)
if host_machine.system() == 'cygwin' or host_machine.system() == 'windows'
# Windows DLLs are stricter about symbol visibility than Unix shared
# objects --- see https://gcc.gnu.org/wiki/Visibility for details.
# This is a temporary sledgehammer to export everything like on Unix,
# and not detail with this yet.
#
# TODO do not do this, and instead do fine-grained export annotations.
linker_export_flags = ['-Wl,--export-all-symbols']
else
linker_export_flags = []
endif
this_library = library(
'nix-expr-test-support',
sources,
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
# TODO: Remove `-lrapidcheck` when https://github.com/emil-e/rapidcheck/pull/326
# is available. See also ../libutil/build.meson
link_args: linker_export_flags + ['-lrapidcheck'],
install : true,
)
install_headers(headers, subdir : 'nix', preserve_path : true)
requires = []
foreach dep : deps_public_subproject
requires += dep.name()
endforeach
requires += deps_public
import('pkgconfig').generate(
this_library,
filebase : meson.project_name(),
name : 'Nix',
description : 'Nix Package Manager',
subdirs : ['nix'],
extra_cflags : ['-std=c++2a'],
requires : requires,
requires_private : deps_private,
)
meson.override_dependency(meson.project_name(), declare_dependency(
include_directories : include_dirs,
link_with : this_library,
compile_args : ['-std=c++2a'],
dependencies : deps_public_subproject + deps_public,
))

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

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

View file

@ -0,0 +1,125 @@
project('nix-expr-test', 'cpp',
version : files('.version'),
default_options : [
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
)
cxx = meson.get_compiler('cpp')
# See note in ../nix-util/meson.build
deps_private = [ ]
# See note in ../nix-util/meson.build
deps_private_subproject = [ ]
# See note in ../nix-util/meson.build
deps_other = [ ]
foreach nix_dep : [
dependency('nix-util'),
dependency('nix-util-c'),
dependency('nix-util-test-support'),
dependency('nix-store'),
dependency('nix-store-c'),
dependency('nix-store-test-support'),
dependency('nix-expr'),
dependency('nix-expr-c'),
dependency('nix-expr-test-support'),
]
if nix_dep.type_name() == 'internal'
deps_private_subproject += nix_dep
# subproject sadly no good for pkg-config module
deps_other += nix_dep
else
deps_private += nix_dep
endif
endforeach
if host_machine.system() == 'cygwin' or host_machine.system() == 'windows'
# Windows DLLs are stricter about symbol visibility than Unix shared
# objects --- see https://gcc.gnu.org/wiki/Visibility for details.
# This is a temporary sledgehammer to export everything like on Unix,
# and not detail with this yet.
#
# TODO do not do this, and instead do fine-grained export annotations.
linker_export_flags = ['-Wl,--export-all-symbols']
else
linker_export_flags = []
endif
rapidcheck = dependency('rapidcheck')
deps_private += rapidcheck
gtest = dependency('gtest', main : true)
deps_private += gtest
add_project_arguments(
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
# It would be nice for our headers to be idempotent instead.
'-include', 'config-util.hh',
'-include', 'config-store.hh',
'-include', 'config-store.hh',
'-include', 'config-util.h',
'-include', 'config-store.h',
'-include', 'config-expr.h',
'-Wno-deprecated-declarations',
'-Wimplicit-fallthrough',
'-Werror=switch',
'-Werror=switch-enum',
'-Wdeprecated-copy',
'-Wignored-qualifiers',
# Enable assertions in libstdc++ by default. Harmless on libc++. Benchmarked
# at ~1% overhead in `nix search`.
#
# FIXME: remove when we get meson 1.4.0 which will default this to on for us:
# https://mesonbuild.com/Release-notes-for-1-4-0.html#ndebug-setting-now-controls-c-stdlib-assertions
'-D_GLIBCXX_ASSERTIONS=1',
language : 'cpp',
)
sources = files(
'derived-path.cc',
'error_traces.cc',
'eval.cc',
'json.cc',
'main.cc',
'nix_api_expr.cc',
'nix_api_external.cc',
'nix_api_value.cc',
'primops.cc',
'search-path.cc',
'trivial.cc',
'value/context.cc',
'value/print.cc',
'value/value.cc',
)
include_dirs = [include_directories('.')]
this_exe = executable(
meson.project_name(),
sources,
dependencies : deps_private_subproject + deps_private + deps_other,
include_directories : include_dirs,
# TODO: -lrapidcheck, see ../libutil-support/build.meson
link_args: linker_export_flags + ['-lrapidcheck'],
# get main from gtest
install : true,
)
test(meson.project_name(), this_exe, env : ['_NIX_TEST_UNIT_DATA=' + meson.current_source_dir() + '/data'])
meson.override_dependency(meson.project_name(), declare_dependency(
include_directories : include_dirs,
link_with : this_exe,
compile_args : ['-std=c++2a'],
))

View file

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

View file

@ -0,0 +1,109 @@
project('nix-fetchers-test', 'cpp',
version : files('.version'),
default_options : [
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
)
cxx = meson.get_compiler('cpp')
# See note in ../nix-util/meson.build
deps_private = [ ]
# See note in ../nix-util/meson.build
deps_private_subproject = [ ]
# See note in ../nix-util/meson.build
deps_other = [ ]
foreach nix_dep : [
dependency('nix-util'),
dependency('nix-util-c'),
dependency('nix-util-test-support'),
dependency('nix-store'),
dependency('nix-store-c'),
dependency('nix-store-test-support'),
dependency('nix-fetchers'),
]
if nix_dep.type_name() == 'internal'
deps_private_subproject += nix_dep
# subproject sadly no good for pkg-config module
deps_other += nix_dep
else
deps_private += nix_dep
endif
endforeach
if host_machine.system() == 'cygwin' or host_machine.system() == 'windows'
# Windows DLLs are stricter about symbol visibility than Unix shared
# objects --- see https://gcc.gnu.org/wiki/Visibility for details.
# This is a temporary sledgehammer to export everything like on Unix,
# and not detail with this yet.
#
# TODO do not do this, and instead do fine-grained export annotations.
linker_export_flags = ['-Wl,--export-all-symbols']
else
linker_export_flags = []
endif
rapidcheck = dependency('rapidcheck')
deps_private += rapidcheck
gtest = dependency('gtest', main : true)
deps_private += gtest
add_project_arguments(
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
# It would be nice for our headers to be idempotent instead.
'-include', 'config-util.hh',
'-include', 'config-store.hh',
'-include', 'config-store.hh',
'-include', 'config-util.h',
'-include', 'config-store.h',
'-Wno-deprecated-declarations',
'-Wimplicit-fallthrough',
'-Werror=switch',
'-Werror=switch-enum',
'-Wdeprecated-copy',
'-Wignored-qualifiers',
# Enable assertions in libstdc++ by default. Harmless on libc++. Benchmarked
# at ~1% overhead in `nix search`.
#
# FIXME: remove when we get meson 1.4.0 which will default this to on for us:
# https://mesonbuild.com/Release-notes-for-1-4-0.html#ndebug-setting-now-controls-c-stdlib-assertions
'-D_GLIBCXX_ASSERTIONS=1',
language : 'cpp',
)
sources = files(
'public-key.cc',
)
include_dirs = [include_directories('.')]
this_exe = executable(
meson.project_name(),
sources,
dependencies : deps_private_subproject + deps_private + deps_other,
include_directories : include_dirs,
# TODO: -lrapidcheck, see ../libutil-support/build.meson
link_args: linker_export_flags + ['-lrapidcheck'],
# get main from gtest
install : true,
)
test(meson.project_name(), this_exe, env : ['_NIX_TEST_UNIT_DATA=' + meson.current_source_dir() + '/data'])
meson.override_dependency(meson.project_name(), declare_dependency(
include_directories : include_dirs,
link_with : this_exe,
compile_args : ['-std=c++2a'],
))

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

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

View file

@ -0,0 +1,114 @@
project('nix-flake-test', 'cpp',
version : files('.version'),
default_options : [
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
)
cxx = meson.get_compiler('cpp')
# See note in ../nix-util/meson.build
deps_private = [ ]
# See note in ../nix-util/meson.build
deps_private_subproject = [ ]
# See note in ../nix-util/meson.build
deps_other = [ ]
foreach nix_dep : [
dependency('nix-util'),
dependency('nix-util-c'),
dependency('nix-util-test-support'),
dependency('nix-store'),
dependency('nix-store-c'),
dependency('nix-store-test-support'),
dependency('nix-expr'),
dependency('nix-expr-c'),
dependency('nix-expr-test-support'),
dependency('nix-flake'),
]
if nix_dep.type_name() == 'internal'
deps_private_subproject += nix_dep
# subproject sadly no good for pkg-config module
deps_other += nix_dep
else
deps_private += nix_dep
endif
endforeach
if host_machine.system() == 'cygwin' or host_machine.system() == 'windows'
# Windows DLLs are stricter about symbol visibility than Unix shared
# objects --- see https://gcc.gnu.org/wiki/Visibility for details.
# This is a temporary sledgehammer to export everything like on Unix,
# and not detail with this yet.
#
# TODO do not do this, and instead do fine-grained export annotations.
linker_export_flags = ['-Wl,--export-all-symbols']
else
linker_export_flags = []
endif
rapidcheck = dependency('rapidcheck')
deps_private += rapidcheck
gtest = dependency('gtest', main : true)
deps_private += gtest
add_project_arguments(
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
# It would be nice for our headers to be idempotent instead.
'-include', 'config-util.hh',
'-include', 'config-store.hh',
'-include', 'config-expr.hh',
'-include', 'config-util.h',
'-include', 'config-store.h',
'-include', 'config-expr.h',
'-Wno-deprecated-declarations',
'-Wimplicit-fallthrough',
'-Werror=switch',
'-Werror=switch-enum',
'-Wdeprecated-copy',
'-Wignored-qualifiers',
# Enable assertions in libstdc++ by default. Harmless on libc++. Benchmarked
# at ~1% overhead in `nix search`.
#
# FIXME: remove when we get meson 1.4.0 which will default this to on for us:
# https://mesonbuild.com/Release-notes-for-1-4-0.html#ndebug-setting-now-controls-c-stdlib-assertions
'-D_GLIBCXX_ASSERTIONS=1',
language : 'cpp',
)
sources = files(
'flakeref.cc',
'url-name.cc',
)
include_dirs = [include_directories('.')]
this_exe = executable(
meson.project_name(),
sources,
dependencies : deps_private_subproject + deps_private + deps_other,
include_directories : include_dirs,
# TODO: -lrapidcheck, see ../libutil-support/build.meson
link_args: linker_export_flags + ['-lrapidcheck'],
# get main from gtest
install : true,
)
test(meson.project_name(), this_exe, env : ['_NIX_TEST_UNIT_DATA=' + meson.current_source_dir() + '/data'])
meson.override_dependency(meson.project_name(), declare_dependency(
include_directories : include_dirs,
link_with : this_exe,
compile_args : ['-std=c++2a'],
))

View file

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

View file

@ -0,0 +1,130 @@
project('nix-store-test-support', 'cpp',
version : files('.version'),
default_options : [
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
)
cxx = meson.get_compiler('cpp')
# See note in ../nix-util/meson.build
deps_private = [ ]
# See note in ../nix-util/meson.build
deps_public = [ ]
# See note in ../nix-util/meson.build
deps_public_subproject = [ ]
# See note in ../nix-util/meson.build
deps_other = [ ]
foreach nix_dep : [
dependency('nix-util'),
dependency('nix-util-test-support'),
dependency('nix-store'),
]
if nix_dep.type_name() == 'internal'
deps_public_subproject += nix_dep
# subproject sadly no good for pkg-config module
deps_other += nix_dep
else
deps_public += nix_dep
endif
endforeach
rapidcheck = dependency('rapidcheck')
deps_public += rapidcheck
add_project_arguments(
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
# It would be nice for our headers to be idempotent instead.
'-include', 'config-util.hh',
'-include', 'config-store.hh',
'-Wno-deprecated-declarations',
'-Wimplicit-fallthrough',
'-Werror=switch',
'-Werror=switch-enum',
'-Wdeprecated-copy',
'-Wignored-qualifiers',
# Enable assertions in libstdc++ by default. Harmless on libc++. Benchmarked
# at ~1% overhead in `nix search`.
#
# FIXME: remove when we get meson 1.4.0 which will default this to on for us:
# https://mesonbuild.com/Release-notes-for-1-4-0.html#ndebug-setting-now-controls-c-stdlib-assertions
'-D_GLIBCXX_ASSERTIONS=1',
language : 'cpp',
)
sources = files(
'tests/derived-path.cc',
'tests/outputs-spec.cc',
'tests/path.cc',
)
include_dirs = [include_directories('.')]
headers = files(
'tests/derived-path.hh',
'tests/libstore.hh',
'tests/nix_api_store.hh',
'tests/outputs-spec.hh',
'tests/path.hh',
'tests/protocol.hh',
)
if host_machine.system() == 'cygwin' or host_machine.system() == 'windows'
# Windows DLLs are stricter about symbol visibility than Unix shared
# objects --- see https://gcc.gnu.org/wiki/Visibility for details.
# This is a temporary sledgehammer to export everything like on Unix,
# and not detail with this yet.
#
# TODO do not do this, and instead do fine-grained export annotations.
linker_export_flags = ['-Wl,--export-all-symbols']
else
linker_export_flags = []
endif
this_library = library(
'nix-store-test-support',
sources,
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
# TODO: Remove `-lrapidcheck` when https://github.com/emil-e/rapidcheck/pull/326
# is available. See also ../libutil/build.meson
link_args: linker_export_flags + ['-lrapidcheck'],
install : true,
)
install_headers(headers, subdir : 'nix', preserve_path : true)
requires = []
foreach dep : deps_public_subproject
requires += dep.name()
endforeach
requires += deps_public
import('pkgconfig').generate(
this_library,
filebase : meson.project_name(),
name : 'Nix',
description : 'Nix Package Manager',
subdirs : ['nix'],
extra_cflags : ['-std=c++2a'],
requires : requires,
requires_private : deps_private,
)
meson.override_dependency(meson.project_name(), declare_dependency(
include_directories : include_dirs,
link_with : this_library,
compile_args : ['-std=c++2a'],
dependencies : deps_public_subproject + deps_public,
))

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

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

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