PATCH: Make result annotations always available for ExecTest
Mark Mitchell
mark at codesourcery.com
Fri Sep 26 23:04:32 UTC 2003
This test makes the result annotations for ExecTest (the exit code,
stdout, and stderr) always available. Until now, they've only been
available on FAILing tests. That's not in keeping with the spirit of
these kinds of annotations; you want to be able to look at them in the
results file whether or not the test fails.
I've also updated the documentation to remove an obsolete mention of
carriage-return issues in execution tests.
--
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery.com
2003-09-25 Mark Mitchell <mark at codesourcery.com>
* qm/test/classes/command.py (ExecTestBase.arguments): Improve
documentation for exit_code.
* qm/test/doc/tour.xml: Remove discussion of carriage-returns in
execution tests.
Index: qm/test/classes/command.py
===================================================================
RCS file: /home/sc/Repository/qm/qm/test/classes/command.py,v
retrieving revision 1.41
diff -c -5 -p -r1.41 command.py
*** qm/test/classes/command.py 25 Sep 2003 19:23:12 -0000 1.41
--- qm/test/classes/command.py 26 Sep 2003 22:53:58 -0000
*************** class ExecTestBase(Test):
*** 199,224 ****
else:
exit_code = os.WEXITSTATUS(exit_status)
# Get the output generated by the program.
stdout = e.stdout
stderr = e.stderr
# Check to see if the exit code matches.
if exit_code != self.exit_code:
causes.append("exit_code")
result["ExecTest.expected_exit_code"] \
= str(self.exit_code)
- result["ExecTest.exit_code"] = str(exit_code)
# Check to see if the standard output matches.
if not self.__CompareText(stdout, self.stdout):
causes.append("standard output")
- result["ExecTest.stdout"] = "<pre>" + stdout + "</pre>"
result["ExecTest.expected_stdout"] \
= "<pre>" + self.stdout + "</pre>"
# Check to see that the standard error matches.
if not self.__CompareText(stderr, self.stderr):
causes.append("standard error")
- result["ExecTest.stderr"] = "<pre>" + stderr + "</pre>"
result["ExecTest.expected_stderr"] \
= "<pre>" + self.stderr + "</pre>"
# If anything went wrong, the test failed.
if causes:
result.Fail("Unexpected %s." % string.join(causes, ", "))
--- 199,225 ----
else:
exit_code = os.WEXITSTATUS(exit_status)
# Get the output generated by the program.
stdout = e.stdout
stderr = e.stderr
+ # Record the results.
+ result["ExecTest.exit_code"] = str(exit_code)
+ result["ExecTest.stdout"] = "<pre>" + stdout + "</pre>"
+ result["ExecTest.stderr"] = "<pre>" + stderr + "</pre>"
# Check to see if the exit code matches.
if exit_code != self.exit_code:
causes.append("exit_code")
result["ExecTest.expected_exit_code"] \
= str(self.exit_code)
# Check to see if the standard output matches.
if not self.__CompareText(stdout, self.stdout):
causes.append("standard output")
result["ExecTest.expected_stdout"] \
= "<pre>" + self.stdout + "</pre>"
# Check to see that the standard error matches.
if not self.__CompareText(stderr, self.stderr):
causes.append("standard error")
result["ExecTest.expected_stderr"] \
= "<pre>" + self.stderr + "</pre>"
# If anything went wrong, the test failed.
if causes:
result.Fail("Unexpected %s." % string.join(causes, ", "))
Index: qm/test/doc/tour.xml
===================================================================
RCS file: /home/sc/Repository/qm/qm/test/doc/tour.xml,v
retrieving revision 1.7
diff -c -5 -p -r1.7 tour.xml
*** qm/test/doc/tour.xml 31 Jul 2003 23:17:50 -0000 1.7
--- qm/test/doc/tour.xml 26 Sep 2003 22:53:58 -0000
*************** QMTest running at http://127.0.0.1:1158/
*** 294,309 ****
because you're creating a different kind of test. Enter
<literal>echo test</literal> in the <guilabel>Command</guilabel>
field. This command will produce an output (the word
<literal>test</literal>), so find the <guilabel>Standard
Output</guilabel> box and enter <literal>test</literal> in this
! box. Make sure to hit the <keycap>Return</keycap> key after you
! type <literal>test</literal>; the <command>echo</command> command
! will output a carriage return after it prints the word
! <literal>test</literal>, so you must indicate that you expect a
! carriage return. When you are done, click the
! <guibutton>OK</guibutton> button at the bottom of the form.</para>
<para>Now you can select <guibutton>This Test</guibutton> from the
<guilabel>Run</guilabel> menu to run the test.</para>
<para>When you're done experimenting with &qmtest, choose
--- 294,305 ----
because you're creating a different kind of test. Enter
<literal>echo test</literal> in the <guilabel>Command</guilabel>
field. This command will produce an output (the word
<literal>test</literal>), so find the <guilabel>Standard
Output</guilabel> box and enter <literal>test</literal> in this
! box. When you are done, click the <guibutton>OK</guibutton> button
! at the bottom of the form.</para>
<para>Now you can select <guibutton>This Test</guibutton> from the
<guilabel>Run</guilabel> menu to run the test.</para>
<para>When you're done experimenting with &qmtest, choose
More information about the qmtest
mailing list