test suite: use md5 of input as test name
in order to keep same name, if order of test would change
This commit is contained in:
parent
38666a86f8
commit
1221a003ba
1 changed files with 20 additions and 8 deletions
|
@ -7,14 +7,16 @@ $0 ~ "^`{3,}$" {
|
||||||
l=length($0)
|
l=length($0)
|
||||||
if (fence == 0) { # enter fence
|
if (fence == 0) { # enter fence
|
||||||
print "#[test]"
|
print "#[test]"
|
||||||
printf "fn test%02d() {\n", count
|
|
||||||
printf " let src = r##\""
|
|
||||||
fence=l
|
fence=l
|
||||||
count+=1
|
|
||||||
} else if (fence == l) { # exit fence
|
} else if (fence == l) { # exit fence
|
||||||
if (ignore) {
|
if (ignore) {
|
||||||
ignore=0
|
ignore=0
|
||||||
} else {
|
} else {
|
||||||
|
printf " let expected = r##\""
|
||||||
|
close("src")
|
||||||
|
while (getline l < "src") print l
|
||||||
|
close("src")
|
||||||
|
system("rm -f src")
|
||||||
print "\"##;"
|
print "\"##;"
|
||||||
print " suite_test!(src, expected);"
|
print " suite_test!(src, expected);"
|
||||||
print "}"
|
print "}"
|
||||||
|
@ -22,7 +24,7 @@ $0 ~ "^`{3,}$" {
|
||||||
}
|
}
|
||||||
fence=0
|
fence=0
|
||||||
} else {
|
} else {
|
||||||
print $0 # md/html
|
print $0 > "src" # md/html
|
||||||
}
|
}
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
@ -34,14 +36,24 @@ fence == 0 && $0 ~ "^`{3,} .*$" {
|
||||||
}
|
}
|
||||||
|
|
||||||
$0 ~ "^\\.$" && !ignore { # enter html
|
$0 ~ "^\\.$" && !ignore { # enter html
|
||||||
|
close("src")
|
||||||
|
cmd="cat src | md5sum | cut -c-7"
|
||||||
|
cmd | getline hash
|
||||||
|
close(cmd)
|
||||||
|
printf "fn test_%s() {\n", hash
|
||||||
|
printf " let src = r##\""
|
||||||
|
while (getline l < "src") print l
|
||||||
|
close("src")
|
||||||
|
system("rm -f src")
|
||||||
print "\"##;"
|
print "\"##;"
|
||||||
printf " let expected = r##\""
|
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
|
||||||
!ignore {
|
!ignore {
|
||||||
if (fence==0 && $0 != "") { # comment
|
if (fence) {
|
||||||
printf "// "
|
# write to file so content can be piped to md5sum (without having to shell escape)
|
||||||
|
print $0 > "src" # md/html
|
||||||
|
} else if ($0 != "") {
|
||||||
|
printf "// %s\n", $0 # comment
|
||||||
}
|
}
|
||||||
print $0 # comment/md/html
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue