Skip to content

Commit 3862695

Browse files
authored
buildOctavePackage: add passthru tests (#411718)
2 parents 41609fd + a25d57d commit 3862695

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed

pkgs/development/interpreters/octave/build-octave-package.nix

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
stdenv,
1010
config,
1111
octave,
12+
callPackage,
1213
texinfo,
1314
computeRequiredOctavePackages,
1415
writeRequiredOctavePackagesHook,
@@ -64,13 +65,6 @@ let
6465
writeRequiredOctavePackagesHook
6566
] ++ nativeBuildInputs;
6667

67-
passthru' = {
68-
updateScript = [
69-
../../../../maintainers/scripts/update-octave-packages
70-
(builtins.unsafeGetAttrPos "pname" octave.pkgs.${attrs.pname}).file
71-
];
72-
} // passthru;
73-
7468
# This step is required because when
7569
# a = { test = [ "a" "b" ]; }; b = { test = [ "c" "d" ]; };
7670
# (a // b).test = [ "c" "d" ];
@@ -81,9 +75,9 @@ let
8175
"nativeBuildInputs"
8276
"passthru"
8377
];
84-
8578
in
8679
stdenv.mkDerivation (
80+
finalAttrs:
8781
{
8882
packageName = "${fullLibName}";
8983
# The name of the octave package ends up being
@@ -136,7 +130,22 @@ stdenv.mkDerivation (
136130
# together with Octave.
137131
dontInstall = true;
138132

139-
passthru = passthru';
133+
passthru =
134+
{
135+
updateScript = [
136+
../../../../maintainers/scripts/update-octave-packages
137+
(builtins.unsafeGetAttrPos "pname" octave.pkgs.${attrs.pname}).file
138+
];
139+
}
140+
// passthru
141+
// {
142+
tests = {
143+
testOctaveBuildEnv = (octave.withPackages (os: [ finalAttrs.finalPackage ])).overrideAttrs (old: {
144+
name = "${finalAttrs.name}-pkg-install";
145+
});
146+
testOctavePkgTests = callPackage ./run-pkg-test.nix { } finalAttrs.finalPackage;
147+
} // passthru.tests or { };
148+
};
140149

141150
inherit meta;
142151
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
octave,
3+
runCommand,
4+
}:
5+
package:
6+
7+
runCommand "${package.name}-pkg-test"
8+
{
9+
nativeBuildInputs = [
10+
(octave.withPackages (os: [ package ]))
11+
];
12+
}
13+
''
14+
{ octave-cli --eval 'pkg test ${package.pname}' || touch FAILED_ERRCODE; } \
15+
|& tee >( grep --quiet '^Failure Summary:$' && touch FAILED_OUTPUT || : ; cat >/dev/null )
16+
if [[ -f FAILED_ERRCODE ]]; then
17+
echo >&2 "octave-cli returned with non-zero exit code."
18+
false
19+
elif [[ -f FAILED_OUTPUT ]]; then
20+
echo >&2 "Test failures detected in output."
21+
false
22+
else
23+
touch $out
24+
fi
25+
''

0 commit comments

Comments
 (0)