-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.nix
86 lines (76 loc) · 1.91 KB
/
tests.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{
lib,
system,
rustPlatform-cov,
rust-toolchain-llvm-tools,
python3,
assetFilter,
sourceFilter,
}:
let
inherit (python3.pkgs) lzallright;
testFilter = p: t: builtins.match ".*/(pyproject\.toml|tests|tests/.*\.py)$" p != null;
in
{
pytest =
with python3.pkgs;
buildPythonPackage {
inherit (lzallright) version;
pname = "${lzallright.pname}-tests-pytest";
format = "other";
src = lib.cleanSourceWith {
src = ./.;
filter = p: t: (testFilter p t) || (assetFilter p t);
};
dontBuild = true;
dontInstall = true;
nativeCheckInputs = [
lzallright
pytestCheckHook
];
};
}
// lib.optionalAttrs (system == "x86_64-linux") {
coverage =
let
lzallright-cov = lzallright.override {
coverage = true;
rustPlatform = rustPlatform-cov;
cargo = rust-toolchain-llvm-tools;
rustc = rust-toolchain-llvm-tools;
};
in
with python3.pkgs;
buildPythonPackage {
inherit (lzallright) version cargoDeps;
pname = "${lzallright.pname}-tests-coverage";
format = "other";
src = lib.cleanSourceWith {
src = ./.;
filter = p: t: (sourceFilter p t) || (testFilter p t) || (assetFilter p t);
};
dontBuild = true;
dontInstall = true;
preCheck = ''
source <(cargo llvm-cov show-env --export-prefix)
LLVM_COV_FLAGS=$(echo -n $(find ${lzallright-cov} -name "*.so"))
export LLVM_COV_FLAGS
'';
postCheck = ''
rm -r $out
cargo llvm-cov report -vv --ignore-filename-regex cargo-vendor-dir --codecov --output-path $out
'';
nativeBuildInputs = (
with rustPlatform-cov;
[
cargoSetupHook
]
);
nativeCheckInputs = with pkgs; [
rust-toolchain-llvm-tools
cargo-llvm-cov
lzallright-cov
pytestCheckHook
];
};
}