PATCH: Do not silently ignore bogus prerequisites
Mark Mitchell
mark at codesourcery.com
Wed Jul 20 00:44:26 UTC 2005
If a test had a prerequisite that did not exist in the database, we
silently ignored it. That situation probably reflects a problem with
the test database. This patch therefore changes the behavior of
QMTest so that in this case the test with the bogus prerequisite is
UNTESTED.
Committed.
--
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery.com
2005-07-19 Mark Mitchell <mark at codesourcery.com>
* qm/test/execution_engine.py (ExecutionEngine.__AddTestToStack):
If a test prerequisite does not exist, give the test an error
outcome.
* qm/test/share/messages/diagnostics.txt (prerequisite not in
database): New message.
* tests/regress/bad_prereq: New test.
* qm/test/classes/python.py (ExecTest.Run): Handle empty input.
Index: qm/test/execution_engine.py
===================================================================
RCS file: /home/qm/Repository/qm/qm/test/execution_engine.py,v
retrieving revision 1.29
diff -c -5 -p -r1.29 execution_engine.py
*** qm/test/execution_engine.py 26 May 2004 01:25:13 -0000 1.29
--- qm/test/execution_engine.py 20 Jul 2005 00:37:45 -0000
*************** class ExecutionEngine:
*** 547,556 ****
--- 547,569 ----
# Load the descriptor.
descriptor = self.__GetTestDescriptor(test_id)
if not descriptor:
return 0
+ # Check that all the prerequisites listed are actually present
+ # in the database. We may not actually run all of them, but if
+ # they're completely missing, that indicates a problem with
+ # either the descriptor or the database.
+ for p in descriptor.GetPrerequisites():
+ if not self.__database.HasTest(p):
+ self.__AddUntestedResult(
+ test_id,
+ qm.message("prerequisite not in database",
+ prerequisite = p)
+ )
+ return 0
+
# Ignore prerequisites that are not going to be run at all.
prereqs_iter = iter(descriptor.GetPrerequisites())
relevant_prereqs = filter(self.__statuses.has_key, prereqs_iter)
# Store the test on the stack.
Index: qm/test/classes/python.py
===================================================================
RCS file: /home/qm/Repository/qm/qm/test/classes/python.py,v
retrieving revision 1.18
diff -c -5 -p -r1.18 python.py
*** qm/test/classes/python.py 22 Mar 2005 01:11:15 -0000 1.18
--- qm/test/classes/python.py 20 Jul 2005 00:37:45 -0000
*************** class ExecTest(Test):
*** 72,90 ****
]
def Run(self, context, result):
! # Adjust the source code.
! if self.source is None:
! self.source = ""
! else:
! # Make sure the source ends with a newline. A user is
! # likely to be confused by the error message if it's
! # missing.
! if self.source[-1] != "\n":
! self.source = self.source + "\n"
global_namespace, local_namespace = make_namespaces(context)
# Execute the source code.
try:
exec self.source in global_namespace, local_namespace
except:
--- 72,88 ----
]
def Run(self, context, result):
! # Adjust the source code. Make sure the source ends with a
! # newline. A user is likely to be confused by the error message
! # if it's missing.
! if not self.source:
! self.source = "\n"
! elif self.source[-1] != "\n":
! self.source += "\n"
global_namespace, local_namespace = make_namespaces(context)
# Execute the source code.
try:
exec self.source in global_namespace, local_namespace
except:
Index: qm/test/share/messages/diagnostics.txt
===================================================================
RCS file: /home/qm/Repository/qm/qm/test/share/messages/diagnostics.txt,v
retrieving revision 1.11
diff -c -5 -p -r1.11 diagnostics.txt
*** qm/test/share/messages/diagnostics.txt 13 Nov 2003 03:08:01 -0000 1.11
--- qm/test/share/messages/diagnostics.txt 20 Jul 2005 00:37:45 -0000
*************** The "%(file)s" target file could not be
*** 39,53 ****
@ dependency cycle
This test depends on itself, either directly or by way of other tests.
@ error loading xml resource
A problem occurred while loading the XML resource file "%(resource_id)s":
! %(message)s.
@ error loading xml test
A problem occurred while loading the XML test file "%(test_id)s":
! %(message)s.
@ execution terminated
Termination was requested before this test was executed.
@ extension class not found
--- 39,53 ----
@ dependency cycle
This test depends on itself, either directly or by way of other tests.
@ error loading xml resource
A problem occurred while loading the XML resource file "%(resource_id)s":
! %(message)s
@ error loading xml test
A problem occurred while loading the XML test file "%(test_id)s":
! %(message)s
@ execution terminated
Termination was requested before this test was executed.
@ extension class not found
*************** An extension class failed to override th
*** 185,194 ****
--- 185,197 ----
The following traceback may be helpful to the extension class implementor.
@ not test database
"%(path)s" is not a test database.
+ @ prerequisite not in database
+ The non-existant test "%(prerequisite)s" is listed as a prerequisite.
+
@ seed not integer
The random number generator seed you specified, "%(seed)s", is not an
integer.
@ suite already exists
Index: tests/regress/bad_prereq/a.qmt
===================================================================
RCS file: tests/regress/bad_prereq/a.qmt
diff -N tests/regress/bad_prereq/a.qmt
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- tests/regress/bad_prereq/a.qmt 20 Jul 2005 00:37:45 -0000
***************
*** 0 ****
--- 1,9 ----
+ <?xml version="1.0" ?>
+ <!DOCTYPE extension
+ PUBLIC '-//QM/2.3/Extension//EN'
+ 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'>
+ <extension class="python.ExecTest" kind="test">
+ <argument name="source"><text/></argument>
+ <argument name="expression"><text>True</text></argument>
+ <argument name="prerequisites"><set><tuple><text>bad_prereq</text><enumeral>PASS</enumeral></tuple></set></argument>
+ </extension>
Index: tests/regress/bad_prereq/results.qmr
===================================================================
RCS file: tests/regress/bad_prereq/results.qmr
diff -N tests/regress/bad_prereq/results.qmr
Binary files /dev/null and results.qmr differ
Index: tests/regress/bad_prereq/QMTest/configuration
===================================================================
RCS file: tests/regress/bad_prereq/QMTest/configuration
diff -N tests/regress/bad_prereq/QMTest/configuration
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- tests/regress/bad_prereq/QMTest/configuration 20 Jul 2005 00:37:45 -0000
***************
*** 0 ****
--- 1,5 ----
+ <?xml version="1.0" ?>
+ <!DOCTYPE extension
+ PUBLIC '-//QM/2.3/Extension//EN'
+ 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'>
+ <extension class="xml_database.XMLDatabase" kind="database"/>
\ No newline at end of file
More information about the qmtest
mailing list