haskell-te: 4790258f914f27c7109a9837d29c8b8b60f0f8a4
1: { analysis, annotated, bash, fail, genQuickspecRunner, glibcLocales,
2: jq, lib, makeHaskellPkgNixable, mkBin, runCommand, testData, unpack,
3: withDeps, withNix }:
4:
5: with lib;
6: with rec {
7: quickspecAsts = mkBin {
8: name = "quickspecAsts";
9: paths = [ bash genQuickspecRunner jq makeHaskellPkgNixable ];
10: vars = {
11: LANG = "en_US.UTF-8";
12: LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive";
13: NIX_EVAL_HASKELL_PKGS = builtins.toString ./quickspecEnv.nix;
14: };
15: script = ''
16: #!${bash}/bin/bash
17: set -e
18: set -o pipefail
19:
20: function mkNixable {
21: for P in "$@"
22: do
23: makeHaskellPkgNixable "$P" | jq -R '.'
24: done
25: }
26:
27: OUT_DIRS=$(mkNixable "$@" | jq -s '.')
28: export OUT_DIRS
29:
30: S=$(genQuickspecRunner)
31:
32: [[ -e "$S" ]] || fail "Runner '$S' doesn't exist"
33: "$S"
34: '';
35: };
36:
37: testGarbage = runCommand "check-garbage"
38: {
39: buildInputs = [ fail quickspecAsts ];
40: }
41: ''
42: if echo '!"£$%^&*()' | quickspecAsts 1> /dev/null 2> garbage.err
43: then
44: cat garbage.err 1>&2
45: fail "Shouldn't have accepted garbage"
46: fi
47: echo pass > "$out"
48: '';
49:
50: eqss = testData.eqs { script = quickspecAsts; };
51:
52: testAsts = mapAttrs
53: (n: eqs: runCommand "test-quickspecasts-${n}"
54: {
55: inherit eqs n;
56: buildInputs = [ fail jq ];
57: }
58: ''
59: set -e
60: RESULTS=$(jq 'length' < "$eqs") ||
61: fail "Couldn't get equation array for $n"
62:
63: [[ "$RESULTS" -gt 0 ]] || fail "No equations for $n: $eqs"
64: mkdir "$out"
65: '')
66: eqss;
67:
68: moreTests = attr: eqs:
69: with rec {
70: pkg = getAttr attr testData.haskellDrvs;
71: name = pkg.name;
72: haveEqs = runCommand "haveEquations-${name}"
73: {
74: inherit eqs;
75: buildInputs = [ jq ];
76: }
77: ''
78: set -e
79: jq -e 'type == "array"' < "$eqs"
80: jq -e 'map(has("relation")) | all' < "$eqs"
81: mkdir "$out"
82: '';
83:
84: foundEqs = runCommand "${name}-eqs-found"
85: {
86: inherit eqs;
87: buildInputs = [ jq ];
88: }
89: ''
90: set -e
91: jq -e 'length | . > 0' < "$eqs"
92: mkdir "$out"
93: '';
94: };
95: [ foundEqs haveEqs ];
96:
97: checkParamTypes = runCommand "can-find-properties-of-parameterised-types"
98: {
99: buildInputs = [ analysis fail jq ];
100: eqs = eqss.test-theory;
101: GROUND_TRUTH = testData.truth.test-theory;
102: TRUTH_SOURCE = testData.truth.test-theory;
103: }
104: ''
105: set -e
106: set -o pipefail
107: RESULT=$(precision_recall_eqs < "$eqs")
108: RECALL=$(echo "$RESULT" | jq '.recall') || fail "No recall"
109: echo "$RECALL" | jq -e '. > 0' || fail "Recall is '$RECALL'"
110: mkdir "$out"
111: '';
112:
113: checks = attrValues testAsts ++
114: attrValues (mapAttrs moreTests eqss) ++
115: [ checkParamTypes testGarbage ];
116: };
117:
118: withDeps checks quickspecAsts
Generated by git2html.