Skip to content

Commit 7bfa182

Browse files
committed
discuss trun, tdiff, tclean in notes/test.txt, commands.txt
also mention tclean in PowerSwitch/test_exception.py comment header
1 parent a0da67c commit 7bfa182

File tree

3 files changed

+45
-28
lines changed

3 files changed

+45
-28
lines changed

notes/commands.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ PyModel also provides these programs and scripts:
5050

5151
trun: runs sample demonstrations and scripts that test PyModel itself.
5252

53-
clogdiff: works with trun to execute and check regression tests on PyModel.
53+
tdiff: works with trun to execute and check regression tests on PyModel.
54+
55+
clogdiff: same as tdiff, used in PyModel versions before 1.0,
56+
retained for backwards compatibility, but now deprecated
57+
58+
tclean: removes output files from test scripts in the current directory
5459

5560
To prepare to use the programs, put the PyModel/bin directory on your
5661
execution path. Put the Pymodel/pymodel directory and the the current

notes/test.txt

+38-26
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ distribution, including the tests of all the samples. These scripts
99
demonstrate the samples, as well as testing PyModel itself.
1010

1111
These notes describe our unit tests, along with our little homemade
12-
unit testing commands, which are independent of the rest of PyModel
13-
(they could be used to test any program that writes to stdout). We
14-
use these (instead of a conventional unit test framework like unittest
15-
or nose) because:
12+
unit testing commands: trun, tdiff, and tclean. These commands are
13+
independent of the rest of PyModel (they could be used to test any
14+
program that writes to stdout). We use these (instead of a
15+
conventional unit test framework like unittest or nose) because:
1616

1717
- The units we test here are not function calls or method calls,
1818
but entire program invocations including command line arguments.
@@ -46,35 +46,41 @@ Quick Start
4646

4747
In each subdirectory of samples, type:
4848

49-
clogdiff trun test
49+
tdiff trun test
5050

5151
if there are more test*.py files besides test.py, you can run them too:
5252

53-
clogdiff trun test_scenarios
53+
tdiff trun test_scenarios
5454

5555
etc. If messages indicate differences were found, there may be a
5656
problem. Or maybe not (see Checking test script output, below). If
5757
messages indicate there is no .ref file, it means that this test
58-
script is not deterministic and the clogdiff command is not meaningful
58+
script is not deterministic and the tdiff command is not meaningful
5959
-- instead just run trun test (or whatever).
6060

6161

6262
Summary
6363

6464
commands in bin directory
65-
trun - execute test script module
66-
clogdiff - execute test script, compare output to reference
67-
clogdiff.bat - ditto, batch script for Windows
65+
trun - execute test script module
66+
tdiff - execute test script, compare output to reference
67+
tdiff.bat - ditto, batch script for Windows
68+
tclean - remove output files created by running test scripts
69+
tclean.bat - ditto, batch script for Windows
70+
71+
The tdiff command was called clogdiff in PyModel versions before 1.0.
72+
The clogdiff command is retained for backwards compatibility, but is
73+
deprecated.
6874

6975
Programs and scripts in the pymodel directory
7076
trun.py - executes test script module given as argument
7177

7278
In each model directory: samples/PowerSwitch, samples/WebApplication/Model,...
7379
test.py - test script module, executed by trun
7480
test.log - most recent output from test.py, including stdout and stderr,
75-
saved by clogdiff
81+
saved by tdiff
7682
test.ref - sample test.log from from test.py, including stdout and stderr,
77-
renamed by hand, used by clogdiff
83+
renamed by hand, used by tdiff
7884
test_scenarios.py, test_graphics.py, ... - other test script modules
7985
test_scenarios.ref ... - etc., like test.ref
8086
fsmpy/ - directory of FSM Python modules written by pma.py (maybe via pmv.py)
@@ -145,7 +151,7 @@ Checking test script output
145151

146152
Executing a test script typically writes a lot of output to the
147153
terminal (that is, to stdout and stderr). For regression testing, use
148-
the clogdiff command in the pymodel directory. clogdiff runs a
154+
the tdiff command in the pymodel directory. tdiff runs a
149155
command, collects the output to stdout and stderr in a log file and
150156
compares it to a reference log file. To use it, make a reference log
151157
file first:
@@ -155,42 +161,42 @@ file first:
155161
(But on Windows systems you must use > and >& and only stdout not
156162
stderr is captured in test.ref.)
157163

158-
Then invoke clogdiff:
164+
Then invoke tdiff:
159165

160-
clogdiff trun test
166+
tdiff trun test
161167

162-
On Unix-like systems (including Linux and Mac OS X), clogdiff prints
168+
On Unix-like systems (including Linux and Mac OS X), tdiff prints
163169
no output when there are no differences, and only prints out any
164-
differences that it finds. On Windows systems, clogdiff.bat prints
170+
differences that it finds. On Windows systems, tdiff.bat prints
165171

166172
Comparing files test.log and TEST.REF
167173
FC: no differences encountered
168174

169175
when there are no differences.
170176

171-
Be warned that on Windows systems "clogdiff trun test_graphics" writes
177+
Be warned that on Windows systems "tdiff trun test_graphics" writes
172178
a lot of output to the screen, but the line "FC: no differences
173179
encountered" should appear at the end. (On Unix-like systems, nothing
174180
more should appear.) Apparently all this output is stderr output from
175181
the graphviz dot program, which is not captured or checked by
176-
clogdiff.
182+
tdiff.
177183

178184
Be warned that if you use .ref files generated on one system and
179-
execute clogdiff on another system, differences may be reported even
185+
execute tdiff on another system, differences may be reported even
180186
when the programs work correctly, in cases where PyModel randomly
181187
selects actions and action arguments (as it does in many scripts).
182188
Apparently, the functions from the random module that PyModel uses
183189
behave differently on different systems, even when started with the
184190
same seed (the pmt -s option, which is supposed to make the random
185191
selections repeatable). In particular, some of the .ref files
186-
included in the PyModel distribution may cause clogdiff to report
192+
included in the PyModel distribution may cause tdiff to report
187193
differences on your system.
188194

189195
Differences may also be reported because command prompts or file paths
190196
appear in the output, and these were different when the .ref file was
191197
generated.
192198

193-
If clogdiff reports differences, examine the output (in the .log file)
199+
If tdiff reports differences, examine the output (in the .log file)
194200
to determine whether the differences indicate errors, or are merely
195201
due to different randomly selected choices on your system, or to
196202
environmental differences like command prompts or file paths. In the
@@ -223,7 +229,7 @@ stderr), but other PyModel commands write output files: pma writes
223229
another module (.py file) that contains the generated FSM, pmg
224230
writes a .dot file with commands for the Graphviz dot program, and the
225231
various dot commands (dotsvg etc.) write graphics files: .svg, .pdf,
226-
.ps etc. The pmv program invokes all of these programs causes all
232+
.ps etc. The pmv program invokes all of these programs and causes all
227233
of these files to be written.
228234

229235
The PyModel programs write all of these output files in the current
@@ -240,10 +246,16 @@ generate into these directories, so you can compare them to output
240246
from tests that you run later (in much the same way that the .ref
241247
files are used to compare output to stdout).
242248

249+
The pmclean command removes these test output files from the current
250+
directory. It does not remove them from the fsmpy or svg
251+
subdirectories (or any other subdirectories). All of the files
252+
removed by pmclean can be easily recreated just by running the test
253+
scripts again.
254+
243255

244256
Using other unit testing frameworks
245257

246-
Our trun and clogdiff commands, along with our test scripts, comprise
258+
Our trun and tdiff commands, along with our test scripts, comprise
247259
a very simple homemade unit testing framework, an alternative to the
248260
popular Python unit test frameworks such as unittest or nose.
249261

@@ -274,7 +286,7 @@ the test output is also more verbose (the -v option here just commands
274286
unittest to print the docstring for each test case). The
275287
test_populations.py module merely executes the tests, it does not
276288
check the results (it uses no assertions). To check the results, you
277-
could capture and check the output using our clogdiff command, just as
289+
could capture and check the output using our tdiff command, just as
278290
you would do with with test.py.
279291

280-
Revised Apr 2013
292+
Revised May 2013

samples/PowerSwitch/test_exception.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Test raising an exception, to check how clogdiff handles it
2+
Test raising an exception, to check how tdiff (formerly clogdiff) handles it
33
"""
44

55
cases = [

0 commit comments

Comments
 (0)