reenable results summary.

support tests named spec as well.
clean up UnityBegin to make us not have to dig inside it to inject the filename.
Add UNITY_OUTPUT_START() and UNITY_OUTPUT_COMPLETE() for future use.
This commit is contained in:
Mark VanderVoord
2014-07-30 22:12:49 -04:00
parent a4a2eb787d
commit 14b074336b
5 changed files with 35 additions and 30 deletions

View File

@ -78,7 +78,7 @@ class UnityTestRunnerGenerator
lines.each_with_index do |line, index|
#find tests
if line =~ /^((?:\s*TEST_CASE\s*\(.*?\)\s*)*)\s*void\s+(test.*?)\s*\(\s*(.*)\s*\)/
if line =~ /^((?:\s*TEST_CASE\s*\(.*?\)\s*)*)\s*void\s+((?:test.*)|(?:spec.*))\s*\(\s*(.*)\s*\)/
arguments = $1
name = $2
call = $3
@ -266,8 +266,7 @@ class UnityTestRunnerGenerator
output.puts("int main(void)")
output.puts("{")
output.puts(" suite_setup();") unless @options[:suite_setup].nil?
output.puts(" UnityBegin();")
output.puts(" Unity.TestFile = \"#{filename}\";")
output.puts(" UnityBegin(\"#{filename}\");")
if (@options[:use_param_tests])
tests.each do |test|
if ((test[:args].nil?) or (test[:args].empty?))

View File

@ -1102,9 +1102,9 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int
}
//-----------------------------------------------
void UnityBegin(void)
void UnityBegin(const char* filename)
{
Unity.TestFile = NULL;
Unity.TestFile = filename;
Unity.CurrentTestName = NULL;
Unity.CurrentTestLineNumber = 0;
Unity.NumberOfTests = 0;
@ -1112,6 +1112,8 @@ void UnityBegin(void)
Unity.TestIgnores = 0;
Unity.CurrentTestFailed = 0;
Unity.CurrentTestIgnored = 0;
UNITY_OUTPUT_START();
}
//-----------------------------------------------
@ -1136,6 +1138,7 @@ int UnityEnd(void)
UnityPrintFail();
}
UNITY_PRINT_EOL;
UNITY_OUTPUT_COMPLETE();
return (int)(Unity.TestFailures);
}

View File

@ -258,20 +258,23 @@ typedef UNITY_DOUBLE_TYPE _UD;
#endif
//-------------------------------------------------------
// Output Method
// Output Method: stdout (DEFAULT)
//-------------------------------------------------------
#ifndef UNITY_OUTPUT_CHAR
//Default to using putchar, which is defined in stdio.h
#include <stdio.h>
#define UNITY_OUTPUT_CHAR(a) putchar(a)
#else
//If defined as something else, make sure we declare it here so it's ready for use
extern int UNITY_OUTPUT_CHAR(int);
#endif
#ifndef UNITY_OUTPUT_START
#define UNITY_OUTPUT_START()
#endif
#ifndef UNITY_OUTPUT_COMPLETE
#define UNITY_OUTPUT_COMPLETE()
#endif
//-------------------------------------------------------
@ -388,7 +391,7 @@ extern struct _Unity Unity;
// Test Suite Management
//-------------------------------------------------------
void UnityBegin(void);
void UnityBegin(const char* filename);
int UnityEnd(void);
void UnityConcludeTest(void);
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum);
@ -544,7 +547,7 @@ extern const char* UnityStrErr64;
#define TEST_IS_IGNORED (Unity.CurrentTestIgnored)
#ifndef UNITY_BEGIN
#define UNITY_BEGIN() {UnityBegin(); Unity.TestFile = __FILE__;}
#define UNITY_BEGIN() UnityBegin(__FILE__)
#endif
#ifndef UNITY_END

View File

@ -177,7 +177,7 @@ module RakefileHelpers
results_glob.gsub!(/\\/, '/')
results = Dir[results_glob]
summary.set_targets(results)
summary.run
report summary.run
end
def run_tests(test_files)