2056 """Prepare the test result directory in the destination directory storing
2057 into it the result fields.
2058 A summary of the test result is stored both in a file in the test directory
2059 and in the global summary file.
2062 summary[
"id"] = result.GetId()
2063 summary[
"outcome"] = result.GetOutcome()
2064 summary[
"cause"] = result.GetCause()
2065 summary[
"fields"] = result.keys()
2066 summary[
"fields"].sort()
2070 for f
in [
"id",
"outcome",
"cause"]:
2071 summary[f] = str(summary[f])
2072 summary[
"fields"] =
map(str, summary[
"fields"])
2078 if "qmtest.start_time" in summary[
"fields"]:
2079 haveStartDate =
True
2081 haveStartDate =
False
2082 if "qmtest.end_time" in summary[
"fields"]:
2089 self.
_startTime = calendar.timegm(time.strptime(result[
"qmtest.start_time"],
"%Y-%m-%dT%H:%M:%SZ"))
2090 if self._StartTestTime.text
is None:
2091 self._StartDateTime.text = time.strftime(
"%b %d %H:%M %Z", time.localtime(self.
_startTime))
2092 self._StartTestTime.text = str(self.
_startTime)
2093 self._site.set(
"BuildStamp" , result[
"qmtest.start_time"] )
2097 self.
_endTime = calendar.timegm(time.strptime(result[
"qmtest.end_time"],
"%Y-%m-%dT%H:%M:%SZ"))
2101 tl = ET.Element(
"Test")
2102 tl.text = summary[
"id"]
2103 self._TestList.insert(0,tl)
2106 Test = ET.Element(
"Test")
2107 if summary[
"outcome"] ==
"PASS":
2108 Test.set(
"Status",
"passed")
2109 elif summary[
"outcome"] ==
"FAIL":
2110 Test.set(
"Status",
"failed")
2111 elif summary[
"outcome"] ==
"SKIPPED" or summary[
"outcome"] ==
"UNTESTED":
2112 Test.set(
"Status",
"skipped")
2113 elif summary[
"outcome"] ==
"ERROR":
2114 Test.set(
"Status",
"failed")
2115 Name = ET.SubElement(Test,
"Name",)
2116 Name.text = summary[
"id"]
2117 Results = ET.SubElement(Test,
"Results")
2120 self._Testing.insert(3,Test)
2122 if haveStartDate
and haveEndDate:
2125 testduration = str(delta)
2126 Testduration= ET.SubElement(Results,
"NamedMeasurement")
2127 Testduration.set(
"name",
"Execution Time")
2128 Testduration.set(
"type",
"numeric/float" )
2129 value = ET.SubElement(Testduration,
"Value")
2130 value.text = testduration
2133 for n
in (
"qmtest.end_time",
"qmtest.start_time",
"qmtest.cause",
"ExecTest.stdout"):
2134 if n
in summary[
"fields"]:
2135 summary[
"fields"].
remove(n)
2139 if "ExecTest.exit_code" in summary[
"fields"] :
2140 summary[
"fields"].
remove(
"ExecTest.exit_code")
2141 ExitCode= ET.SubElement(Results,
"NamedMeasurement")
2142 ExitCode.set(
"name",
"exit_code")
2143 ExitCode.set(
"type",
"numeric/integer" )
2144 value = ET.SubElement(ExitCode,
"Value")
2147 TestStartTime= ET.SubElement(Results,
"NamedMeasurement")
2148 TestStartTime.set(
"name",
"Start_Time")
2149 TestStartTime.set(
"type",
"String" )
2150 value = ET.SubElement(TestStartTime,
"Value")
2156 TestEndTime= ET.SubElement(Results,
"NamedMeasurement")
2157 TestEndTime.set(
"name",
"End_Time")
2158 TestEndTime.set(
"type",
"String" )
2159 value = ET.SubElement(TestEndTime,
"Value")
2165 if summary[
"cause"]:
2166 FailureCause= ET.SubElement(Results,
"NamedMeasurement")
2167 FailureCause.set(
"name",
"Cause")
2168 FailureCause.set(
"type",
"String" )
2169 value = ET.SubElement(FailureCause,
"Value")
2174 for field
in summary[
"fields"] :
2175 fields[field] = ET.SubElement(Results,
"NamedMeasurement")
2176 fields[field].set(
"type",
"String")
2177 fields[field].set(
"name",field)
2178 value = ET.SubElement(fields[field],
"Value")
2180 if "<pre>" in result[field][0:6] :
2186 if result.has_key(
"ExecTest.stdout" ) :
2187 Measurement = ET.SubElement(Results,
"Measurement")
2188 value = ET.SubElement(Measurement,
"Value")
2189 if "<pre>" in result[
"ExecTest.stdout"][0:6] :
2196 self._tree.write(self.
_xmlFile,
"utf-8")