tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
root: add package test test-thisroot
Shamrock Lee
3 years ago
a664ec27
7f91dec5
+58
3 changed files
expand all
collapse all
unified
split
pkgs
applications
science
misc
root
default.nix
tests
default.nix
test-thisroot.nix
+5
pkgs/applications/science/misc/root/default.nix
···
1
1
{ stdenv
2
2
, lib
3
3
+
, callPackage
3
4
, fetchFromGitHub
4
5
, fetchpatch
5
6
, makeWrapper
···
70
71
stdenv.mkDerivation rec {
71
72
pname = "root";
72
73
version = "6.26.08";
74
74
+
75
75
+
passthru = {
76
76
+
tests = import ./tests { inherit callPackage; };
77
77
+
};
73
78
74
79
src = fetchFromGitHub {
75
80
owner = "root-project";
+4
pkgs/applications/science/misc/root/tests/default.nix
···
1
1
+
{ callPackage }:
2
2
+
{
3
3
+
test-thisroot = callPackage ./test-thisroot.nix { };
4
4
+
}
+49
pkgs/applications/science/misc/root/tests/test-thisroot.nix
···
1
1
+
{ lib
2
2
+
, runCommand
3
3
+
, root
4
4
+
, bash
5
5
+
, fish
6
6
+
, ksh
7
7
+
, tcsh
8
8
+
, zsh
9
9
+
}: runCommand "test-thisroot"
10
10
+
{
11
11
+
meta = with lib; {
12
12
+
description = "Test for root thisroot.* sourcing";
13
13
+
maintainers = unique ((with maintainers; [ ShamrockLee ]) ++ root.meta.maintainers);
14
14
+
};
15
15
+
}
16
16
+
''
17
17
+
set -eu -o pipefail
18
18
+
declare -a shellNameArray shellOutpathArray sourcefileNameArray sourceCommandArray
19
19
+
shellNameArray=( bash zsh tcsh fish )
20
20
+
shellOutpathArray=( "${bash}" "${zsh}" "${tcsh}" "${fish}")
21
21
+
sourcefileNameArray=( thisroot.sh thisroot.sh thisroot.csh thisroot.fish )
22
22
+
sourceCommandArray=( "source" "source" "source" "source" )
23
23
+
debugFlagstrArray=( "-e" "-e" "-e" "" )
24
24
+
nShellToTest="''${#shellNameArray[@]}"
25
25
+
if [[ "''${#shellOutpathArray[@]}" -ne "$nShellToTest" ]] \
26
26
+
|| [[ "''${#sourcefileNameArray[@]}" -ne "$nShellToTest" ]] \
27
27
+
|| [[ "''${#sourceCommandArray[@]}" -ne "$nShellToTest" ]] \
28
28
+
|| [[ "''${#debugFlagstrArray[@]}" -ne "$nShellToTest" ]]
29
29
+
then
30
30
+
echo "error: Lengths of test parameter arrays doesn't match." >&2
31
31
+
exit 1
32
32
+
fi
33
33
+
typePExpect="${root}/bin/root"
34
34
+
for ((i=0; i<$nShellToTest; ++i)); do
35
35
+
tryCommand="''${sourceCommandArray[$i]} \"${root}/bin/''${sourcefileNameArray[$i]}\""
36
36
+
echo "Testing ''${shellNameArray[$i]} $tryCommand"
37
37
+
# Home directory for Fish
38
38
+
HOME_TEMP="$(mktemp -d temporary_home_XXXXXX)"
39
39
+
binPATHGot="$(PATH="''${shellOutpathArray[$i]}/bin" HOME=$HOME_TEMP "''${shellNameArray[$i]}" ''${debugFlagstrArray[$i]} -c "$tryCommand && echo \"\$PATH\"")"
40
40
+
rm -r "$HOME_TEMP"
41
41
+
typePGot="$(PATH="$binPATHGot" type -p root)"
42
42
+
if [[ "$typePGot" != "$typePExpect" ]]; then
43
43
+
echo "error: Got PATH \"$binPATHGot\", in which the root executable path is \"$typePGot\". Expect root executable path \"$typePExpect\"." >&2
44
44
+
exit 1
45
45
+
fi
46
46
+
done
47
47
+
echo "test-thisroot pass!"
48
48
+
touch "$out"
49
49
+
''