diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 0eedb7d78880c1b566e3a65c157a987dafb13f56..b984960af7dabd9a1721522d1716556d0dc93228 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -266,8 +266,8 @@ class UnityTestRunnerGenerator output.puts("int main(void)") output.puts("{") output.puts(" suite_setup();") unless @options[:suite_setup].nil? - output.puts(" Unity.TestFile = \"#{filename}\";") output.puts(" UnityBegin();") + output.puts(" Unity.TestFile = \"#{filename}\";") if (@options[:use_param_tests]) tests.each do |test| if ((test[:args].nil?) or (test[:args].empty?)) diff --git a/src/unity.c b/src/unity.c index 392625e07627b8d11c78957504c8d5e71236ee5b..3a6e290966dc874294cf8c5876345e776c78e615 100644 --- a/src/unity.c +++ b/src/unity.c @@ -14,7 +14,7 @@ #define UNITY_SKIP_EXECUTION { if ((Unity.CurrentTestFailed != 0) || (Unity.CurrentTestIgnored != 0)) {return;} } #define UNITY_PRINT_EOL { UNITY_OUTPUT_CHAR('\n'); } -struct _Unity Unity = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , {{{ 0 }}} }; +struct _Unity Unity; const char* UnityStrNull = "NULL"; const char* UnityStrSpacer = ". "; @@ -1115,6 +1115,9 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int //----------------------------------------------- void UnityBegin(void) { + Unity.TestFile = NULL; + Unity.CurrentTestName = NULL; + Unity.CurrentTestLineNumber = 0; Unity.NumberOfTests = 0; Unity.TestFailures = 0; Unity.TestIgnores = 0; diff --git a/test/expectdata/testsample_cmd.c b/test/expectdata/testsample_cmd.c index d426dde4ba47212e919c1ec0222d0f36fe95578c..ffcd895e7b99e5ad5efbc70fdd7a6f7776915e23 100644 --- a/test/expectdata/testsample_cmd.c +++ b/test/expectdata/testsample_cmd.c @@ -48,8 +48,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/testsample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_def.c b/test/expectdata/testsample_def.c index 8cdedde712a010c0209e74bcc4bff8ce1f7eecfb..e2c9c6888f7a9b77c9339df665efd03961aa9714 100644 --- a/test/expectdata/testsample_def.c +++ b/test/expectdata/testsample_def.c @@ -44,8 +44,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/testsample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_mock_cmd.c b/test/expectdata/testsample_mock_cmd.c index c62c3b5e6ff758619f5b5aa8e7c1e34209940fba..6acb53261376147010e9b2e35ab47877cb7df8fa 100644 --- a/test/expectdata/testsample_mock_cmd.c +++ b/test/expectdata/testsample_mock_cmd.c @@ -69,8 +69,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/mocksample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_mock_def.c b/test/expectdata/testsample_mock_def.c index e971179443f650066f1c152a685306fda78f4b64..965f26fc03a0207867bdbe183e3e6530be8cb706 100644 --- a/test/expectdata/testsample_mock_def.c +++ b/test/expectdata/testsample_mock_def.c @@ -65,8 +65,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/mocksample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_mock_new1.c b/test/expectdata/testsample_mock_new1.c index 070927aaf31fcaf39734c02743c52fff45175a54..041499e417c623208cbf0f015921b0324b36b824 100644 --- a/test/expectdata/testsample_mock_new1.c +++ b/test/expectdata/testsample_mock_new1.c @@ -78,8 +78,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/mocksample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_mock_new2.c b/test/expectdata/testsample_mock_new2.c index 6d786bae2f0051c07239697bb9aa884e7c6e72f7..56155c09b1807b04f06122e97c99656ffa414f0b 100644 --- a/test/expectdata/testsample_mock_new2.c +++ b/test/expectdata/testsample_mock_new2.c @@ -78,8 +78,8 @@ void resetTest() int main(void) { suite_setup(); - Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/mocksample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_mock_param.c b/test/expectdata/testsample_mock_param.c index 39f6c9184b76abf01625aa3d88da1f7fa72f4d91..bb445ace676af7dd0ae8c9802610e9ae69f3c61d 100644 --- a/test/expectdata/testsample_mock_param.c +++ b/test/expectdata/testsample_mock_param.c @@ -66,8 +66,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/mocksample.c"; RUN_TEST(test_TheFirstThingToTest, 21, RUN_TEST_NO_ARGS); RUN_TEST(test_TheSecondThingToTest, 43, RUN_TEST_NO_ARGS); diff --git a/test/expectdata/testsample_mock_run1.c b/test/expectdata/testsample_mock_run1.c index 070927aaf31fcaf39734c02743c52fff45175a54..041499e417c623208cbf0f015921b0324b36b824 100644 --- a/test/expectdata/testsample_mock_run1.c +++ b/test/expectdata/testsample_mock_run1.c @@ -78,8 +78,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/mocksample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_mock_run2.c b/test/expectdata/testsample_mock_run2.c index 6d786bae2f0051c07239697bb9aa884e7c6e72f7..56155c09b1807b04f06122e97c99656ffa414f0b 100644 --- a/test/expectdata/testsample_mock_run2.c +++ b/test/expectdata/testsample_mock_run2.c @@ -78,8 +78,8 @@ void resetTest() int main(void) { suite_setup(); - Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/mocksample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_mock_yaml.c b/test/expectdata/testsample_mock_yaml.c index cf680fde1d893a639c5e7c8cf2b1445bf111e53f..32262f709e16a11da173aaae4f2781f4fae0fe61 100644 --- a/test/expectdata/testsample_mock_yaml.c +++ b/test/expectdata/testsample_mock_yaml.c @@ -79,8 +79,8 @@ void resetTest() int main(void) { suite_setup(); - Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/mocksample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_new1.c b/test/expectdata/testsample_new1.c index 56b148bb710a582f2efe145c430d040d1b6c68d9..bc726e545e343cb5335174255786810b631d8b85 100644 --- a/test/expectdata/testsample_new1.c +++ b/test/expectdata/testsample_new1.c @@ -54,8 +54,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/testsample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_new2.c b/test/expectdata/testsample_new2.c index be591b3edab3668f79576b76fbc2fabe5e0c1cdf..884af51bb6c3d38defdcf91010883401d55f41b5 100644 --- a/test/expectdata/testsample_new2.c +++ b/test/expectdata/testsample_new2.c @@ -57,8 +57,8 @@ void resetTest() int main(void) { suite_setup(); - Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/testsample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_param.c b/test/expectdata/testsample_param.c index df4a69304c0bc53d8f0e2c18cb9141f885a9c0fc..b287401360c4d749e0fb0d3356d335ab69d4947c 100644 --- a/test/expectdata/testsample_param.c +++ b/test/expectdata/testsample_param.c @@ -45,8 +45,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/testsample.c"; RUN_TEST(test_TheFirstThingToTest, 21, RUN_TEST_NO_ARGS); RUN_TEST(test_TheSecondThingToTest, 43, RUN_TEST_NO_ARGS); diff --git a/test/expectdata/testsample_run1.c b/test/expectdata/testsample_run1.c index 56b148bb710a582f2efe145c430d040d1b6c68d9..bc726e545e343cb5335174255786810b631d8b85 100644 --- a/test/expectdata/testsample_run1.c +++ b/test/expectdata/testsample_run1.c @@ -54,8 +54,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/testsample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_run2.c b/test/expectdata/testsample_run2.c index be591b3edab3668f79576b76fbc2fabe5e0c1cdf..884af51bb6c3d38defdcf91010883401d55f41b5 100644 --- a/test/expectdata/testsample_run2.c +++ b/test/expectdata/testsample_run2.c @@ -57,8 +57,8 @@ void resetTest() int main(void) { suite_setup(); - Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/testsample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_yaml.c b/test/expectdata/testsample_yaml.c index 9198105a24c1fdab9b65d7bcd7c1ba86a3e7a56f..75882a649518f982594b243f1a364867ec8216a6 100644 --- a/test/expectdata/testsample_yaml.c +++ b/test/expectdata/testsample_yaml.c @@ -58,8 +58,8 @@ void resetTest() int main(void) { suite_setup(); - Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/testsample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43);