change test generation

This commit is contained in:
Thomas Levine 2016-02-28 19:01:59 +00:00
parent fa402bd42d
commit 87d5aec23c
4 changed files with 24 additions and 28 deletions

View 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'"
}

View File

@ -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

View File

@ -0,0 +1 @@
rm -R "$tmp"

View File

@ -1,4 +0,0 @@
rm -R "$tmp"
if ls | grep '^[0-9]' > /dev/null; then
rm [0-9]*
fi