bear: re-enable tests
Apply patch to run unit/lit tests in checkPhase instead of buildPhase. Move test dependencies to nativeCheckInputs/checkInputs. Use finalAttrs to make doCheck overridable. Disable failings tests from lit test suite.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index f1ecfe0..9056f9d 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -83,8 +83,9 @@ ExternalProject_Add(BearSource
|
||||
-DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_MODULE_LINKER_FLAGS}
|
||||
-DROOT_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
|
||||
${CMAKE_CACHE_ARGS_EXTRA}
|
||||
- TEST_BEFORE_INSTALL
|
||||
+ TEST_EXCLUDE_FROM_MAIN
|
||||
1
|
||||
+ STEP_TARGETS test
|
||||
TEST_COMMAND
|
||||
ctest # or `ctest -T memcheck`
|
||||
)
|
||||
@@ -100,7 +101,8 @@ if (ENABLE_FUNC_TESTS)
|
||||
-DCMAKE_INSTALL_LIBDIR:PATH=${CMAKE_INSTALL_LIBDIR}
|
||||
-DCMAKE_INSTALL_BINDIR:PATH=${CMAKE_INSTALL_BINDIR}
|
||||
-DSTAGED_INSTALL_PREFIX:PATH=${STAGED_INSTALL_PREFIX}
|
||||
- TEST_BEFORE_INSTALL
|
||||
+ TEST_EXCLUDE_FROM_MAIN
|
||||
+ STEP_TARGETS test
|
||||
1
|
||||
INSTALL_COMMAND
|
||||
""
|
||||
@@ -20,14 +20,14 @@
|
||||
coreutils,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "bear";
|
||||
version = "3.1.5";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "rizsotto";
|
||||
repo = pname;
|
||||
rev = version;
|
||||
repo = "bear";
|
||||
rev = finalAttrs.version;
|
||||
hash = "sha256-pwdjytP+kmTwozRl1Gd0jUqRs3wfvcYPqiQvVwa6s9c=";
|
||||
};
|
||||
|
||||
@@ -35,10 +35,6 @@ stdenv.mkDerivation rec {
|
||||
cmake
|
||||
ninja
|
||||
pkg-config
|
||||
|
||||
# Used for functional tests, which run during buildPhase.
|
||||
lit
|
||||
python3
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
@@ -46,7 +42,6 @@ stdenv.mkDerivation rec {
|
||||
protobuf
|
||||
openssl
|
||||
nlohmann_json
|
||||
gtest
|
||||
spdlog
|
||||
c-ares
|
||||
zlib
|
||||
@@ -54,15 +49,52 @@ stdenv.mkDerivation rec {
|
||||
re2
|
||||
];
|
||||
|
||||
patches = [
|
||||
# This patch is necessary to run tests in a separate phase. By default
|
||||
# test targets are run with ALL, which is not what we want. This patch creates
|
||||
# separate 'test' step targets for each cmake ExternalProject:
|
||||
# - BearTest-test (functional lit tests)
|
||||
# - BearSource-test (unit tests via gtest)
|
||||
./0001-exclude-tests-from-all.patch
|
||||
];
|
||||
|
||||
nativeCheckInputs = [
|
||||
lit
|
||||
python3
|
||||
];
|
||||
|
||||
checkInputs = [
|
||||
gtest
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
# Build system and generated files concatenate install prefix and
|
||||
# CMAKE_INSTALL_{BIN,LIB}DIR, which breaks if these are absolute paths.
|
||||
"-DCMAKE_INSTALL_BINDIR=bin"
|
||||
"-DCMAKE_INSTALL_LIBDIR=lib"
|
||||
(lib.cmakeBool "ENABLE_UNIT_TESTS" false)
|
||||
(lib.cmakeBool "ENABLE_FUNC_TESTS" false)
|
||||
(lib.cmakeBool "ENABLE_UNIT_TESTS" finalAttrs.doCheck)
|
||||
(lib.cmakeBool "ENABLE_FUNC_TESTS" finalAttrs.doCheck)
|
||||
];
|
||||
|
||||
checkTarget = lib.concatStringsSep " " [
|
||||
"BearTest-test"
|
||||
"BearSource-test"
|
||||
];
|
||||
|
||||
doCheck = true;
|
||||
|
||||
env = {
|
||||
# Disable failing tests. The cause is not immediately clear.
|
||||
LIT_FILTER_OUT = lib.concatStringsSep "|" [
|
||||
"cases/compilation/output/config/filter_compilers.sh"
|
||||
"cases/intercept/preload/posix/execvpe/success_to_resolve.c"
|
||||
"cases/intercept/preload/posix/popen/success.c"
|
||||
"cases/intercept/preload/posix/posix_spawnp/success_to_resolve.c"
|
||||
"cases/intercept/preload/posix/system/success.c"
|
||||
"cases/intercept/preload/shell_commands_intercepted_without_shebang.sh"
|
||||
];
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
patchShebangs test/bin
|
||||
|
||||
@@ -87,4 +119,4 @@ stdenv.mkDerivation rec {
|
||||
platforms = platforms.unix;
|
||||
maintainers = with maintainers; [ DieracDelta ];
|
||||
};
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user