nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 37 lines 927 B view raw
1{ lib, runCommand }: 2 3rec { 4 runTest = 5 name: body: 6 runCommand name { strictDeps = true; } '' 7 set -o errexit 8 ${body} 9 touch $out 10 ''; 11 12 skip = 13 cond: text: 14 if cond then 15 '' 16 echo "Skipping test $name" > /dev/stderr 17 '' 18 else 19 text; 20 21 fail = text: '' 22 echo "FAIL: $name: ${text}" > /dev/stderr 23 exit 1 24 ''; 25 26 expectSomeLineContainingYInFileXToMentionZ = file: filter: expected: '' 27 file=${lib.escapeShellArg file} filter=${lib.escapeShellArg filter} expected=${lib.escapeShellArg expected} 28 29 if ! grep --text --quiet "$filter" "$file"; then 30 ${fail "The file $file should include a line containing $filter."} 31 fi 32 33 if ! grep --text "$filter" "$file" | grep --text --quiet "$expected"; then 34 ${fail "The file $file should include a line containing $filter that also contains $expected."} 35 fi 36 ''; 37}