From 4dc04d39776b266aaebe372a2144db076cfdc62a Mon Sep 17 00:00:00 2001 From: Jeremy Hannon Date: Tue, 7 Feb 2017 10:38:49 -0600 Subject: [PATCH] Enhance parseOutput.rb to support Unity fixture output unity.h and unity_fixture.h output their results in different string formats. This parseOutput.rb script already parsed the unity.h output to generate a JUnit-style XML summary which could be parsed by CI servers to graph the history of test pass/fail results. The changes in this commit allow the script to also handle the output format of unity_fixture.h which utilizes groups to add a layer of organization for tests. The changes in this commit were authored by Justin Seifi, my coworker, who has approved of me submitting his work back to this open source framework repo. --- auto/parseOutput.rb | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/auto/parseOutput.rb b/auto/parseOutput.rb index 7ea180f..e8dbf08 100644 --- a/auto/parseOutput.rb +++ b/auto/parseOutput.rb @@ -65,6 +65,17 @@ class ParseOutput @arrayList.push " " end end + +# Test was flagged as having passed so format the output. +# This is using the Unity fixture output and not the original Unity output. + def testPassedUnityFixture(array) + testSuite = array[0].sub("TEST(", "") + testSuite = testSuite.sub(",", "") + testName = array[1].sub(")", "") + if @xmlOut == true + @arrayList.push " " + end + end # Test was flagged as being ingored so format the output def testIgnored(array) @@ -73,6 +84,14 @@ class ParseOutput reason = array[lastItem].chomp testSuiteVerify(array[@className]) printf "%-40s IGNORED\n", testName + + if testName.start_with? "TEST(" + array2 = testName.split(" ") + @testSuite = array2[0].sub("TEST(", "") + @testSuite = @testSuite.sub(",", "") + testName = array2[1].sub(")", "") + end + if @xmlOut == true @arrayList.push " " @arrayList.push " " + reason + " " @@ -87,6 +106,14 @@ class ParseOutput reason = array[lastItem].chomp + " at line: " + array[lastItem - 3] testSuiteVerify(array[@className]) printf "%-40s FAILED\n", testName + + if testName.start_with? "TEST(" + array2 = testName.split(" ") + @testSuite = array2[0].sub("TEST(", "") + @testSuite = @testSuite.sub(",", "") + testName = array2[1].sub(")", "") + end + if @xmlOut == true @arrayList.push " " @arrayList.push " " + reason + " " @@ -138,7 +165,7 @@ class ParseOutput lineSize = lineArray.size # If we were able to split the line then we can look to see if any of our target words # were found. Case is important. - if lineSize >= 4 + if ((lineSize >= 4) || (line.start_with? "TEST(")) # Determine if this test passed if line.include? ":PASS" testPassed(lineArray) @@ -149,6 +176,12 @@ class ParseOutput elsif line.include? ":IGNORE:" testIgnored(lineArray) testIgnore += 1 + elsif line.start_with? "TEST(" + if line.include? " PASS" + lineArray = line.split(" ") + testPassedUnityFixture(lineArray) + testPass += 1 + end # If none of the keywords are found there are no more tests for this suite so clear # the test flag else