haskell-te: ddefc72620c5ff8d8c4b94fd0f034087845f6b9b
1: { annotated, bash, fail, haskellPackages,jq, lib, ML4HSFE, runCommand, runWeka,
2: testData, unpack, withDeps, wrap }:
3:
4: with builtins;
5: with lib;
6: with rec {
7: clusterScript-untested = wrap {
8: name = "cluster";
9: paths = [ bash ML4HSFE runWeka ];
10: script = ''
11: #!${bash}/bin/bash
12: set -e
13:
14: [[ -n "$WIDTH" ]] || WIDTH=30
15: [[ -n "$HEIGHT" ]] || HEIGHT=30
16: export WIDTH
17: export HEIGHT
18: ml4hsfe-outer-loop
19: '';
20: };
21:
22: test = attr: pkg:
23: with rec {
24: asts = getAttr attr (testData.asts {});
25: clustered = runCommand "cluster"
26: {
27: inherit asts;
28: cmd = clusterScript-untested;
29: }
30: ''
31: "$cmd" < "$asts" > "$out"
32: '';
33:
34: clustersHaveFields = runCommand "clustersHaveFields-for-${pkg.name}"
35: {
36: inherit clustered;
37: buildInputs = [ fail jq ];
38: }
39: ''
40: set -e
41: jq -e 'length | . > 0' < "$clustered" || fail "No clusters"
42:
43: for field in arity name module type package ast features cluster \
44: quickspecable
45: do
46: jq -e "map(has(\"$field\")) | all" < "$clustered"
47: done
48:
49: mkdir "$out"
50: '';
51:
52: featuresConform = runCommand "features-conform-${attr}"
53: {
54: inherit clustered;
55: buildInputs = [ fail jq ];
56: }
57: ''
58: set -e
59:
60: FEATURELENGTHS=$(jq -r '.[] | .features | length' < "$clustered")
61: COUNT=$(echo "$FEATURELENGTHS" | head -n 1)
62: echo "$FEATURELENGTHS" | while read -r LINE
63: do
64: [[ "$LINE" -eq "$COUNT" ]] ||
65: fail "Found '$LINE' features, was expecting '$COUNT'"
66: done
67: mkdir "$out"
68: '';
69:
70: haveAllClusters = runCommand "haveAllClusters-${attr}"
71: {
72: inherit asts;
73: inherit (pkg) name;
74: buildInputs = [ fail jq ];
75: cluster = clusterScript-untested;
76: }
77: ''
78: for CLUSTERS in 1 2 3
79: do
80: export CLUSTERS
81: RESULT=$("$cluster" < "$asts")
82: FOUND=$(echo "$RESULT" | jq '.[] | .cluster')
83: for NUM in $(seq 1 "$CLUSTERS")
84: do
85: echo "$FOUND" | grep "^$NUM$" > /dev/null || fail \
86: "Clustering '$name' into '$CLUSTERS' clusters, '$NUM' was empty"
87: done
88: done
89: mkdir "$out"
90: '';
91: };
92: [ clustersHaveFields featuresConform haveAllClusters ];
93:
94: tests = concatLists (attrValues (mapAttrs test {
95: inherit (testData.haskellDrvs) test-theory;
96: }));
97: };
98:
99: withDeps tests clusterScript-untested
Generated by git2html.