-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontractiles-a2ml-test.sh
More file actions
executable file
·55 lines (44 loc) · 1.7 KB
/
contractiles-a2ml-test.sh
File metadata and controls
executable file
·55 lines (44 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
set -euo pipefail
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
tool="$root/scripts/contractiles-a2ml-tool.js"
fixtures="$root/tests/contractiles/fixtures"
expected="$root/tests/contractiles/expected"
runtool() { deno run --quiet --allow-read --allow-write "$tool" "$@"; }
runtool validate \
"$fixtures/Mustfile.a2ml" \
"$fixtures/Trustfile.a2ml" \
"$fixtures/Dustfile.a2ml" \
"$fixtures/Intentfile.a2ml"
runtool emit "$fixtures/Mustfile.a2ml" "$expected/mustfile.json.tmp"
runtool emit "$fixtures/Trustfile.a2ml" "$expected/trustfile.json.tmp"
runtool emit "$fixtures/Dustfile.a2ml" "$expected/dustfile.json.tmp"
runtool emit "$fixtures/Intentfile.a2ml" "$expected/intentfile.json.tmp"
diff -u "$expected/mustfile.json" "$expected/mustfile.json.tmp"
diff -u "$expected/trustfile.json" "$expected/trustfile.json.tmp"
diff -u "$expected/dustfile.json" "$expected/dustfile.json.tmp"
diff -u "$expected/intentfile.json" "$expected/intentfile.json.tmp"
expect_fail() {
local file="$1"
if runtool validate "$file"; then
echo "Expected validation failure: $file" >&2
exit 1
fi
}
expect_fail_type() {
local file="$1"
local type="$2"
if runtool validate --type "$type" "$file"; then
echo "Expected validation failure: $file ($type)" >&2
exit 1
fi
}
expect_fail_type "$fixtures/invalid-mustfile.a2ml" mustfile
expect_fail_type "$fixtures/invalid-trustfile.a2ml" trustfile
expect_fail_type "$fixtures/invalid-dustfile.a2ml" dustfile
expect_fail_type "$fixtures/invalid-intentfile.a2ml" intentfile
rm -f "$expected/mustfile.json.tmp" \
"$expected/trustfile.json.tmp" \
"$expected/dustfile.json.tmp" \
"$expected/intentfile.json.tmp"
echo "Contractiles A2ML v1 tests: OK"