Improve test coverage.

This commit is contained in:
Eric S. Raymond 2022-04-07 06:42:20 -04:00
parent 6f7c5743c6
commit 49e2479efa
5 changed files with 38 additions and 5 deletions

View file

@ -861,8 +861,10 @@ static phase_codes_t fly(verb_t verb, obj_t obj)
game.newloc = LOC_CLIFF; game.newloc = LOC_CLIFF;
rspeak(RUG_RETURNS); rspeak(RUG_RETURNS);
} else { } else {
// LCOV_EXCL_START
/* should never happen */ /* should never happen */
rspeak(NOTHING_HAPPENS); rspeak(NOTHING_HAPPENS);
// LCOV_EXCL_STOP
} }
return GO_TERMINATE; return GO_TERMINATE;
} }

View file

@ -107,7 +107,7 @@ int resume(void)
while (fp == NULL) { while (fp == NULL) {
char* name = myreadline("\nFile name: "); char* name = myreadline("\nFile name: ");
// Autocomplete can leave the input with an extra traoling space. // Autocomplete can leave the input with an extra trailing space.
if (name != NULL && strlen(name) > 0 && name[strlen(name) - 1] == ' ') if (name != NULL && strlen(name) > 0 && name[strlen(name) - 1] == ' ')
name[strlen(name) - 1] = '\0'; name[strlen(name) - 1] = '\0';
if (name == NULL) if (name == NULL)

View file

@ -67,6 +67,7 @@ buildregress: savegames
OPTS=`sed -n /#options:/s///p <$${file}.log`; \ OPTS=`sed -n /#options:/s///p <$${file}.log`; \
advent $$OPTS <$${file}.log >$${file}.chk 2>&1 || exit 1; \ advent $$OPTS <$${file}.log >$${file}.chk 2>&1 || exit 1; \
done; \ done; \
echo "inven" | advent isofoo.log /dev/stdin >multifile.chk
rm -f scratch.tmp rm -f scratch.tmp
savecheck: savegames savecheck: savegames
@ -96,17 +97,19 @@ regress:
then diff --text -u $${file}.chk /tmp/regress$$$$ || exit 1; \ then diff --text -u $${file}.chk /tmp/regress$$$$ || exit 1; \
else echo "*** Nonzero return status on $${file}!"; exit 1; fi \ else echo "*** Nonzero return status on $${file}!"; exit 1; fi \
done; \ done; \
$(ECHO) " multifile ## Test multiple file arguments"
@(echo "inven" | advent isofoo.log /dev/stdin | diff --text -u multifile.chk -) || exit 1
rm -f scratch.tmp /tmp/regress$$$$ rm -f scratch.tmp /tmp/regress$$$$
# Steps towards TAP and parallelization. # Steps towards TAP and parallelization.
# There's a blocker in that the log tests can't be run concurrently # There's a blocker in that the log tests can't be run concurrently
# due to isssues with colliding save files. # due to issues with colliding save files.
# The TAP filter. Only affects presentation of the test suite messages # The TAP filter. Only affects presentation of the test suite messages
TAPCONSUMER=tappy TAPCONSUMER=tappy
# Fall back to safety if our declared TAP consumer does not exist. # Fall back to safety if our declared TAP consumer does not exist.
# This is helpful in the CI environment, where it wiuld be better for # This is helpful in the CI environment, where it would be better for
# the logfiles to carry the raw TAP messages. # the logfiles to carry the raw TAP messages.
TAPFILTER=$(shell command -v $(TAPCONSUMER) || echo cat) TAPFILTER=$(shell command -v $(TAPCONSUMER) || echo cat)

27
tests/multifile.chk Normal file
View file

@ -0,0 +1,27 @@
Welcome to Adventure!! Would you like instructions?
> ## Test isolated 'foo' word
> n
> n
You are standing at the end of a road before a small brick building.
Around you is a forest. A small stream flows out of the building and
down a gully.
> foo
> foo
Nothing happens.
> inven
> inven
You're not carrying anything.
You scored 32 out of a possible 430, using 2 turns.
You are obviously a rank amateur. Better luck next time.
To achieve the next higher rating, you need 14 more points.

View file

@ -1,5 +1,6 @@
## Resume, then win ## Resume, then win
# Here to get class threshold of 426 # Here to get class threshold of 426
# Note, savefile name has trailing space
n n
resume resume
y y