2080 """Prepare the test result directory in the destination directory storing
2081 into it the result fields.
2082 A summary of the test result is stored both in a file in the test directory
2083 and in the global summary file.
2086 summary[
"id"] = result.GetId()
2087 summary[
"outcome"] = result.GetOutcome()
2088 summary[
"cause"] = result.GetCause()
2089 summary[
"fields"] = result.keys()
2090 summary[
"fields"].sort()
2094 for f
in [
"id",
"outcome",
"cause"]:
2095 summary[f] = str(summary[f])
2096 summary[
"fields"] =
map(str, summary[
"fields"])
2102 if "qmtest.start_time" in summary[
"fields"]:
2103 haveStartDate =
True
2105 haveStartDate =
False
2106 if "qmtest.end_time" in summary[
"fields"]:
2113 self.
_startTime = calendar.timegm(time.strptime(result[
"qmtest.start_time"],
"%Y-%m-%dT%H:%M:%SZ"))
2114 if self._StartTestTime.text
is None:
2115 self._StartDateTime.text = time.strftime(
"%b %d %H:%M %Z", time.localtime(self.
_startTime))
2116 self._StartTestTime.text = str(self.
_startTime)
2117 self._site.set(
"BuildStamp" , result[
"qmtest.start_time"] )
2121 self.
_endTime = calendar.timegm(time.strptime(result[
"qmtest.end_time"],
"%Y-%m-%dT%H:%M:%SZ"))
2125 tl = ET.Element(
"Test")
2126 tl.text = summary[
"id"]
2127 self._TestList.insert(0,tl)
2130 Test = ET.Element(
"Test")
2131 if summary[
"outcome"] ==
"PASS":
2132 Test.set(
"Status",
"passed")
2133 elif summary[
"outcome"] ==
"FAIL":
2134 Test.set(
"Status",
"failed")
2135 elif summary[
"outcome"] ==
"SKIPPED" or summary[
"outcome"] ==
"UNTESTED":
2136 Test.set(
"Status",
"skipped")
2137 elif summary[
"outcome"] ==
"ERROR":
2138 Test.set(
"Status",
"failed")
2139 Name = ET.SubElement(Test,
"Name",)
2140 Name.text = summary[
"id"]
2141 Results = ET.SubElement(Test,
"Results")
2144 self._Testing.insert(3,Test)
2146 if haveStartDate
and haveEndDate:
2149 testduration = str(delta)
2150 Testduration= ET.SubElement(Results,
"NamedMeasurement")
2151 Testduration.set(
"name",
"Execution Time")
2152 Testduration.set(
"type",
"numeric/float" )
2153 value = ET.SubElement(Testduration,
"Value")
2154 value.text = testduration
2157 for n
in (
"qmtest.end_time",
"qmtest.start_time",
"qmtest.cause",
"ExecTest.stdout"):
2158 if n
in summary[
"fields"]:
2159 summary[
"fields"].
remove(n)
2163 if "ExecTest.exit_code" in summary[
"fields"] :
2164 summary[
"fields"].
remove(
"ExecTest.exit_code")
2165 ExitCode= ET.SubElement(Results,
"NamedMeasurement")
2166 ExitCode.set(
"name",
"exit_code")
2167 ExitCode.set(
"type",
"numeric/integer" )
2168 value = ET.SubElement(ExitCode,
"Value")
2171 TestStartTime= ET.SubElement(Results,
"NamedMeasurement")
2172 TestStartTime.set(
"name",
"Start_Time")
2173 TestStartTime.set(
"type",
"String" )
2174 value = ET.SubElement(TestStartTime,
"Value")
2180 TestEndTime= ET.SubElement(Results,
"NamedMeasurement")
2181 TestEndTime.set(
"name",
"End_Time")
2182 TestEndTime.set(
"type",
"String" )
2183 value = ET.SubElement(TestEndTime,
"Value")
2189 if summary[
"cause"]:
2190 FailureCause= ET.SubElement(Results,
"NamedMeasurement")
2191 FailureCause.set(
"name",
"Cause")
2192 FailureCause.set(
"type",
"String" )
2193 value = ET.SubElement(FailureCause,
"Value")
2198 for field
in summary[
"fields"] :
2199 fields[field] = ET.SubElement(Results,
"NamedMeasurement")
2200 fields[field].set(
"type",
"String")
2201 fields[field].set(
"name",field)
2202 value = ET.SubElement(fields[field],
"Value")
2204 if "<pre>" in result[field][0:6] :
2210 if result.has_key(
"ExecTest.stdout" ) :
2211 Measurement = ET.SubElement(Results,
"Measurement")
2212 value = ET.SubElement(Measurement,
"Value")
2213 if "<pre>" in result[
"ExecTest.stdout"][0:6] :
2220 self._tree.write(self.
_xmlFile,
"utf-8")