#!/bin/tcsh


#
# Setup
#
if (! -e output) mkdir output
if (! -e diffs) mkdir diffs
/bin/rm -rf output/* diffs/*
if (! -e expected-output) echo "There is no expected-output directory"
if ((! -e smake) || (! -x smake)) echo "There is no executable ./smake"
source aliases.csh
/bin/rm -f *.o f?.txt f??.txt r?.txt r??.txt r? r??


#
# Case 1
#
case no-actions

#
# Case 2
#
case mixed-spacing

#
# Case 3
#
case 1-rule

#
# Case 4
#
/bin/rm -f f1.txt
touch f2.txt
casen 2-rules
ls -s f1.txt | tee -a output/4-2-rules
diff-case 4 2-rules

#
# Case 5
#
casen 2-rules
ls -s f1.txt | tee -a output/5-2-rules
diff-case-v2 5 2-rules

#
# Case 6
#
case self

#
# Case 7
#
case self

#
# Case 8
#
casean self clean
ls -s *.o |& tee -a output/8-self-clean
diff-case 8 self-clean

#
# Case 9
#
casean self print
ls -s *.o |& tee -a output/9-self-print
diff-case 9 self-print

#
# Case 10
#
casean self hash.o
ls -s *.o |& tee -a output/10-self-hash.o
diff-case 10 self-hash.o

#
# Case 11
#
casean self all
ls -s *.o |& tee -a output/11-self-all
diff-case 11 self-all

#
# Case 12
#
touch f4.txt
casen multi-actions
ls -s f*.txt |& tee -a output/12-multi-actions
diff-case 12 multi-actions

#
# Case 13
#
casen multi-actions
ls -s f*.txt |& tee -a output/13-multi-actions
diff-case-v2 13 multi-actions

#
# Case 14
#
/bin/rm -f main.o other.o
casen writeup
ls -s main.o other.o |& tee -a output/14-writeup
diff-case 14 writeup

#
# Case 15
#
/bin/rm -f main.o other.o
case writeup

#
# Case 16
#
casea 4-deep clean

#
# Case 17
#
touch r8.txt r9.txt
case 4-deep

#
# Case 18
#
casen 4-deep
diff-case-v2 18 4-deep

#
# Case 19
#
case empty

#
# Case 20
#
case empty-name

#
# Case 21
#
case malformed-rule

#
# Case 22
#
case no-tab

#
# Case 23
#
case missing-rule

#
# Case 24
#
casee not-found

#
# Case 25
#
casee not-executable

#
# Case 26
#
case unexpected-action

#
# Case 27
#
case-header
timelimit 10 smake 1 2 3 |& tee output/27-smake-1-2-3
diff-case 27 smake-1-2-3
