-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_json_test_suit.awk
executable file
·56 lines (52 loc) · 1.38 KB
/
run_json_test_suit.awk
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
56
#!/usr/bin/awk -f
BEGIN {
if (!(WHAT = ENVIRON["WHAT"])) {
if(!(AWK = ENVIRON["AWK"])||"awk"==AWK) {
print "must set AWK"
exit 1
}
}
FOLDER1 = "./soft/JSONTestSuite/test_parsing/"
FOLDER2 = "./soft/JSONTestSuite/test_transform/"
Successes = Fails = 0
run()
}
function run() {
testFolder(FOLDER1)
testFolder(FOLDER2,"y")
print "Successes: " Successes
print "Fails: " Fails
}
function testFolder(folder, firstLetter, cmd,f) {
cmd = "ls -1 " folder " | LC_COLLATE='C' sort"
while (cmd | getline f) {
testFile(folder, f, firstLetter)
}
close(cmd)
}
function testFile(folder, f, firstLetter, cmd,res) {
if ("n_structure_open_array_object.json" == f ||
"n_structure_100000_opening_arrays.json" == f) {
# cause segfault
return
}
# print FOLDER f
if (!firstLetter)
firstLetter = substr(f,1,1)
if ("jq" == WHAT)
cmd = "cat " folder f " | jq ."
else if ("jsqry" == WHAT)
cmd = "cat " folder f " | jsqry"
else
cmd = AWK " -f gron.awk " folder f
# print cmd
cmd = cmd " >/dev/null 2>&1"
# cmd = cmd " >/dev/null"
res = system(cmd)
printf "%8s : %s\n", (res = analyzeResult(firstLetter, res)) ? "SUCCESS" : "FAIL", f
res ? Successes++ : Fails++
close(cmd)
}
function analyzeResult(firstLetter, res) {
return res == 0 && ("y" == firstLetter || "i" == firstLetter) || res != 0 && firstLetter == "n"
}