mirror of https://github.com/zachjs/sv2v.git
72 lines
1.8 KiB
Bash
72 lines
1.8 KiB
Bash
|
|
#!/bin/bash
|
||
|
|
|
||
|
|
clearArtifacts() {
|
||
|
|
rm -f one.v two.v
|
||
|
|
}
|
||
|
|
|
||
|
|
createArtifacts() {
|
||
|
|
touch one.v two.v
|
||
|
|
}
|
||
|
|
|
||
|
|
test_prereq() {
|
||
|
|
for file in `ls *.sv`; do
|
||
|
|
assertConverts "$file"
|
||
|
|
done
|
||
|
|
}
|
||
|
|
|
||
|
|
test_default() {
|
||
|
|
runAndCapture *.sv
|
||
|
|
assertTrue "default conversion should succeed" $result
|
||
|
|
assertNotNull "stdout should not be empty" "$stdout"
|
||
|
|
assertNull "stderr should be empty" "$stderr"
|
||
|
|
}
|
||
|
|
|
||
|
|
test_stdout() {
|
||
|
|
runAndCapture --write=stdout *.sv
|
||
|
|
assertTrue "default conversion should succeed" $result
|
||
|
|
assertNotNull "stdout should not be empty" "$stdout"
|
||
|
|
assertNull "stderr should be empty" "$stderr"
|
||
|
|
}
|
||
|
|
|
||
|
|
test_adjacent() {
|
||
|
|
runAndCapture --write=stdout *.sv
|
||
|
|
expected="$stdout"
|
||
|
|
|
||
|
|
runAndCapture --write=adjacent *.sv
|
||
|
|
assertTrue "adjacent conversion should succeed" $result
|
||
|
|
assertNull "stdout should be empty" "$stdout"
|
||
|
|
assertNull "stderr should be empty" "$stderr"
|
||
|
|
|
||
|
|
actual=`cat one.v two.v`
|
||
|
|
assertEquals "adjacent output should match combined" "$expected" "$actual"
|
||
|
|
clearArtifacts
|
||
|
|
}
|
||
|
|
|
||
|
|
test_adjacent_exist() {
|
||
|
|
createArtifacts
|
||
|
|
runAndCapture --write=adjacent *.sv
|
||
|
|
clearArtifacts
|
||
|
|
|
||
|
|
assertFalse "adjacent conversion should fail" $result
|
||
|
|
assertNull "stdout should be empty" "$stdout"
|
||
|
|
assertEquals "stderr should list existing files" \
|
||
|
|
"Refusing to write output because the following files would be overwritten: one.v, two.v" \
|
||
|
|
"$stderr"
|
||
|
|
}
|
||
|
|
|
||
|
|
test_adjacent_extension() {
|
||
|
|
createArtifacts
|
||
|
|
runAndCapture --write=adjacent *.v
|
||
|
|
clearArtifacts
|
||
|
|
|
||
|
|
assertFalse "adjacent conversion should fail" $result
|
||
|
|
assertNull "stdout should be empty" "$stdout"
|
||
|
|
assertEquals "stderr should list existing files" \
|
||
|
|
"Refusing to write adjacent to \"one.v\" because that path does not end in \".sv\"" \
|
||
|
|
"$stderr"
|
||
|
|
}
|
||
|
|
|
||
|
|
source ../lib/functions.sh
|
||
|
|
|
||
|
|
. shunit2
|