[inform]automated testing

5 views
Skip to first unread message

JL

unread,
Nov 17, 2002, 11:51:23 AM11/17/02
to
Hello,

Is it possible to obtain the transcript of a replay in batch mode and then
use a comparison tool like diff to test many replays automatically with only
one batch file ?

I use Windows 9x and I don't know which interpreter would permit this.
If nothing with Windows, then Linux Frotz version, maybe ? (I don't have
Linux installed yet)

Thanks

-- JL
http://jlpo.free.fr


JL

unread,
Nov 17, 2002, 12:51:16 PM11/17/02
to
(sorry if you see this post for the second time but the first post didn't
seem to succeed)

Cedric Knight

unread,
Nov 17, 2002, 5:37:42 PM11/17/02
to
> Is it possible to obtain the transcript of a replay in batch mode and
then
> use a comparison tool like diff to test many replays automatically
with only
> one batch file ?
>
> I use Windows 9x
I sympathise.

It's messy, but if I understand what you want to do, maybe you could
pipe into JZIP. Have one or more recording files, called something like
mygame.rec, that look like

--
script
mygame.output
y

version
look
go north
kill troll
...

script off
q
y
--

Then a .BAT file including the lines
\(jzippath)\JZIP mygame.z5 <mygame.rec

REM and as appropriate:
\(jzippath)\JZIP mygame.z5 <mygame_alternative.rec
\(jzippath)\JZIP mygame_stable.z5 <mygame_reference.rec

REM and to diff
fc mygame.output mygame_stable_reference.output > diff_file.txt
notepad diff_file.txt

If you have masses of different game files or recordings to compare, you
could use MS-DOS batch loops and file concatenation.

HTH
CK

JL

unread,
Nov 17, 2002, 7:42:53 PM11/17/02
to
> It's messy, but if I understand what you want to do, maybe you could
> pipe into JZIP. Have one or more recording files, called something like
> mygame.rec, that look like

Thanks, it's exactly what I intend to do.
The redirection into frotz or winfrotz didn't work, so I hope it will work
with JZIP.

>
> --
> script
> mygame.output
> y
>
> version
> look
> go north
> kill troll
> ...
>
> script off
> q
> y
> --
>
> Then a .BAT file including the lines
> \(jzippath)\JZIP mygame.z5 <mygame.rec
>
> REM and as appropriate:
> \(jzippath)\JZIP mygame.z5 <mygame_alternative.rec
> \(jzippath)\JZIP mygame_stable.z5 <mygame_reference.rec
>
> REM and to diff
> fc mygame.output mygame_stable_reference.output > diff_file.txt
> notepad diff_file.txt

I didn't remember "fc" (thanks again)

JL

unread,
Nov 17, 2002, 8:06:09 PM11/17/02
to
> Thanks, it's exactly what I intend to do.
> The redirection into frotz or winfrotz didn't work, so I hope it will work
> with JZIP.
The redirection works with JZIP !
And JZexe (making stand-alone Infocom-format games) is interesting too.

-- JL


L. Ross Raszewski

unread,
Nov 18, 2002, 1:38:04 AM11/18/02
to

And a horrible idea.
Please please please do not do this.

Lucian P. Smith

unread,
Nov 18, 2002, 9:44:38 AM11/18/02
to
JL <TR...@de.spam> wrote in <3dd7ca6b$0$2154$626a...@news.free.fr>:
: Hello,

: Is it possible to obtain the transcript of a replay in batch mode and then
: use a comparison tool like diff to test many replays automatically with only
: one batch file ?

You can also use the beta-testing verbs >RECORD and >REPLAY.

Turn on scripting as the first command in >RECORD and off you go.

-Lucian

Alex Watson

unread,
Nov 19, 2002, 1:38:34 PM11/19/02
to
JL spake thusly:

> > It's messy, but if I understand what you want to do, maybe you could
> > pipe into JZIP. Have one or more recording files, called something like
> > mygame.rec, that look like
>
> Thanks, it's exactly what I intend to do.
> The redirection into frotz or winfrotz didn't work, so I hope it will work
> with JZIP.

The reason piping doesn't work with (DOS) Frotz is that it doesn't take
input from stdin, but from the keyboard. Unix Frotz (and cygwin-compiled
editions thereof) does accept it.

Don Quixote

unread,
Nov 19, 2002, 4:37:58 PM11/19/02
to
"JL" <TR...@DE.SPAM> wrote in news:3dd7ca6b$0$2154$626a...@news.free.fr:

> I use Windows 9x and I don't know which interpreter would permit this.
> If nothing with Windows, then Linux Frotz version, maybe ? (I don't
> have Linux installed yet)

You can use vbscript to access the Windows Scripting Host (WSH) to type
directly into any window. Here's how:

======================

CommandFile = "C:\path\to\cmdfile.txt"
WinFrotz = """C:\path\to\winfrotz"""
GameFile = """C:\path\to\gamefile.z5"""
WaitSeconds = 5

Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
Set TextStream = FileSystemObject.OpenTextFile(CommandFile,1)

set MyShell = WScript.CreateObject("Wscript.Shell")
UselessVariable = MyShell.Run(WinFrotz & " " & GameFile)
MyShell.AppActivate "WinFrotz"
Wscript.Sleep WaitSeconds * 1000
Do While Not TextStream.AtEndOfStream
MyShell.SendKeys(TextStream.ReadLine & Chr(13))
Loop
Set MyShell = Nothing

Set TextStream = Nothing
Set FileSystemObject = Nothing

======================

Some Notes:

You should only have to modify the first four lines.

Save the file with a .vbs extension, you should be able to run it by
double-clicking.

Note the TRIPLE-QUOTES on the second and third lines, and don't take
them out! If you do, it'll get confused over file/folder names longer
than 8 chars.

In your cmdfile.txt, just put a command on each line, like so:

verbose
e
look
quit

Line 4 (WaitSeconds = 5) determines the # of seconds that should pass
before it starts typing in. If this is too short, you'll blow some or
all of your commands while WinFrotz is still loading. Just play with it
until you find the right length for your system.

If you have any windows open that have "WinFrotz" in their header, it
may confuse the program (it uses that to find the WinFrotz executable
for typing).

Don Quixote

unread,
Nov 19, 2002, 4:54:11 PM11/19/02
to
"JL" <TR...@DE.SPAM> wrote in news:3dd7ca6b$0$2154$626a...@news.free.fr:

> Is it possible to obtain the transcript of a replay in batch mode and


> then use a comparison tool like diff to test many replays
> automatically with only one batch file ?
>
> I use Windows 9x and I don't know which interpreter would permit this.
> If nothing with Windows, then Linux Frotz version, maybe ? (I don't
> have Linux installed yet)

Here's the same code I posted before, but modified to handle the file
created by a SCRIPT command issued in-game:

=====================

CommandFile = "C:\path\to\script.scr"
WinFrotz = """C:\path\to\winfrotz.exe"""


GameFile = """C:\path\to\gamefile.z5"""
WaitSeconds = 5

Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
Set TextStream = FileSystemObject.OpenTextFile(CommandFile,1)

set MyShell = WScript.CreateObject("Wscript.Shell")
UselessVariable = MyShell.Run(WinFrotz & " " & GameFile)
MyShell.AppActivate "WinFrotz"
Wscript.Sleep WaitSeconds * 1000
Do While Not TextStream.AtEndOfStream

MyCommand = TextStream.ReadLine
If Left(MyCommand,1)=">" Then MyShell.SendKeys(Right(MyCommand,Len
(MyCommand)-1) & Chr(13))

JL

unread,
Nov 19, 2002, 7:33:49 PM11/19/02
to
I've just tried this script (thanks!). It works (incredible!) BUT :
- the keys are sometimes too fast (with many beeps) so I had to add "
Wscript.Sleep 200 " just before " Loop " but I'm not sure it will always be
enough
- if the active window is changed during the process, the keys are sent to
it (ie everywhere) !! (it can be dangerous ; it happened, but this time I
was lucky :-)

It's still interesting because WinFrotz displays french accents well
(Windows Frotz 2002 is even better with the input of accented characters)
and because the automatic transcript works too (for now I didn't manage to
start automatically a transcript with JZIP).

-- JL

PS The idea to use a filtered transcript as a list of commands is
interesting too.


"Don Quixote" <donqui...@hotmail.takethispartout.com> a écrit dans le
message de news:
7A9C697B9C3DF7F2.ADC61B98...@lp.airnews.net...

Benjamin Fan

unread,
Nov 19, 2002, 9:17:38 PM11/19/02
to
I do not know if these resources are available for MS Windows,
but I am using Expect and DejaGnu to automate IF testing.
Basically, you can set up scripts of inputs and expected outputs
and run the scripts to make sure that the correct interactions
occur.
http://expect.nist.gov/
http://www.gnu.org/software/dejagnu/dejagnu.html

A sample script to test a sample Cloak of Darkness game (not
the Inform version) is appended below. It simply starts the game,
verifies that the expected output is seen ("Hurrying through the
rainswept ...", "Cloak of Darkness", foyer name and description,
and user prompt), inputs the "quit" command, and verifies that the
correct quit output is seen.

load_file set_env.exp
set test "cloak1"
spawn $env(SHELL)
send -- "cd $jigpath\r"
send -- "pwd\r"
set timeout 5
send -- "kaffe Cloak\r"
expect {
-re "Hurrying" {}
default { fail "$test.a" }
}
set timeout 1
expect {
-re "Cloak of Darkness" {}
default { fail "$test.b" }
}
expect {
-re "Foyer of the Opera" {}
default { fail "$test.c" }
}
expect {
-re "south and west." {}
default { fail "$test.d" }
}
expect {
-re "> " {}
default { fail "$test.f" }
}

send -- "quit\r"

expect {
-re "Are you sure (yes/no)?" {}
default { fail "$test.g" }
}

send -- "yes\r"

expect {
-re "Your score was .* point., out of .* possible points." {}
default {fail "$test.h" }
}
pass "$test"

Ben


"JL" <TR...@DE.SPAM> wrote in message news:<3dd7ca6b$0$2154$626a...@news.free.fr>...

Don Quixote

unread,
Nov 20, 2002, 2:07:05 AM11/20/02
to
"JL" <TR...@DE.SPAM> wrote in news:3ddad9d4$0$2142$626a...@news.free.fr:

> I've just tried this script (thanks!). It works (incredible!) BUT :
> - the keys are sometimes too fast (with many beeps) so I had to add "
> Wscript.Sleep 200 " just before " Loop " but I'm not sure it will
> always be enough

Good point... I had wondered about that. If 200 is too short, you can
always adjust it on the fly.

> - if the active window is changed during the process, the keys are
> sent to it (ie everywhere) !! (it can be dangerous ; it happened, but
> this time I was lucky :-)

Heh, I'd forgotten to mention that. But in all honesty it shouldn't
take too long to iterate through the commands, so just watching it
complete should be fine.

> PS The idea to use a filtered transcript as a list of commands is
> interesting too.

Keep in mind that the transcript feature just looks for lines that start
with ">"... so any commands such as "[PRESS ANY KEY TO CONTINUE]" or
"Are you sure you wish to quit? [Y/N]" will be doomed to failure. It
shouldn't be too hard to error-trap those situations as they arrive
though.

--
"There ought to be limits to freedom." - George W. Bush

JL

unread,
Nov 20, 2002, 7:30:31 PM11/20/02
to
> I do not know if these resources are available for MS Windows,
> but I am using Expect and DejaGnu to automate IF testing.

I'll explore that too, maybe with Cygwin (because the Windows version seems
to be for NT).

Thanks

-- JL


Reply all
Reply to author
Forward
0 new messages