root: add package test test-thisroot

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