From 1f422b586ac57ca4b409aa5ecc92000a40a06835 Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Wed, 1 Mar 2017 09:23:18 +0100 Subject: [PATCH] Squashed 'tests/unity/' changes from 1782bab..2988e98 2988e98 Merge pull request #262 from codehearts/patch-2 1732698 Fixed incorrect TEST_PROTECT explanation in readme 3817375 Merge pull request #260 from jeremyhannon/parseUnityFixtureOutputToJUnitFormat 9d5159f Merge pull request #261 from codehearts/patch-1 65ce727 Fixed typo for TEST_PROTECT in readme 4dc04d3 Enhance parseOutput.rb to support Unity fixture output git-subtree-dir: tests/unity git-subtree-split: 2988e980fbc2252fa4290b608517d4ae25cd9a46 --- README.md | 4 ++-- auto/parseOutput.rb | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fef275c..11759c8 100644 --- a/README.md +++ b/README.md @@ -41,13 +41,13 @@ Example: main() { - if (TEST_PROTECT() == 0) + if (TEST_PROTECT()) { MyTest(); } } -If MyTest calls `TEST_ABORT`, program control will immediately return to `TEST_PROTECT` with a non-zero return value. +If MyTest calls `TEST_ABORT`, program control will immediately return to `TEST_PROTECT` with a return value of zero. Unity Assertion Summary 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