mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-29 22:09:00 +08:00
- revert last change until I figure out what I screwed up
git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@102 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
This commit is contained in:
@ -67,10 +67,10 @@ class UnityTestRunnerGenerator
|
|||||||
|
|
||||||
input_file.rewind
|
input_file.rewind
|
||||||
source_raw = input_file.read
|
source_raw = input_file.read
|
||||||
source_scrubbed = source_raw.gsub(/\/\/.*$/, '') # remove line comments
|
source_scrubbed = source_raw.gsub(/\/\/.*$/, '') #remove line comments
|
||||||
source_scrubbed = source_scrubbed.gsub(/\/\*.*?\*\//m, '') # remove block comments
|
source_scrubbed = source_scrubbed.gsub(/\/\*.*?\*\//m, '') #remove block comments
|
||||||
lines = source_scrubbed.split(/(^\s*\#.*$) # Treat preprocessor directives as a logical line
|
lines = source_scrubbed.split(/(^\s*\#.*$) # Treat preprocessor directives as a logical line
|
||||||
| (;|\{|\}) /x) # Match ;, {, and } as end of lines
|
| (;|\{|\}) /x) # Match ;, {, and } as end of lines
|
||||||
|
|
||||||
lines.each_with_index do |line, index|
|
lines.each_with_index do |line, index|
|
||||||
if line =~ /^\s*void\s+test(.*?)\s*\(\s*void\s*\)/
|
if line =~ /^\s*void\s+test(.*?)\s*\(\s*void\s*\)/
|
||||||
@ -193,28 +193,23 @@ class UnityTestRunnerGenerator
|
|||||||
|
|
||||||
def create_runtest(output, used_mocks)
|
def create_runtest(output, used_mocks)
|
||||||
cexception = @options[:plugins].include? :cexception
|
cexception = @options[:plugins].include? :cexception
|
||||||
va_args1 = @options[:use_param_tests] ? ', ...' : ''
|
output.puts("static void runTest(UnityTestFunction test)")
|
||||||
va_args2 = @options[:use_param_tests] ? '__VA_ARGS__' : ''
|
output.puts("{")
|
||||||
output.puts("#define TEST_RUN(TestFunc, TestLineNum#{va_args1}) \\")
|
output.puts(" if (TEST_PROTECT())")
|
||||||
output.puts("{ \\")
|
output.puts(" {")
|
||||||
output.puts(" Unity.CurrentTestName = #TestFunc; \\")
|
output.puts(" CEXCEPTION_T e;") if cexception
|
||||||
output.puts(" Unity.CurrentTestLineNumber = TestLineNum; \\")
|
output.puts(" Try {") if cexception
|
||||||
output.puts(" Unity.NumberOfTests++; \\")
|
output.puts(" CMock_Init();") unless (used_mocks.empty?)
|
||||||
output.puts(" if (TEST_PROTECT()) \\")
|
output.puts(" setUp();")
|
||||||
output.puts(" { \\")
|
output.puts(" test();")
|
||||||
output.puts(" CEXCEPTION_T e; \\") if cexception
|
output.puts(" CMock_Verify();") unless (used_mocks.empty?)
|
||||||
output.puts(" Try { \\") if cexception
|
output.puts(" } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, \"Unhandled Exception!\"); }") if cexception
|
||||||
output.puts(" CMock_Init(); \\") unless (used_mocks.empty?)
|
output.puts(" }")
|
||||||
output.puts(" setUp(); \\")
|
output.puts(" CMock_Destroy();") unless (used_mocks.empty?)
|
||||||
output.puts(" TestFunc(#{va_args2}); \\")
|
output.puts(" if (TEST_PROTECT() && !TEST_IS_IGNORED)")
|
||||||
output.puts(" CMock_Verify(); \\") unless (used_mocks.empty?)
|
output.puts(" {")
|
||||||
output.puts(" } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, \"Unhandled Exception!\"); } \\") if cexception
|
output.puts(" tearDown();")
|
||||||
output.puts(" } \\")
|
output.puts(" }")
|
||||||
output.puts(" CMock_Destroy(); \\") unless (used_mocks.empty?)
|
|
||||||
output.puts(" if (TEST_PROTECT() && !TEST_IS_IGNORED) \\")
|
|
||||||
output.puts(" { \\")
|
|
||||||
output.puts(" tearDown(); \\")
|
|
||||||
output.puts(" } \\")
|
|
||||||
output.puts("}")
|
output.puts("}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
20
src/unity.c
20
src/unity.c
@ -790,26 +790,6 @@ void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
|
|||||||
UNITY_IGNORE_AND_BAIL;
|
UNITY_IGNORE_AND_BAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------
|
|
||||||
void setUp(void);
|
|
||||||
void tearDown(void);
|
|
||||||
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum)
|
|
||||||
{
|
|
||||||
Unity.CurrentTestName = FuncName;
|
|
||||||
Unity.CurrentTestLineNumber = FuncLineNum;
|
|
||||||
Unity.NumberOfTests++;
|
|
||||||
if (TEST_PROTECT())
|
|
||||||
{
|
|
||||||
setUp();
|
|
||||||
Func();
|
|
||||||
}
|
|
||||||
if (TEST_PROTECT() && !(Unity.CurrentTestIgnored))
|
|
||||||
{
|
|
||||||
tearDown();
|
|
||||||
}
|
|
||||||
UnityConcludeTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
void UnityBegin(void)
|
void UnityBegin(void)
|
||||||
{
|
{
|
||||||
|
@ -40,9 +40,12 @@
|
|||||||
|
|
||||||
#define TEST_ABORT() {longjmp(Unity.AbortFrame, 1);}
|
#define TEST_ABORT() {longjmp(Unity.AbortFrame, 1);}
|
||||||
|
|
||||||
#ifndef RUN_TEST
|
#define RUN_TEST(func, line_num) \
|
||||||
#define RUN_TEST(func, line_num) UnityDefaultTestRun(func, #func, line_num)
|
Unity.CurrentTestName = #func; \
|
||||||
#endif
|
Unity.CurrentTestLineNumber = line_num; \
|
||||||
|
Unity.NumberOfTests++; \
|
||||||
|
runTest(func); \
|
||||||
|
UnityConcludeTest();
|
||||||
|
|
||||||
#define TEST_LINE_NUM (Unity.CurrentTestLineNumber)
|
#define TEST_LINE_NUM (Unity.CurrentTestLineNumber)
|
||||||
#define TEST_IS_IGNORED (Unity.CurrentTestIgnored)
|
#define TEST_IS_IGNORED (Unity.CurrentTestIgnored)
|
||||||
|
@ -189,7 +189,6 @@ extern struct _Unity Unity;
|
|||||||
void UnityBegin(void);
|
void UnityBegin(void);
|
||||||
int UnityEnd(void);
|
int UnityEnd(void);
|
||||||
void UnityConcludeTest(void);
|
void UnityConcludeTest(void);
|
||||||
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum);
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// Test Output
|
// Test Output
|
||||||
|
Reference in New Issue
Block a user