Use positive source filtering for the standalone functional tests job

Additionally this skipping of the building is reimplemented to be a bit
more robust and use the same idioms as the functionality for skipping
the tests. In particular, it will now work even if the source files
exist, so we can do this during development too.
This commit is contained in:
John Ericson 2023-10-06 11:57:31 -04:00
parent c29b8ba142
commit 47b3508665
6 changed files with 61 additions and 36 deletions

View File

@ -1,3 +1,7 @@
-include Makefile.config
clean-files += Makefile.config
ifeq ($(ENABLE_BUILD), yes)
makefiles = \ makefiles = \
mk/precompiled-headers.mk \ mk/precompiled-headers.mk \
local.mk \ local.mk \
@ -18,15 +22,18 @@ makefiles = \
misc/upstart/local.mk \ misc/upstart/local.mk \
doc/manual/local.mk \ doc/manual/local.mk \
doc/internal-api/local.mk doc/internal-api/local.mk
endif
-include Makefile.config ifeq ($(ENABLE_BUILD)_$(ENABLE_TESTS), yes_yes)
ifeq ($(tests), yes)
UNIT_TEST_ENV = _NIX_TEST_UNIT_DATA=unit-test-data UNIT_TEST_ENV = _NIX_TEST_UNIT_DATA=unit-test-data
makefiles += \ makefiles += \
src/libutil/tests/local.mk \ src/libutil/tests/local.mk \
src/libstore/tests/local.mk \ src/libstore/tests/local.mk \
src/libexpr/tests/local.mk \ src/libexpr/tests/local.mk
endif
ifeq ($(ENABLE_TESTS), yes)
makefiles += \
tests/functional/local.mk \ tests/functional/local.mk \
tests/functional/ca/local.mk \ tests/functional/ca/local.mk \
tests/functional/dyn-drv/local.mk \ tests/functional/dyn-drv/local.mk \

View File

@ -46,5 +46,6 @@ sandbox_shell = @sandbox_shell@
storedir = @storedir@ storedir = @storedir@
sysconfdir = @sysconfdir@ sysconfdir = @sysconfdir@
system = @system@ system = @system@
tests = @tests@ ENABLE_BUILD = @ENABLE_BUILD@
ENABLE_TESTS = @ENABLE_TESTS@
internal_api_docs = @internal_api_docs@ internal_api_docs = @internal_api_docs@

View File

@ -152,12 +152,17 @@ if test "x$GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC" = xyes; then
LDFLAGS="-latomic $LDFLAGS" LDFLAGS="-latomic $LDFLAGS"
fi fi
# Running the functional tests without building Nix is useful for testing
# different pre-built versions of Nix against each other.
AC_ARG_ENABLE(build, AS_HELP_STRING([--disable-build],[Do not build nix]),
ENABLE_BUILD=$enableval, ENABLE_BUILD=yes)
AC_SUBST(ENABLE_BUILD)
# Building without tests is useful for bootstrapping with a smaller footprint # Building without tests is useful for bootstrapping with a smaller footprint
# or running the tests in a separate derivation. Otherwise, we do compile and # or running the tests in a separate derivation. Otherwise, we do compile and
# run them. # run them.
AC_ARG_ENABLE(tests, AS_HELP_STRING([--disable-tests],[Do not build the tests]), AC_ARG_ENABLE(tests, AS_HELP_STRING([--disable-tests],[Do not build the tests]),
tests=$enableval, tests=yes) ENABLE_TESTS=$enableval, ENABLE_TESTS=yes)
AC_SUBST(tests) AC_SUBST(ENABLE_TESTS)
# Building without API docs is the default as Nix' C++ interfaces are internal and unstable. # Building without API docs is the default as Nix' C++ interfaces are internal and unstable.
AC_ARG_ENABLE(internal_api_docs, AS_HELP_STRING([--enable-internal-api-docs],[Build API docs for Nix's internal unstable C++ interfaces]), AC_ARG_ENABLE(internal_api_docs, AS_HELP_STRING([--enable-internal-api-docs],[Build API docs for Nix's internal unstable C++ interfaces]),
@ -289,7 +294,7 @@ if test "$gc" = yes; then
fi fi
if test "$tests" = yes; then if test "$ENABLE_TESTS" = yes; then
# Look for gtest. # Look for gtest.
PKG_CHECK_MODULES([GTEST], [gtest_main]) PKG_CHECK_MODULES([GTEST], [gtest_main])

View File

@ -59,29 +59,40 @@
# that would interfere with repo semantics. # that would interfere with repo semantics.
fileset.fileFilter (f: f.name != ".gitignore") ./.; fileset.fileFilter (f: f.name != ".gitignore") ./.;
configureFiles = fileset.unions [
./.version
./configure.ac
./m4
# TODO: do we really need README.md? It doesn't seem used in the build.
./README.md
];
topLevelBuildFiles = fileset.unions [
./local.mk
./Makefile
./Makefile.config.in
./mk
];
functionalTestFiles = fileset.unions [
./tests/functional
(fileset.fileFilter (f: lib.strings.hasPrefix "nix-profile" f.name) ./scripts)
];
nixSrc = fileset.toSource { nixSrc = fileset.toSource {
root = ./.; root = ./.;
fileset = fileset.intersect baseFiles (fileset.unions [ fileset = fileset.intersect baseFiles (fileset.unions [
./.version configureFiles
topLevelBuildFiles
./boehmgc-coroutine-sp-fallback.diff ./boehmgc-coroutine-sp-fallback.diff
./bootstrap.sh
./configure.ac
./doc ./doc
./local.mk
./m4
./Makefile
./Makefile.config.in
./misc ./misc
./mk
./precompiled-headers.h ./precompiled-headers.h
./src ./src
./tests/functional
./unit-test-data ./unit-test-data
./COPYING ./COPYING
./scripts/local.mk ./scripts/local.mk
(fileset.fileFilter (f: lib.strings.hasPrefix "nix-profile" f.name) ./scripts) functionalTestFiles
# TODO: do we really need README.md? It doesn't seem used in the build.
./README.md
]); ]);
}; };
@ -252,7 +263,6 @@
testNixVersions = pkgs: client: daemon: with commonDeps { inherit pkgs; }; with pkgs.lib; pkgs.stdenv.mkDerivation { testNixVersions = pkgs: client: daemon: with commonDeps { inherit pkgs; }; with pkgs.lib; pkgs.stdenv.mkDerivation {
NIX_DAEMON_PACKAGE = daemon; NIX_DAEMON_PACKAGE = daemon;
NIX_CLIENT_PACKAGE = client; NIX_CLIENT_PACKAGE = client;
HAVE_LOCAL_NIX_BUILD = false;
name = name =
"nix-tests" "nix-tests"
+ optionalString + optionalString
@ -261,7 +271,14 @@
"-${client.version}-against-${daemon.version}"; "-${client.version}-against-${daemon.version}";
inherit version; inherit version;
src = nixSrc; src = fileset.toSource {
root = ./.;
fileset = fileset.intersect baseFiles (fileset.unions [
configureFiles
topLevelBuildFiles
functionalTestFiles
]);
};
VERSION_SUFFIX = versionSuffix; VERSION_SUFFIX = versionSuffix;
@ -271,19 +288,20 @@
enableParallelBuilding = true; enableParallelBuilding = true;
configureFlags = testConfigureFlags; # otherwise configure fails configureFlags =
testConfigureFlags # otherwise configure fails
++ [ "--disable-build" ];
dontBuild = true;
doInstallCheck = true; doInstallCheck = true;
buildPhase = ''
# Remove the source files to make sure that we're not accidentally rebuilding Nix
rm src/**/*.cc
'';
installPhase = '' installPhase = ''
mkdir -p $out mkdir -p $out
''; '';
installCheckPhase = "make installcheck -j$NIX_BUILD_CORES -l$NIX_BUILD_CORES"; installCheckPhase = ''
mkdir -p src/nix-channel
make installcheck -j$NIX_BUILD_CORES -l$NIX_BUILD_CORES
'';
}; };
binaryTarball = nix: pkgs: binaryTarball = nix: pkgs:

View File

@ -1,5 +1,3 @@
clean-files += Makefile.config
GLOBAL_CXXFLAGS += -Wno-deprecated-declarations -Werror=switch GLOBAL_CXXFLAGS += -Wno-deprecated-declarations -Werror=switch
# Allow switch-enum to be overridden for files that do not support it, usually because of dependency headers. # Allow switch-enum to be overridden for files that do not support it, usually because of dependency headers.
ERROR_SWITCH_ENUM = -Werror=switch-enum ERROR_SWITCH_ENUM = -Werror=switch-enum

View File

@ -1,7 +1,3 @@
# whether to run the tests that assume that we have a local build of
# Nix
HAVE_LOCAL_NIX_BUILD ?= 1
nix_tests = \ nix_tests = \
test-infra.sh \ test-infra.sh \
init.sh \ init.sh \
@ -131,7 +127,7 @@ ifeq ($(HAVE_LIBCPUID), 1)
nix_tests += compute-levels.sh nix_tests += compute-levels.sh
endif endif
ifeq ($(HAVE_LOCAL_NIX_BUILD), 1) ifeq ($(ENABLE_BUILD), yes)
nix_tests += test-libstoreconsumer.sh nix_tests += test-libstoreconsumer.sh
ifeq ($(BUILD_SHARED_LIBS), 1) ifeq ($(BUILD_SHARED_LIBS), 1)