@@ -9,10 +9,10 @@ distribution, including the tests of all the samples. These scripts
9
9
demonstrate the samples, as well as testing PyModel itself.
10
10
11
11
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:
16
16
17
17
- The units we test here are not function calls or method calls,
18
18
but entire program invocations including command line arguments.
@@ -46,35 +46,41 @@ Quick Start
46
46
47
47
In each subdirectory of samples, type:
48
48
49
- clogdiff trun test
49
+ tdiff trun test
50
50
51
51
if there are more test*.py files besides test.py, you can run them too:
52
52
53
- clogdiff trun test_scenarios
53
+ tdiff trun test_scenarios
54
54
55
55
etc. If messages indicate differences were found, there may be a
56
56
problem. Or maybe not (see Checking test script output, below). If
57
57
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
59
59
-- instead just run trun test (or whatever).
60
60
61
61
62
62
Summary
63
63
64
64
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.
68
74
69
75
Programs and scripts in the pymodel directory
70
76
trun.py - executes test script module given as argument
71
77
72
78
In each model directory: samples/PowerSwitch, samples/WebApplication/Model,...
73
79
test.py - test script module, executed by trun
74
80
test.log - most recent output from test.py, including stdout and stderr,
75
- saved by clogdiff
81
+ saved by tdiff
76
82
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
78
84
test_scenarios.py, test_graphics.py, ... - other test script modules
79
85
test_scenarios.ref ... - etc., like test.ref
80
86
fsmpy/ - directory of FSM Python modules written by pma.py (maybe via pmv.py)
@@ -145,7 +151,7 @@ Checking test script output
145
151
146
152
Executing a test script typically writes a lot of output to the
147
153
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
149
155
command, collects the output to stdout and stderr in a log file and
150
156
compares it to a reference log file. To use it, make a reference log
151
157
file first:
@@ -155,42 +161,42 @@ file first:
155
161
(But on Windows systems you must use > and >& and only stdout not
156
162
stderr is captured in test.ref.)
157
163
158
- Then invoke clogdiff :
164
+ Then invoke tdiff :
159
165
160
- clogdiff trun test
166
+ tdiff trun test
161
167
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
163
169
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
165
171
166
172
Comparing files test.log and TEST.REF
167
173
FC: no differences encountered
168
174
169
175
when there are no differences.
170
176
171
- Be warned that on Windows systems "clogdiff trun test_graphics" writes
177
+ Be warned that on Windows systems "tdiff trun test_graphics" writes
172
178
a lot of output to the screen, but the line "FC: no differences
173
179
encountered" should appear at the end. (On Unix-like systems, nothing
174
180
more should appear.) Apparently all this output is stderr output from
175
181
the graphviz dot program, which is not captured or checked by
176
- clogdiff .
182
+ tdiff .
177
183
178
184
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
180
186
when the programs work correctly, in cases where PyModel randomly
181
187
selects actions and action arguments (as it does in many scripts).
182
188
Apparently, the functions from the random module that PyModel uses
183
189
behave differently on different systems, even when started with the
184
190
same seed (the pmt -s option, which is supposed to make the random
185
191
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
187
193
differences on your system.
188
194
189
195
Differences may also be reported because command prompts or file paths
190
196
appear in the output, and these were different when the .ref file was
191
197
generated.
192
198
193
- If clogdiff reports differences, examine the output (in the .log file)
199
+ If tdiff reports differences, examine the output (in the .log file)
194
200
to determine whether the differences indicate errors, or are merely
195
201
due to different randomly selected choices on your system, or to
196
202
environmental differences like command prompts or file paths. In the
@@ -223,7 +229,7 @@ stderr), but other PyModel commands write output files: pma writes
223
229
another module (.py file) that contains the generated FSM, pmg
224
230
writes a .dot file with commands for the Graphviz dot program, and the
225
231
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
227
233
of these files to be written.
228
234
229
235
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
240
246
from tests that you run later (in much the same way that the .ref
241
247
files are used to compare output to stdout).
242
248
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
+
243
255
244
256
Using other unit testing frameworks
245
257
246
- Our trun and clogdiff commands, along with our test scripts, comprise
258
+ Our trun and tdiff commands, along with our test scripts, comprise
247
259
a very simple homemade unit testing framework, an alternative to the
248
260
popular Python unit test frameworks such as unittest or nose.
249
261
@@ -274,7 +286,7 @@ the test output is also more verbose (the -v option here just commands
274
286
unittest to print the docstring for each test case). The
275
287
test_populations.py module merely executes the tests, it does not
276
288
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
278
290
you would do with with test.py.
279
291
280
- Revised Apr 2013
292
+ Revised May 2013
0 commit comments