Skip to content

Commit fb69e19

Browse files
committed
feat: Extract the passed time from process output and set Duration in TestResult.
1 parent a1bdaba commit fb69e19

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

ImplemenationCTestTestAdapter/CTestExecutor.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Diagnostics;
66
using System.IO;
77
using System.Linq;
8+
using System.Text.RegularExpressions;
89

910
namespace ImplemenationCTestTestAdapter
1011
{
@@ -77,21 +78,16 @@ public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrame
7778

7879
process.Start();
7980
var output = process.StandardOutput.ReadToEnd();
80-
8181
var exitCode = process.ExitCode;
82+
var time = Regex.Match(output, @"Passed\s*(?<time>\S*)\s*sec");
8283

83-
// TODO: Regex to get the passed time
84-
//Test project C:/data/58481/build/working
85-
//Start 4: dynamic_libraries_dynamicLibrary_getFunction_not_working
86-
//1/1 Test #4: dynamic_libraries_dynamicLibrary_getFunction_not_working ... Passed 0.07 sec
87-
88-
//100% tests passed, 0 tests failed out of 1
89-
90-
//Total Test time (real) = 1.13 sec
84+
// TODO: In case of a failure, try to parse the fileInfo.DirectoryName/Testing/Temporary
85+
// file for failed tests and try to extract the reason for the test failure.
9186

9287
var testResult = new TestResult(test);
9388
testResult.ComputerName = Environment.MachineName;
94-
89+
testResult.Duration = TimeSpan.FromSeconds(double.Parse(time.Groups["time"].Value,
90+
System.Globalization.CultureInfo.InvariantCulture.NumberFormat));
9591
testResult.Outcome = exitCode == 0 ? TestOutcome.Passed : TestOutcome.Failed;
9692
frameworkHandle.RecordResult(testResult);
9793
}

0 commit comments

Comments
 (0)