diff options
author | galaxycrab <UgnineSirdis@ydb.tech> | 2023-03-20 21:40:37 +0300 |
---|---|---|
committer | galaxycrab <UgnineSirdis@ydb.tech> | 2023-03-20 21:40:37 +0300 |
commit | de1da5bba65d071a1fa8a3dde559560c1c4ba8a2 (patch) | |
tree | 055beacf08a82444b3bced0ee9fa7b367f691bdc /library/cpp/testing/unittest/junit.h | |
parent | e39b77e20d0ff8cd09554e97153f2c0a1770ee3d (diff) | |
download | ydb-de1da5bba65d071a1fa8a3dde559560c1c4ba8a2.tar.gz |
Support --fork-tests in JUnitProcessor. Support more than one trace processor. Capture stderr/stdout logs, backtrace and time in JUnitProcesor
Diffstat (limited to 'library/cpp/testing/unittest/junit.h')
-rw-r--r-- | library/cpp/testing/unittest/junit.h | 64 |
1 files changed, 45 insertions, 19 deletions
diff --git a/library/cpp/testing/unittest/junit.h b/library/cpp/testing/unittest/junit.h index f5113c290e..2eca875310 100644 --- a/library/cpp/testing/unittest/junit.h +++ b/library/cpp/testing/unittest/junit.h @@ -1,12 +1,26 @@ #include "registar.h" +#include <util/datetime/base.h> +#include <util/generic/maybe.h> +#include <util/system/tempfile.h> + namespace NUnitTest { +extern const TString Y_UNITTEST_OUTPUT_CMDLINE_OPTION; + class TJUnitProcessor : public ITestSuiteProcessor { + struct TFailure { + TString Message; + TString BackTrace; + }; + struct TTestCase { TString Name; bool Success; - TVector<TString> Failures; + TVector<TFailure> Failures; + TString StdOut; + TString StdErr; + double DurationSecods = 0.0; size_t GetFailuresCount() const { return Failures.size(); @@ -27,27 +41,27 @@ class TJUnitProcessor : public ITestSuiteProcessor { } return sum; } + + double GetDurationSeconds() const { + double sum = 0.0; + for (const auto& [name, testCase] : Cases) { + sum += testCase.DurationSecods; + } + return sum; + } }; -public: - TJUnitProcessor(TString file, TString exec) - : FileName(file) - , ExecName(exec) - { - } + struct TOutputCapturer; - ~TJUnitProcessor() { - Save(); - } +public: + TJUnitProcessor(TString file, TString exec); + ~TJUnitProcessor(); - void OnError(const TError* descr) override { - auto* testCase = GetTestCase(descr->test); - testCase->Failures.emplace_back(descr->msg); - } + void SetForkTestsParams(bool forkTests, bool isForked) override; - void OnFinish(const TFinish* descr) override { - GetTestCase(descr->test)->Success = descr->Success; - } + void OnBeforeTest(const TTest* test) override; + void OnError(const TError* descr) override; + void OnFinish(const TFinish* descr) override; private: TTestCase* GetTestCase(const TTest* test) { @@ -73,10 +87,22 @@ private: return sum; } + void SerializeToFile(); + void MergeSubprocessReport(); + + TString BuildFileName(size_t index, const TStringBuf extension) const; + void MakeReportFileName(); + void MakeTmpFileNameForForkedTests(); + private: - TString FileName; - TString ExecName; + const TString FileName; // cmd line param + const TString ExecName; // cmd line param + TString ResultReportFileName; + TMaybe<TTempFile> TmpReportFile; TMap<TString, TTestSuite> Suites; + THolder<TOutputCapturer> StdErrCapturer; + THolder<TOutputCapturer> StdOutCapturer; + TInstant StartCurrentTestTime; }; } // namespace NUnitTest |