-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.sh
75 lines (62 loc) · 1.38 KB
/
tests.sh
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
64
65
66
67
68
69
70
71
72
#!/bin/bash
# INSTRUCTIONS -
# A small script to automaticall run tests
# Extremly specific, so probably not usable for other courses
# Enter HW number, Question number, and the amount of tests and off you go
#
# Run in bash, follow the instructions
# OR
# enter -w -q -r flags through commandline
#
# Default (and only, because lazy) accepted dir structure
#
# Store binarys in: ./HW#/bin/
# Store tests in: ./HW#/tests
#
# test input name: hw#q#in#.txt
# test output name: hw#q#out#.txt
#
# # := Homework/Question/Test number (in & out # must match)
#
# Example:
#
# ./tests.sh
# /HW#
# /bin
# hw2q1.exe
# /tests
# hw2q1in1.txt
# hw2q1out1.txt
hw=''
question=''
range=''
while true
do
while getopts w:q:r: flag
do
case "${flag}" in
w) hw=${OPTARG} ;;
q) question=${OPTARG} ;;
r) range=${OPTARG} ;;
esac
done
if [ -z ${hw} ]; then
echo HW number:
read hw
fi
if [ -z ${question} ]; then
echo Question number:
read question
fi
if [ -z ${range} ]; then
echo Test amount:
read range
fi
for i in $(seq 1 $range)
do echo "------------------------------->";echo "Doing HW${hw}Q${question} - test $i"; HW${hw}/bin/hw${hw}q${question}.exe < HW${hw}/tests/hw${hw}q${question}in$i.txt | diff --strip-trailing-cr --ignore-trailing-space HW${hw}/tests/hw${hw}q${question}out$i.txt -
done
unset range
unset question
unset hw
echo done
done