1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchpatch,
6 autoreconfHook,
7 kyua,
8 gitUpdater,
9}:
10
11stdenv.mkDerivation (finalAttrs: {
12 pname = "atf";
13 version = "0.23";
14
15 src = fetchFromGitHub {
16 owner = "freebsd";
17 repo = "atf";
18 tag = "atf-${finalAttrs.version}";
19 hash = "sha256-g9cXeiCaiyGQXtg6eyrbRQpqk4VLGSFuhfPB+ynbDIo=";
20 };
21
22 postPatch =
23 lib.optionalString finalAttrs.doInstallCheck ''
24 # Can’t find `c_helpers` in the work folder.
25 substituteInPlace test-programs/Kyuafile \
26 --replace-fail 'atf_test_program{name="srcdir_test"}' ""
27 ''
28 # These tests fail on Darwin.
29 + lib.optionalString (finalAttrs.doInstallCheck && stdenv.hostPlatform.isDarwin) ''
30 substituteInPlace atf-c/detail/process_test.c \
31 --replace-fail 'ATF_TP_ADD_TC(tp, status_coredump);' ""
32 ''
33 # This test fails on Linux.
34 + lib.optionalString (finalAttrs.doInstallCheck && stdenv.hostPlatform.isLinux) ''
35 substituteInPlace atf-c/detail/fs_test.c \
36 --replace-fail 'ATF_TP_ADD_TC(tp, eaccess);' ""
37 '';
38
39 strictDeps = true;
40
41 nativeBuildInputs = [ autoreconfHook ];
42
43 enableParallelBuilding = true;
44
45 makeFlags = [
46 # ATF isn’t compatible with C++17, which is the default on current clang and GCC.
47 "CXXFLAGS=-std=c++14"
48 ];
49
50 doInstallCheck = true;
51
52 nativeInstallCheckInputs = [
53 kyua
54 ];
55
56 installCheckPhase = ''
57 runHook preInstallCheck
58 HOME=$TMPDIR PATH=$out/bin:$PATH kyua test
59 runHook postInstallCheck
60 '';
61
62 passthru.updateScript = gitUpdater { rev-prefix = "atf-"; };
63
64 __structuredAttrs = true;
65
66 meta = {
67 description = "Libraries to write tests in C, C++, and shell";
68 homepage = "https://github.com/freebsd/atf/";
69 license = lib.licenses.bsd3;
70 mainProgram = "atf-sh";
71 maintainers = with lib.maintainers; [ reckenrode ];
72 platforms = lib.platforms.unix;
73 };
74})