diff options
| author | Yong He <yonghe@outlook.com> | 2022-01-10 13:16:30 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-10 13:16:30 -0800 |
| commit | 0ac19741937e007ebb45791f53d413d21055feda (patch) | |
| tree | e058c07fef9138941b253116c1d8a434c334ab67 /tools/slang-test/test-reporter.cpp | |
| parent | 36e9276b1799b476f12db9b24d3073ceef3b7594 (diff) | |
Enable running tests in parallel. (#2078)
* Enable running tests in parallel.
* Fix linux build.
* Add pthread dependency for slang-test.
* Fix teamcity output.
* Fix race condition.
* Make testReporter thread safe.
* Clean up.
* Fix.
* trigger build
* Fix.
Co-authored-by: Yong He <yhe@nvidia.com>
Co-authored-by: Theresa Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'tools/slang-test/test-reporter.cpp')
| -rw-r--r-- | tools/slang-test/test-reporter.cpp | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/tools/slang-test/test-reporter.cpp b/tools/slang-test/test-reporter.cpp index 83df0fb0b..ee8421e81 100644 --- a/tools/slang-test/test-reporter.cpp +++ b/tools/slang-test/test-reporter.cpp @@ -7,6 +7,8 @@ #include <stdio.h> #include <stdlib.h> +#include <mutex> + using namespace Slang; /* static */TestReporter* TestReporter::s_reporter = nullptr; @@ -82,9 +84,10 @@ TestReporter::TestReporter() : m_isVerbose = false; } -Result TestReporter::init(TestOutputMode outputMode) +Result TestReporter::init(TestOutputMode outputMode, bool isSubReporter) { m_outputMode = outputMode; + m_isSubReporter = isSubReporter; return SLANG_OK; } @@ -191,6 +194,15 @@ TestResult TestReporter::addTest(const String& testName, bool isPass) return res; } +void TestReporter::consolidateWith(TestReporter* other) +{ + m_testInfos.addRange(other->m_testInfos); + m_failedTestCount += other->m_failedTestCount; + m_ignoredTestCount += other->m_ignoredTestCount; + m_passedTestCount += other->m_passedTestCount; + m_totalTestCount += other->m_totalTestCount; +} + void TestReporter::dumpOutputDifference(const String& expectedOutput, const String& actualOutput) { StringBuilder builder; @@ -493,6 +505,8 @@ void TestReporter::addTest(const String& testName, TestResult testResult) void TestReporter::message(TestMessageType type, const String& message) { + static std::mutex mutex; + std::lock_guard<std::mutex> lock(mutex); if (type == TestMessageType::Info) { if (m_isVerbose && canWriteStdError()) @@ -666,9 +680,12 @@ void TestReporter::startSuite(const String& name) { case TestOutputMode::TeamCity: { - StringBuilder escapedSuiteName; - _appendEncodedTeamCityString(name.getUnownedSlice(), escapedSuiteName); - printf("##teamcity[testSuiteStarted name='%s']\n", escapedSuiteName.begin()); + if (!m_isSubReporter) + { + StringBuilder escapedSuiteName; + _appendEncodedTeamCityString(name.getUnownedSlice(), escapedSuiteName); + printf("##teamcity[testSuiteStarted name='%s']\n", escapedSuiteName.begin()); + } break; } default: break; @@ -683,10 +700,13 @@ void TestReporter::endSuite() { case TestOutputMode::TeamCity: { - const String& name = m_suiteStack.getLast(); - StringBuilder escapedSuiteName; - _appendEncodedTeamCityString(name.getUnownedSlice(), escapedSuiteName); - printf("##teamcity[testSuiteFinished name='%s']\n", escapedSuiteName.begin()); + if (!m_isSubReporter) + { + const String& name = m_suiteStack.getLast(); + StringBuilder escapedSuiteName; + _appendEncodedTeamCityString(name.getUnownedSlice(), escapedSuiteName); + printf("##teamcity[testSuiteFinished name='%s']\n", escapedSuiteName.begin()); + } break; } default: break; |
