mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 08:23:09 +00:00
root: add package test test-thisroot
This commit is contained in:
parent
7f91dec5dd
commit
a664ec27f4
@ -1,5 +1,6 @@
|
||||
{ stdenv
|
||||
, lib
|
||||
, callPackage
|
||||
, fetchFromGitHub
|
||||
, fetchpatch
|
||||
, makeWrapper
|
||||
@ -71,6 +72,10 @@ stdenv.mkDerivation rec {
|
||||
pname = "root";
|
||||
version = "6.26.08";
|
||||
|
||||
passthru = {
|
||||
tests = import ./tests { inherit callPackage; };
|
||||
};
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "root-project";
|
||||
repo = "root";
|
||||
|
4
pkgs/applications/science/misc/root/tests/default.nix
Normal file
4
pkgs/applications/science/misc/root/tests/default.nix
Normal file
@ -0,0 +1,4 @@
|
||||
{ callPackage }:
|
||||
{
|
||||
test-thisroot = callPackage ./test-thisroot.nix { };
|
||||
}
|
49
pkgs/applications/science/misc/root/tests/test-thisroot.nix
Normal file
49
pkgs/applications/science/misc/root/tests/test-thisroot.nix
Normal file
@ -0,0 +1,49 @@
|
||||
{ lib
|
||||
, runCommand
|
||||
, root
|
||||
, bash
|
||||
, fish
|
||||
, ksh
|
||||
, tcsh
|
||||
, zsh
|
||||
}: runCommand "test-thisroot"
|
||||
{
|
||||
meta = with lib; {
|
||||
description = "Test for root thisroot.* sourcing";
|
||||
maintainers = unique ((with maintainers; [ ShamrockLee ]) ++ root.meta.maintainers);
|
||||
};
|
||||
}
|
||||
''
|
||||
set -eu -o pipefail
|
||||
declare -a shellNameArray shellOutpathArray sourcefileNameArray sourceCommandArray
|
||||
shellNameArray=( bash zsh tcsh fish )
|
||||
shellOutpathArray=( "${bash}" "${zsh}" "${tcsh}" "${fish}")
|
||||
sourcefileNameArray=( thisroot.sh thisroot.sh thisroot.csh thisroot.fish )
|
||||
sourceCommandArray=( "source" "source" "source" "source" )
|
||||
debugFlagstrArray=( "-e" "-e" "-e" "" )
|
||||
nShellToTest="''${#shellNameArray[@]}"
|
||||
if [[ "''${#shellOutpathArray[@]}" -ne "$nShellToTest" ]] \
|
||||
|| [[ "''${#sourcefileNameArray[@]}" -ne "$nShellToTest" ]] \
|
||||
|| [[ "''${#sourceCommandArray[@]}" -ne "$nShellToTest" ]] \
|
||||
|| [[ "''${#debugFlagstrArray[@]}" -ne "$nShellToTest" ]]
|
||||
then
|
||||
echo "error: Lengths of test parameter arrays doesn't match." >&2
|
||||
exit 1
|
||||
fi
|
||||
typePExpect="${root}/bin/root"
|
||||
for ((i=0; i<$nShellToTest; ++i)); do
|
||||
tryCommand="''${sourceCommandArray[$i]} \"${root}/bin/''${sourcefileNameArray[$i]}\""
|
||||
echo "Testing ''${shellNameArray[$i]} $tryCommand"
|
||||
# Home directory for Fish
|
||||
HOME_TEMP="$(mktemp -d temporary_home_XXXXXX)"
|
||||
binPATHGot="$(PATH="''${shellOutpathArray[$i]}/bin" HOME=$HOME_TEMP "''${shellNameArray[$i]}" ''${debugFlagstrArray[$i]} -c "$tryCommand && echo \"\$PATH\"")"
|
||||
rm -r "$HOME_TEMP"
|
||||
typePGot="$(PATH="$binPATHGot" type -p root)"
|
||||
if [[ "$typePGot" != "$typePExpect" ]]; then
|
||||
echo "error: Got PATH \"$binPATHGot\", in which the root executable path is \"$typePGot\". Expect root executable path \"$typePExpect\"." >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
echo "test-thisroot pass!"
|
||||
touch "$out"
|
||||
''
|
Loading…
Reference in New Issue
Block a user