MCPcopy Create free account
hub / github.com/Snapchat/Valdi / saveToFile

Method saveToFile

tsn/src/test262/runner/TestReporter.cpp:57–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57void TestReporter::saveToFile(const fs::path& file) {
58 std::fstream outputStream(file, std::ios_base::out | std::ios_base::trunc);
59 if (outputStream.fail()) {
60 TEST262_LOG(cerr, "Could not create output file {}", file.string());
61 return;
62 }
63
64 TEST262_LOG(outputStream, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
65 TEST262_LOG(outputStream,
66 "<testsuites tests=\"{}\" failures=\"{}\" skipped=\"{}\" errors=\"0\" name=\"AllTests\">",
67 _aggregateStats.total,
68 _aggregateStats.fail,
69 _aggregateStats.disabled);
70 for (const auto& suite : _testSuite) {
71 const auto stats = _testSuiteStats[suite.first];
72 TEST262_LOG(outputStream,
73 "\t<testsuite name=\"{}\" tests=\"{}\" failures=\"{}\" disabled=\"{}\" errors=\"0\">",
74 suite.first,
75 stats.total,
76 stats.fail,
77 stats.disabled);
78 for (const auto& testReport : suite.second) {
79 // status="notrun" result="suppressed"
80 TEST262_LOG(outputStream,
81 "\t\t<testcase name=\"{}\" status=\"{}\" result=\"{}\">",
82 testReport.first,
83 testReport.second.result == TestResult::Disable ? "notrun" : "run",
84 testReport.second.result == TestResult::Disable ? "suppressed" : "completed");
85 switch (testReport.second.result) {
86 case TestResult::Fail: {
87 TEST262_LOG(outputStream, "\t\t\t<failure></failure>");
88 } break;
89 case TestResult::Disable: {
90 TEST262_LOG(outputStream, "\t\t\t<disabled></disabled>");
91 } break;
92 default:
93 break;
94 }
95 TEST262_LOG(outputStream, "\t\t</testcase>");
96 }
97 TEST262_LOG(outputStream, "\t</testsuite>");
98 }
99 TEST262_LOG(outputStream, "</testsuites>");
100}

Callers 1

runTestCasesFunction · 0.80

Calls 1

stringMethod · 0.45

Tested by

no test coverage detected