2078 """Prepare the test result directory in the destination directory storing
2079 into it the result fields.
2080 A summary of the test result is stored both in a file in the test directory
2081 and in the global summary file.
2084 summary[
"id"] = result.GetId()
2085 summary[
"outcome"] = result.GetOutcome()
2086 summary[
"cause"] = result.GetCause()
2087 summary[
"fields"] = result.keys()
2088 summary[
"fields"].sort()
2092 for f
in [
"id",
"outcome",
"cause"]:
2093 summary[f] = str(summary[f])
2094 summary[
"fields"] =
map(str, summary[
"fields"])
2100 if "qmtest.start_time" in summary[
"fields"]:
2101 haveStartDate =
True
2103 haveStartDate =
False
2104 if "qmtest.end_time" in summary[
"fields"]:
2111 self.
_startTime = calendar.timegm(time.strptime(result[
"qmtest.start_time"],
"%Y-%m-%dT%H:%M:%SZ"))
2112 if self._StartTestTime.text
is None:
2113 self._StartDateTime.text = time.strftime(
"%b %d %H:%M %Z", time.localtime(self.
_startTime))
2114 self._StartTestTime.text = str(self.
_startTime)
2115 self._site.set(
"BuildStamp" , result[
"qmtest.start_time"] )
2119 self.
_endTime = calendar.timegm(time.strptime(result[
"qmtest.end_time"],
"%Y-%m-%dT%H:%M:%SZ"))
2123 tl = ET.Element(
"Test")
2124 tl.text = summary[
"id"]
2125 self._TestList.insert(0,tl)
2128 Test = ET.Element(
"Test")
2129 if summary[
"outcome"] ==
"PASS":
2130 Test.set(
"Status",
"passed")
2131 elif summary[
"outcome"] ==
"FAIL":
2132 Test.set(
"Status",
"failed")
2133 elif summary[
"outcome"] ==
"SKIPPED" or summary[
"outcome"] ==
"UNTESTED":
2134 Test.set(
"Status",
"skipped")
2135 elif summary[
"outcome"] ==
"ERROR":
2136 Test.set(
"Status",
"failed")
2137 Name = ET.SubElement(Test,
"Name",)
2138 Name.text = summary[
"id"]
2139 Results = ET.SubElement(Test,
"Results")
2142 self._Testing.insert(3,Test)
2144 if haveStartDate
and haveEndDate:
2147 testduration = str(delta)
2148 Testduration= ET.SubElement(Results,
"NamedMeasurement")
2149 Testduration.set(
"name",
"Execution Time")
2150 Testduration.set(
"type",
"numeric/float" )
2151 value = ET.SubElement(Testduration,
"Value")
2152 value.text = testduration
2155 for n
in (
"qmtest.end_time",
"qmtest.start_time",
"qmtest.cause",
"ExecTest.stdout"):
2156 if n
in summary[
"fields"]:
2157 summary[
"fields"].
remove(n)
2161 if "ExecTest.exit_code" in summary[
"fields"] :
2162 summary[
"fields"].
remove(
"ExecTest.exit_code")
2163 ExitCode= ET.SubElement(Results,
"NamedMeasurement")
2164 ExitCode.set(
"name",
"exit_code")
2165 ExitCode.set(
"type",
"numeric/integer" )
2166 value = ET.SubElement(ExitCode,
"Value")
2169 TestStartTime= ET.SubElement(Results,
"NamedMeasurement")
2170 TestStartTime.set(
"name",
"Start_Time")
2171 TestStartTime.set(
"type",
"String" )
2172 value = ET.SubElement(TestStartTime,
"Value")
2178 TestEndTime= ET.SubElement(Results,
"NamedMeasurement")
2179 TestEndTime.set(
"name",
"End_Time")
2180 TestEndTime.set(
"type",
"String" )
2181 value = ET.SubElement(TestEndTime,
"Value")
2187 if summary[
"cause"]:
2188 FailureCause= ET.SubElement(Results,
"NamedMeasurement")
2189 FailureCause.set(
"name",
"Cause")
2190 FailureCause.set(
"type",
"String" )
2191 value = ET.SubElement(FailureCause,
"Value")
2196 for field
in summary[
"fields"] :
2197 fields[field] = ET.SubElement(Results,
"NamedMeasurement")
2198 fields[field].set(
"type",
"String")
2199 fields[field].set(
"name",field)
2200 value = ET.SubElement(fields[field],
"Value")
2202 if "<pre>" in result[field][0:6] :
2208 if result.has_key(
"ExecTest.stdout" ) :
2209 Measurement = ET.SubElement(Results,
"Measurement")
2210 value = ET.SubElement(Measurement,
"Value")
2211 if "<pre>" in result[
"ExecTest.stdout"][0:6] :
2218 self._tree.write(self.
_xmlFile,
"utf-8")