Skip to content

Commit c1ac482

Browse files
authored
Merge pull request #659 from fy666/master
Parse test execution time in unity fixture output
2 parents b706271 + 84461ba commit c1ac482

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

auto/parse_output.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,41 +138,44 @@ def prepare_fixture_line(line)
138138
def test_passed_unity_fixture(array)
139139
class_name = array[0]
140140
test_name = array[1]
141+
test_time = get_test_time(array[array.length - 1])
141142
test_suite_verify(class_name)
142-
printf "%-40s PASS\n", test_name
143+
printf "%-40s PASS %10d ms\n", test_name, test_time
143144

144-
push_xml_output_passed(test_name) if @xml_out
145+
push_xml_output_passed(test_name, test_time) if @xml_out
145146
end
146147

147148
# Test was flagged as having failed so format the output.
148149
# This is using the Unity fixture output and not the original Unity output.
149150
def test_failed_unity_fixture(array)
150151
class_name = array[0]
151152
test_name = array[1]
153+
test_time = get_test_time(array[array.length - 1])
152154
test_suite_verify(class_name)
153155
reason_array = array[2].split(':')
154156
reason = "#{reason_array[-1].lstrip.chomp} at line: #{reason_array[-4]}"
155157

156-
printf "%-40s FAILED\n", test_name
158+
printf "%-40s FAILED %10d ms\n", test_name, test_time
157159

158-
push_xml_output_failed(test_name, reason) if @xml_out
160+
push_xml_output_failed(test_name, reason, test_time) if @xml_out
159161
end
160162

161163
# Test was flagged as being ignored so format the output.
162164
# This is using the Unity fixture output and not the original Unity output.
163165
def test_ignored_unity_fixture(array)
164166
class_name = array[0]
165167
test_name = array[1]
168+
test_time = get_test_time(array[array.length - 1])
166169
reason = 'No reason given'
167170
if array.size > 2
168171
reason_array = array[2].split(':')
169172
tmp_reason = reason_array[-1].lstrip.chomp
170173
reason = tmp_reason == 'IGNORE' ? 'No reason given' : tmp_reason
171174
end
172175
test_suite_verify(class_name)
173-
printf "%-40s IGNORED\n", test_name
176+
printf "%-40s IGNORED %10d ms\n", test_name, test_time
174177

175-
push_xml_output_ignored(test_name, reason) if @xml_out
178+
push_xml_output_ignored(test_name, reason, test_time) if @xml_out
176179
end
177180

178181
# Test was flagged as having passed so format the output

extras/fixture/src/unity_fixture.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ void UnityIgnoreTest(const char* printableName, const char* group, const char* n
131131
if (UnityFixture.Verbose)
132132
{
133133
UnityPrint(printableName);
134+
UNITY_EXEC_TIME_START();
135+
UNITY_EXEC_TIME_STOP();
136+
UNITY_PRINT_EXEC_TIME();
134137
UNITY_PRINT_EOL();
135138
}
136139
else if (UnityFixture.Silent)
@@ -323,6 +326,8 @@ void UnityConcludeFixtureTest(void)
323326
if (Unity.CurrentTestIgnored)
324327
{
325328
Unity.TestIgnores++;
329+
UNITY_EXEC_TIME_STOP();
330+
UNITY_PRINT_EXEC_TIME();
326331
UNITY_PRINT_EOL();
327332
}
328333
else if (!Unity.CurrentTestFailed)
@@ -339,6 +344,8 @@ void UnityConcludeFixtureTest(void)
339344
else /* Unity.CurrentTestFailed */
340345
{
341346
Unity.TestFailures++;
347+
UNITY_EXEC_TIME_STOP();
348+
UNITY_PRINT_EXEC_TIME();
342349
UNITY_PRINT_EOL();
343350
}
344351

0 commit comments

Comments
 (0)