-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathregress.sh
More file actions
executable file
·63 lines (58 loc) · 1.87 KB
/
regress.sh
File metadata and controls
executable file
·63 lines (58 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh
# regress.sh is a shell script that runs the given main class
# on all of the inputs (*.in files) in the given input directory.
# Does all this by copying the src/*.java files into TestingTemp/
# and running the tests in TestingTemp/.
#
# usage examples:
# ./regress.sh JavaHelloWorld PublicTestCases
# ./regress.sh Main MyTestCases
#
# It is also possible to run the script on an individual file:
# ./regress.sh JavaHelloWorld PublicTestCases file1.in
#
# The assumption is that each main is operating on standard input.
# The input files in PublicTestCases/ will be redirected into the
# program. Here are the operations regress.sh performs:
#
# javac JavaHelloWorld.java
# java JavaHelloWorld < PublicTestCases/file1.in
# java JavaHelloWorld < PublicTestCases/file2.in
#
# Another assumption is that all of the source files are in the
# default package and are in the src/ subdirectory.
#
# FIXME: will also want to be doing a diff
# Check if we got enough parameters, we need at least 2.
if [ $# -gt 1 ]
then
# naming command-line parameters to script
main=$1
inputdir=$2
# copying over all the source files into TestingTemp/
# and then moving into that directory.
cp src/*.java TestingTemp/
cd TestingTemp/
# compiling the driver and any local files it imports
echo
echo "==== compiling $main"
javac $main.java
if [ $? -ne 0 ]
then
echo "******************************************"
echo "regress.sh ERROR: java compilation failed."
#echo "If works in Eclipse, then please contact CS 210 staff."
exit 1
fi
# if that worked then run it on each file in the given directory
for infile in `ls ../$inputdir/*.in`
do
echo "java $main < $infile"
java $main < $infile
done
# Not enough parameters given to script.
else
echo
echo "usage: ./regress.sh JavaHelloWorld PublicTestCases"
fi
echo