nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 47 lines 1.4 kB view raw
1# shellcheck shell=bash 2 3set -eu 4 5declare -ag preScriptHooks=(testBuilderExitCode) 6# shellcheck disable=SC2154 7((${#expectedBuilderLogEntries[@]})) && preScriptHooks+=(testBuilderLogEntries) 8 9testBuilderExitCode() { 10 nixLog "checking original builder exit code" 11 local -ir builderExitCode=$(<"${failed:?}/testBuildFailure.exit") 12 # shellcheck disable=SC2154 13 if ((expectedBuilderExitCode == builderExitCode)); then 14 nixLog "original builder exit code matches expected value of $expectedBuilderExitCode" 15 return 0 16 else 17 nixErrorLog "original builder produced exit code $builderExitCode but was expected to produce $expectedBuilderExitCode" 18 return 1 19 fi 20} 21 22testBuilderLogEntries() { 23 nixLog "checking original builder log" 24 local -r builderLogEntries="$(<"${failed:?}/testBuildFailure.log")" 25 local -i shouldExit=0 26 local expectedBuilderLogEntry 27 for expectedBuilderLogEntry in "${expectedBuilderLogEntries[@]}"; do 28 if [[ ${builderLogEntries} == *"$expectedBuilderLogEntry"* ]]; then 29 nixLog "original builder log contains ${expectedBuilderLogEntry@Q}" 30 else 31 nixErrorLog "original builder log does not contain ${expectedBuilderLogEntry@Q}" 32 shouldExit=1 33 fi 34 done 35 return $shouldExit 36} 37 38scriptPhase() { 39 runHook preScript 40 41 runHook script 42 43 runHook postScript 44} 45 46runHook scriptPhase 47touch "${out:?}"