From 90eaf9d9ebb427fc51eb59808de37d2e421b8ab1 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 5 Jan 2014 16:44:29 +0100 Subject: [PATCH] tests/info: New; checks info and code agree on commands Replaces info/checklist.pl, which has been broken since commit 56d9445, v4.3.0. Signed-off-by: Markus Armbruster --- Make.mk | 1 + info/checklist.pl | 76 -------------- info/deity.list | 121 --------------------- info/player.list | 187 --------------------------------- tests/info-test | 41 ++++++++ tests/info/cmp-toc-vs-lists.pl | 35 ++++++ 6 files changed, 77 insertions(+), 384 deletions(-) delete mode 100644 info/checklist.pl delete mode 100644 info/deity.list delete mode 100644 info/player.list create mode 100755 tests/info-test create mode 100755 tests/info/cmp-toc-vs-lists.pl diff --git a/Make.mk b/Make.mk index 2fb4bbbbb..33048aea6 100644 --- a/Make.mk +++ b/Make.mk @@ -254,6 +254,7 @@ check: all @echo "Warning: test suite is immature and needs work." >&2 $(srcdir)/tests/files-test $(srcdir) $(srcdir)/tests/fairland-test $(srcdir) + $(srcdir)/tests/info-test $(srcdir) ifeq ($(empthread),LWP) $(srcdir)/tests/smoke-test $(srcdir) $(srcdir)/tests/actofgod-test $(srcdir) diff --git a/info/checklist.pl b/info/checklist.pl deleted file mode 100644 index fc823d76f..000000000 --- a/info/checklist.pl +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/local/bin/perl -# -# checklist.pl -# -# By Ken Stevens -# -# FIXME This does not work at the moment -# -# HOW TO RUN IT: -# In empire, redirect the output of the player "list" command to a file called -# "player.list". Similarly, make a file listing deity commands and call it -# deity.list. Put both these files in this directory, and then run this script -# to check which Empire commands need to be documented. -# - -use strict; -use warnings; - -my ($com, @list, @obsolete, @Commands); - -open(LIST, ") { - last if /^ /; -} - -while() { - last if /^For further info on command syntax see/; - $_ = substr($_, 5); - ($com) = split; - push (@list, $com); -} -close LIST; - -push(@list, "break"); - -open(LIST, ") { - last if /^ /; -} - -while() { - last if /^For further info on command syntax see/; - $_ = substr($_, 5); - ($com) = split; - push (@list, $com); -} -close LIST; - -open(OBSOLETE, ") { - push(@obsolete, $1) if /^.L (\S+)$/; -} - -close OBSOLETE; - -open (LS, "ls Commands|"); - -while () { - chop; - next unless /^(\S+).t/; - push(@Commands, $1); -} -close LS; - -print "In list but not Commands:\n"; -for my $l (@list) { - print " $l\n" unless grep (/^$l$/, @Commands); -} -print "In Commands but not list:\n"; -for my $c (@Commands) { - print " $c\n" unless grep(/^$c$/, @list) || grep(/^$c$/, @obsolete); -} diff --git a/info/deity.list b/info/deity.list deleted file mode 100644 index 082a31617..000000000 --- a/info/deity.list +++ /dev/null @@ -1,121 +0,0 @@ -list >!deity.list - Current EMPIRE Command List - ------- ------ ------- ---- -Initial number is cost in B.T.U. units. -Next 2 chars (if present) are: -$ - must be non-broke c -- must have capital -Args in [brackets] are optional. -All-caps args in have the following meanings: - :: a number in unspecified units - :: a commodity such as `food', `guns', etc - :: a commodity such as `food', `guns', etc - :: an item type such as `ship', `plane', etc - 0 accept [as-COUNTRY] - 0 add - 0 announce {message} - 0 apropos - 0 army - 0 bdes - 0 bestpath - 0 bmap [s|l|p|r|t|*|h] - 1 budget [ ] - 0 bye {log-off} - 0 capital - 0 cargo - 0 census - 0 change - 0 commodity - 0 country - 0 cutoff - 1 deliver [q|] [] - 1 designate [sure?] - 0 disable - 1 distribute - 0 dump [] - 0 echo [] - 0 edit [ ]... - 0 enable - 0 execute - 0 financial - 0 flash [] - 0 fleetadd - 0 force - 1 fortify - 1 fuel [] - 0 give - 0 help - 0 headlines [days] - 0 hidden - 0 info - 0 land - 0 lcargo - 0 ledger - 0 level - 0 list of commands - 0 lbmap [s|l|p|r|t|*|h] - 0 ldump [] - 0 lmap [s|l|p|*|h] - 0 lost - 0 lstat - 0 market [COMM] - 0 map [s|l|p|*|h] - 0 mobupdate - 0 motd - 0 name - 0 nation - 0 ndump - 0 newcap [] - 0 neweff - 0 newspaper [days] - 0 nmap [s|l|p|*|h] - 0 nuke - 0 offset - 1 origin - 0 path - 0 payoff - 0 pbmap [s|l|p|r|t|*|h] - 0 pdump [] - 0 plane - 0 players - 0 pmap [s|l|p|*|h] - 0 power [["new" []] | ["country" ]] - 0 pray - 0 production - 0 pstat - 0 quit - 0 read - 0 realm [] - 0 relations [as-COUNTRY] - 2 reject - 0 report - 0 resource - 1 route - 0 sbmap [s|l|p|r|t|*|h] - 0 sdump [] - 0 sect - 0 setsector - 0 setresource - 0 sharebmap [] - 0 ship - 0 show <"build"|"stats"|"cap"> [] - 0 shutdown [] - 0 sinfrastructure - 0 smap [s|l|p|*|h] - 0 sstat - 0 starvation [|l |s ] - 1 strength - 0 swapsector - 0 telegram - 0 territory [] - 1 threshold - 0 toggle [inform|flash|beep|coastwatch|sonar|techlists] [on|off] - 0 turn <"on"|"off"|"mess"> - 0 update - 0 version - 0 wait - 0 wall [] - 1 wingadd - 1 wipe - 0 wire [yes|no|] - 0 zdone -For further info on command syntax see "info Syntax". diff --git a/info/player.list b/info/player.list deleted file mode 100644 index d199c1932..000000000 --- a/info/player.list +++ /dev/null @@ -1,187 +0,0 @@ -list >!player.list - Current EMPIRE Command List - ------- ------ ------- ---- -Initial number is cost in B.T.U. units. -Next 2 chars (if present) are: -$ - must be non-broke c -- must have capital -Args in [brackets] are optional. -All-caps args in have the following meanings: - :: a number in unspecified units - :: a commodity such as `food', `guns', etc - :: a commodity such as `food', `guns', etc - :: an item type such as `ship', `plane', etc - 0 accept [as-COUNTRY] - 0 announce {message} - 3 $c anti - 0 apropos - 3 $c arm - 0 army - 3 $c assault [ ] - 3 $c attack [ ] - 0 bdes - 0 bestpath - 0 bmap [s|l|p|r|t|*|h] - 3 $c board [|] - 2 $c bomb - 1 budget [ ] - 1 $c build [ ] - 1 $c buy - 0 bye {log-off} - 0 capital - 0 cargo - 0 census - 0 change - 1 c coastwatch - 2 $c collect - 0 commodity - 1 c consider - 2 $c convert [sure?] - 0 country - 0 cutoff - 2 c declare - 1 deliver [q|] [] - 1 c demobilize [sure?] - 1 designate [sure?] - 2 $c disarm - 1 distribute - 1 $c drop - 0 dump [] - 0 echo [] - 2 $c enlist - 0 execute - 1 $c explore - 0 financial - 1 $c fire [TO-SECT | SHIP] - 0 flash [] - 0 fleetadd - 2 $c fly - 1 c follow - 1 fortify - 1 fuel [] - 1 $c grind - 2 $c harden - 0 help - 0 headlines [days] - 1 $c improve - 0 info - 0 land - 3 $c launch - 3 $c lboard [] - 0 lcargo - 0 ledger - 0 level - 0 list of commands - 0 lbmap [s|l|p|r|t|*|h] - 0 ldump [] - 1 c lload - 1 c llookout - 0 lmap [s|l|p|*|h] - 2 $c lmine - 1 c load - 1 c lookout - 0 lost - 1 c lradar - 1 c lrange - 1 c lretreat [i|h|b|c] - 0 lstat - 1 c ltend - 1 c lunload - 0 market [COMM] - 0 map [s|l|p|*|h] - 1 c march - 2 $c mine - 2 c mission [] - 1 c morale - 0 motd - 1 c move - 2 c mquota - 0 name - 0 nation - 1 c navigate - 0 ndump - 0 neweff - 0 newspaper [days] - 0 nmap [s|l|p|*|h] - 0 nuke - 1 $c offer [ ] - 1 c order - 1 origin - 3 $c paradrop - 0 path - 0 payoff - 0 pbmap [s|l|p|r|t|*|h] - 3 $c pboard - 0 pdump [] - 0 plane - 0 players - 0 pmap [s|l|p|*|h] - 0 power [["new" []] | ["country" ]] - 0 pray - 0 production - 0 pstat - 0 c qorder - 0 quit - 1 c radar - 1 c range - 0 read - 0 realm [] - 3 $c recon - 1 c retreat [i|t|s|h|b|d|u|c] - 0 relations [as-COUNTRY] - 2 reject - 1 $c repay - 0 report - 1 c reset <0|price> - 0 resource - 1 route - 1 $c sabotage - 1 c sail - 1 $c satellite [ [?cond&cond&...]] - 0 sbmap [s|l|p|r|t|*|h] - 2 $c scrap - 5 c scuttle - 0 sdump [] - 0 sect - 1 c sell - 1 c set -25 $c shark - 0 sharebmap [] - 0 ship - 3 $c shoot - 0 show <"build"|"stats"|"cap"> [] - 0 sinfrastructure - 1 c skywatch - 0 smap [s|l|p|*|h] - 1 c sonar - 0 c sorder - 1 c spy - 0 sstat - 1 c start - 0 starvation [|l |s ] - 1 c stop - 1 strength - 1 c supply - 0 c survey - 3 $c sweep - 0 telegram - 1 c tend - 0 territory [] - 1 c test - 1 threshold - 0 toggle [inform|flash|beep|coastwatch|sonar|techlists] [on|off] - 3 $c torpedo - 1 $c trade - 1 c transport <"nuke"|"plane"> [ ] - 0 $c treaty - 1 c unload - 1 c unsail - 0 update - 1 $c upgrade - 0 version - 0 wall [] - 1 wingadd - 1 wipe - 0 wire [yes|no|] - 1 $c work - 0 zdone -For further info on command syntax see "info Syntax". diff --git a/tests/info-test b/tests/info-test new file mode 100755 index 000000000..5fa1776e1 --- /dev/null +++ b/tests/info-test @@ -0,0 +1,41 @@ +#!/bin/sh -e +# Documentation completeness test for Empire + +if [ $# -ne 1 ] +then echo "Usage: $0 SRCDIR" >&2; exit 1 +fi + +srcdir="$1" + +. "$srcdir"/tests/test-common.sh + +create_sandbox + +begin_test <sandbox/deity.list +EOF +feed_input 1 1 <sandbox/sanctuary.list +break +list >sandbox/active.list +EOF +feed_input visitor visitor <sandbox/visitor.list +EOF + +end_test + +if perl $srcdir/tests/info/cmp-toc-vs-lists.pl info/toc sandbox/*.list +then echo "Command documentation OK" +else echo "Command documentation FAIL"; false +fi diff --git a/tests/info/cmp-toc-vs-lists.pl b/tests/info/cmp-toc-vs-lists.pl new file mode 100755 index 000000000..e138dfd3b --- /dev/null +++ b/tests/info/cmp-toc-vs-lists.pl @@ -0,0 +1,35 @@ +#!/usr/bin/perl + +use warnings; +use strict; + +my $toc = shift @ARGV; +my %cmd; +my $status = 0; + +open TOC, "<$toc" + or die "Can't open $toc for reading: $!"; +while () { + my ($chap, $top) = split; + $cmd{$top} = undef if $chap eq 'Command'; +} +close TOC; + +while (<>) { + next unless (/^[ 0-9][0-9] [$ ][c ] (\S+)/); + gripe("$1 lacks an info page\n") + unless exists $cmd{$1}; + $cmd{$1} = 1; +} + +for (keys %cmd) { + gripe("$_ is not in any command list\n") + unless defined $cmd{$_} +} + +sub gripe { + print STDERR @_; + $status = 1; +} + +exit $status; -- 2.43.0