change test generation
This commit is contained in:
parent
fa402bd42d
commit
87d5aec23c
23
tests/Single-file test suites/setup
Normal file
23
tests/Single-file test suites/setup
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
tmp=$(mktemp -d)
|
||||||
|
testdir=$tmp/tests
|
||||||
|
touch "$testdir/.urchin"
|
||||||
|
testcase=$testdir/testcase
|
||||||
|
|
||||||
|
test_testsuite() {
|
||||||
|
contents="$1"
|
||||||
|
expectation="$2"
|
||||||
|
|
||||||
|
# Set up the test suite.
|
||||||
|
echo "$contents" > "$testcase"
|
||||||
|
|
||||||
|
chmod +x $testcase
|
||||||
|
case "$expectation" in ok) regex='^ok 1 - testcase';;
|
||||||
|
not\ ok) regex='^not ok 1 - testcase';;
|
||||||
|
skip) regex='^ok 1 - testcase # SKIP';;
|
||||||
|
*) chmod -x $testcase;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Run the test suite
|
||||||
|
echo "#!/bin/sh
|
||||||
|
../../urchin -n -t '$testdir' | grep '$regex'"
|
||||||
|
}
|
@ -1,24 +0,0 @@
|
|||||||
n=0
|
|
||||||
tmp=$(mktemp -d)
|
|
||||||
testdir=$tmp/tests
|
|
||||||
while read line; do
|
|
||||||
n=$(($n + 1))
|
|
||||||
|
|
||||||
contents=$(echo "$line" | cut -d, -f1)
|
|
||||||
expectation=$(echo "$line" | cut -d, -f2)
|
|
||||||
|
|
||||||
# Set up the test suite.
|
|
||||||
mkdir -p "$testdir/$n"
|
|
||||||
touch "$testdir/$n/.urchin"
|
|
||||||
echo "$contents" > "$testdir/$n/testcase"
|
|
||||||
|
|
||||||
# Write the test that runs on the test suite
|
|
||||||
echo "#!/bin/sh
|
|
||||||
../../urchin -t '$testdir/$n' | grep '$expectation'" > $n
|
|
||||||
|
|
||||||
# Skip if invalid.
|
|
||||||
if test "$expectation" = ok || test "$expectation" = not\ ok ||
|
|
||||||
test "$expectation" = skip; then
|
|
||||||
chmod +x $n
|
|
||||||
fi
|
|
||||||
done < .fixtures.csv
|
|
1
tests/Single-file test suites/teardown
Normal file
1
tests/Single-file test suites/teardown
Normal file
@ -0,0 +1 @@
|
|||||||
|
rm -R "$tmp"
|
@ -1,4 +0,0 @@
|
|||||||
rm -R "$tmp"
|
|
||||||
if ls | grep '^[0-9]' > /dev/null; then
|
|
||||||
rm [0-9]*
|
|
||||||
fi
|
|
Loading…
Reference in New Issue
Block a user