diff options
author | Justin Goshi <jgoshi@microsoft.com> | 2018-10-18 18:33:01 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-01-08 16:22:11 (GMT) |
commit | 7b81d8c21e0a0d8756f0afdc0530c2d06ee3bcd4 (patch) | |
tree | 0848b0d979656afe9b796ecbd6b5241df8a3bb8a /Source/CTest | |
parent | 00530d74d5d07a320c998d6caccc00cf4e59b06d (diff) | |
download | CMake-7b81d8c21e0a0d8756f0afdc0530c2d06ee3bcd4.zip CMake-7b81d8c21e0a0d8756f0afdc0530c2d06ee3bcd4.tar.gz CMake-7b81d8c21e0a0d8756f0afdc0530c2d06ee3bcd4.tar.bz2 |
TestGenerator: Record support file and line where test was added
Add internal test properties that ctest can use to report where
the test was added in CMake code.
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 26 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.h | 3 |
2 files changed, 29 insertions, 0 deletions
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 2e1bb0a..9fd2299 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -2147,6 +2147,32 @@ bool cmCTestTestHandler::SetTestsProperties( for (std::string const& t : tests) { for (cmCTestTestProperties& rt : this->TestList) { if (t == rt.Name) { + if (key == "_BACKTRACE_TRIPLES") { + std::vector<std::string> triples; + // allow empty args in the triples + cmSystemTools::ExpandListArgument(val, triples, true); + + // Ensure we have complete triples otherwise the data is corrupt. + if (triples.size() % 3 == 0) { + cmState state; + rt.Backtrace = cmListFileBacktrace(state.CreateBaseSnapshot()); + + // the first entry represents the top of the trace so we need to + // reconstruct the backtrace in reverse + for (size_t i = triples.size(); i >= 3; i -= 3) { + cmListFileContext fc; + fc.FilePath = triples[i - 3]; + long line = 0; + if (!cmSystemTools::StringToLong(triples[i - 2].c_str(), + &line)) { + line = 0; + } + fc.Line = line; + fc.Name = triples[i - 1]; + rt.Backtrace = rt.Backtrace.Push(fc); + } + } + } if (key == "WILL_FAIL") { rt.WillFail = cmSystemTools::IsOn(val); } diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index bcacf23..0b557db 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -7,6 +7,7 @@ #include "cmCTestGenericHandler.h" #include "cmDuration.h" +#include "cmListFileCache.h" #include "cmsys/RegularExpression.hxx" #include <chrono> @@ -141,6 +142,8 @@ public: std::set<std::string> FixturesCleanup; std::set<std::string> FixturesRequired; std::set<std::string> RequireSuccessDepends; + // Private test generator properties used to track backtraces + cmListFileBacktrace Backtrace; }; struct cmCTestTestResult |