Skip to content

Instantly share code, notes, and snippets.

@scottopell
Last active October 28, 2015 01:36
Show Gist options
  • Save scottopell/28d572dc17bc2c1cba8b to your computer and use it in GitHub Desktop.
Save scottopell/28d572dc17bc2c1cba8b to your computer and use it in GitHub Desktop.
CS352 Project 4 Testing scripts

Test Scripts

Adapted from Austin Schwartz's scripts that he posted on project 2. https://gist.github.com/nawns/3befd88d5bdd39d43e96

These assume you'll be running from the root of the project (ie, alongside src and bin.) Have the tests inside p4tests/output. See the diagram at the bottom for the intended directory structure.

Usage:

./test.sh t1.mj

Or a prettier version with side by side diff (requires sdiff)

./test.sh t1.mj -p

And to test everything at once

./testall

Directory structure expected

.
├── Makefile
├── bin
├──── (truncated)
├── p4tests
│   ├── Expected_Output.pdf
│   ├── Expected_Output.txt
│   ├── List_of_TODO.pdf
│   ├── Or_1.mj
│   ├── output
│   │   ├── t1.mj.out
│   │   ├── t10.mj.out
│   │   ├── t11.mj.out
│   │   ├── t12.mj.out
│   │   ├── t13.mj.out
│   │   ├── t14.mj.out
│   │   ├── t15.mj.out
│   │   ├── t16.mj.out
│   │   ├── t17.mj.out
│   │   ├── t18.mj.out
│   │   ├── t19.mj.out
│   │   ├── t2.mj.out
│   │   ├── t20.mj.out
│   │   ├── t21.mj.out
│   │   ├── t3.mj.out
│   │   ├── t4.mj.out
│   │   ├── t5.mj.out
│   │   ├── t6.mj.out
│   │   ├── t7.mj.out
│   │   ├── t8.mj.out
│   │   └── t9.mj.out
│   ├── output.txt
│   ├── p4output.tar.gz
│   ├── t1.mj
│   ├── t10.mj
│   ├── t11.mj
│   ├── t12.mj
│   ├── t13.mj
│   ├── t14.mj
│   ├── t15.mj
│   ├── t16.mj
│   ├── t17.mj
│   ├── t18.mj
│   ├── t19.mj
│   ├── t2.mj
│   ├── t20.mj
│   ├── t21.mj
│   ├── t3.mj
│   ├── t4.mj
│   ├── t5.mj
│   ├── t6.mj
│   ├── t7.mj
│   ├── t8.mj
│   └── t9.mj
├── src
│   ├── Translate
│   │   ├── Frag.java
│   │   ├── Frame.java
│   │   ├── Temp.java
│   │   └── Tree.java
│   ├── mojo
│   │   ├── Absyn.java
│   │   ├── Error.java
│   │   ├── ProcBody.java
│   │   ├── Scope.java
│   │   └── Translate.java
│   └── x64
│       └── Frame.java
├── test
└── testall
#!/bin/bash
rm -f out
if [ "$2" == "-p" ]
then
#printf "***INPUT***\n\n"
#cat -n "p4tests/$1"
java -classpath "bin:lib" mojo.Translate "p4tests/$1" 2> out >> out
printf "\n***YOUR OUTPUT***\n"
cat out
printf "\n***EXPECTED OUTPUT***\n"
cat p4tests/output/$1.out
printf "\n***DIFF***\n"
sdiff -W p4tests/output/$1.out out
printf "\n"
else
java -classpath "bin:lib" mojo.Translate "p4tests/$1" 2> out >> out
diff -iw out p4tests/output/$1.out
if [ $? -ne 0 ]
then
echo "$1 failed"
cd ..
exit -1
fi
echo "$1 OK"
cd ..
exit 0
fi
#!/bin/bash
totalpassed1=0
for f in `ls p4tests`;
do
if [ -f "p4tests/$f" ]
then
./test $f && totalpassed1=`expr $totalpassed1 "+" 1`
echo "testing $f"
fi
done
echo "Compilers project 4 (Translate)"
echo "**************************"
echo "Basic implementation"
echo "$totalpassed1 / `ls p4tests/output | wc -l` passed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment