haskell-te: 112d0557bb3010ef98134a0a65dff227275a7321
1: { analysis, bash, fail, jq, wrap }:
2:
3: { REP, SIZE, sampleFile ? null, SAMPLED_NAMES ? null}:
4:
5: with builtins;
6: with {
7: errMsg = ''
8: FOUND:
9: $FOUND
10: END FOUND
11: SAMPLED_NAMES:
12: $SAMPLED_NAMES
13: END SAMPLED_NAMES
14: '';
15:
16: err = error: abort (toJSON { inherit error sampleFile SAMPLED_NAMES; });
17: };
18:
19: assert sampleFile == null -> SAMPLED_NAMES != null ||
20: err "sampleAnalyser needs either sampleFile xor SAMPLED_NAMES";
21:
22: assert sampleFile != null -> SAMPLED_NAMES == null ||
23: err "sampleAnalyser can't use sampleFIle AND SAMPLED_NAMES";
24:
25: assert SAMPLED_NAMES != null -> isString SAMPLED_NAMES ||
26: err "SAMPLED_NAMES should be a newline-delimited string";
27:
28: wrap {
29: name = "sampleAnalyser-${toString SIZE}-${toString REP}";
30: paths = [ analysis bash fail jq ];
31: vars = if sampleFile == null
32: then { inherit SAMPLED_NAMES; }
33: else { inherit sampleFile; };
34: script = ''
35: #!${bash}/bin/bash
36: set -e
37: set -o pipefail
38:
39: [[ -n "$SAMPLED_NAMES" ]] || SAMPLED_NAMES=$(cat "$sampleFile")
40: export SAMPLED_NAMES
41:
42: FOUND=$(cat)
43:
44: # conjectures_for_sample expects encoded sample but decoded eqs
45: RESULT=$(echo "$FOUND" | decode | conjectures_for_sample) ||
46: fail "${errMsg}"
47:
48: echo "$RESULT" | jq --slurpfile f <(echo "$FOUND") '. + {"found": $f}'
49: '';
50: }
Generated by git2html.