From d9d462108caaa581d11b93699412160dda944128 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 20 Feb 2012 13:05:14 -0500 Subject: [PATCH] Add the beginnings of a regression-test suite. --- test/Makefile | 31 +++++++++++++++++++++ test/README | 13 +++++++++ test/test1.chk | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++ test/test1.log | 16 +++++++++++ 4 files changed, 135 insertions(+) create mode 100644 test/Makefile create mode 100644 test/README create mode 100644 test/test1.chk create mode 100644 test/test1.log diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..d77b4e0 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,31 @@ +# Test-suite makefile for sst + +all: regress + @echo "No diff output is good news." + +.SUFFIXES: .log .chk + +.log.chk: + ../sst.py -r $< >$@ 2>&1 + +TESTLOADS := $(shell ls *.log | sed '/.log/s///') +buildregress: + @for test in $(TESTLOADS); do \ + if [ ! -f $${test}.tst ] ; \ + then \ + echo "Remaking $${test}.chk"; \ + rm -f $${test}.chk && ../sst.py -r $${test}.log >$${test}.chk 2>&1; \ + fi \ + done +regress: + @for test in $(TESTLOADS); \ + do \ + if [ ! -f $${test}.tst ] ; \ + then \ + (if echo "Testing $${test}" >&2; \ + ../sst.py -r $${test}.log >/tmp/regress 2>&1; \ + then diff -u $${test}.chk /tmp/regress; \ + else echo "*** Nonzero return status on $${test}!"; exit 1; fi;) \ + fi \ + done + @rm -f /tmp/regress diff --git a/test/README b/test/README new file mode 100644 index 0000000..57c32e7 --- /dev/null +++ b/test/README @@ -0,0 +1,13 @@ +This directory contains regression test pairs for SST. + +A regression test log is just a command capture from a game with a QUIT +appended to tell it to exit. The corresponding check file is just the +output stimulated by the log. All files with extension ".log" in this +directory will be treated as test logs, with each corresponding checkfile +having extension ".chk". + +"make regress" checks that the output of the logfiles is stable. It +will show context diffs when the actual output is different from the +checkfile. + +"make buildregress" rebuilds all check files from their logs. diff --git a/test/test1.chk b/test/test1.chk new file mode 100644 index 0000000..26e045c --- /dev/null +++ b/test/test1.chk @@ -0,0 +1,75 @@ +sst2k: seed set to 1329758601 + + +-SUPER- STAR TREK + +Would you like a regular, tournament, or saved game? # recorded by esr@snark on Mon Feb 20 12:23:21 2012 +r +Would you like a Short, Medium, or Long game? s +Are you a Novice, Fair, Good, Expert, or Emeritus player? n +Choose your game style (plain, almy, fancy or just press enter): + + +It is stardate 3054. The Federation is being attacked by +a deadly Klingon invasion force. As captain of the United +Starship U.S.S. Enterprise, it is your mission to seek out +and destroy this invasion force of 3 battle cruisers. +You have an initial allotment of 7 stardates to complete +your mission. As you proceed you may be given more time. + +You will have 5 supporting starbases. +Starbase locations- 1 - 7 3 - 8 3 - 1 5 - 8 2 - 2 + +The Enterprise is currently in Quadrant 6 - 7 Sector 8 - 8 + +Good Luck! +COMMAND> +COMMAND> m 8 +(Manual movement assumed.) + +Beg your pardon, Captain? +COMMAND> move 8 7 3 2 +(Manual movement assumed.) + +Helmsman Sulu- "Aye, Sir." + +YOU HAVE ATTEMPTED TO CROSS THE NEGATIVE ENERGY BARRIER +AT THE EDGE OF THE GALAXY. THE THIRD TIME YOU TRY THIS, +YOU WILL BE DESTROYED. + +[ANNOUNCEMENT ARRIVING...] + +***Enterprise caught in long range tractor beam-- +Enterprise is pulled to Quadrant 4 - 4, Sector 9 - 8 +Shields raised. + +32 unit hit on the Enterprise from Klingon at Sector 4 - 10 + +21 unit hit on the Enterprise from Klingon at Sector 1 - 5 + + +Energy left 4090 shields up 71%, torpedoes left 10 +COMMAND> torp +10 torpedoes left. +Number of torpedoes to fire- 3 +Target sector for torpedo number 1- 1 5 +Target sector for torpedo number 2- 4 10 +Target sector for torpedo number 3- 7 9 + +Track for torpedo number 1- 8 - 8 7 - 7 6 - 7 +5 - 6 4 - 6 3 - 6 2 - 5 1 - 5 +***Klingon at Sector 1 - 5 destroyed. + +Track for torpedo number 2- 8 - 8 7 - 9 +***Commander at Sector 7 - 9 damaged-- displaced by blast to Sector 8 - 9 + +Track for torpedo number 3- 8 - 9 +***Commander at Sector 8 - 9 destroyed. + +34 unit hit on the Enterprise from Klingon at Sector 4 - 10 + + +Energy left 4056 shields up 68%, torpedoes left 7 +COMMAND> QUIT + +May the Great Bird of the Galaxy roost upon your home planet. diff --git a/test/test1.log b/test/test1.log new file mode 100644 index 0000000..7d65349 --- /dev/null +++ b/test/test1.log @@ -0,0 +1,16 @@ +# seed 1329758601 +# options +# recorded by esr@snark on Mon Feb 20 12:23:21 2012 +r +s +n + + +m 8 +move 8 7 3 2 +torp +3 +1 5 +4 10 +7 9 +QUIT -- 2.31.1