From 7dbfc4be56f006954f7cc440e2f542b22d004ff6 Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Tue, 2 Jul 2019 19:57:55 -0700 Subject: [PATCH 1/8] Adding root meson.build file. --- meson.build | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 meson.build diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..0c6a344 --- /dev/null +++ b/meson.build @@ -0,0 +1,79 @@ +################################################################################### +# # +# NAME: meson.build # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### + + + +project('unity', 'c', + license : 'MIT', + meson_version : '>=0.50.0', + default_options : + [ + 'werror=true', + 'optimization=3', + 'warning_level=3', + 'b_sanitize=address,undefined', + 'b_lto=true', + 'b_lundef=true' + ]) +cc = meson.get_compiler('c') +args_for_langs = 'c' + +if cc.get_id() == 'clang' + add_project_arguments( + '-Wweak-vtables', + '-Wexit-time-destructors', + '-Wglobal-constructors', + '-Wmissing-noreturn', language: args_for_langs) +endif + +if cc.get_argument_syntax() == 'gcc' + add_project_arguments( + '-Wall', + '-Wextra', + '-Wunreachable-code', + '-Wmissing-declarations', + '-Wmissing-prototypes', + '-Wredundant-decls', + '-Wundef', + '-Wwrite-strings', + '-Wformat', + '-Wformat-nonliteral', + '-Wformat-security', + '-Wold-style-definition', + '-Winit-self', + '-Wmissing-include-dirs', + '-Waddress', + '-Waggregate-return', + '-Wno-multichar', + '-Wdeclaration-after-statement', + '-Wvla', + '-Wpointer-arith',language: args_for_langs) +endif + +if cc.get_id() == 'msvc' + add_project_arguments( + '/W4', + '/w44265', + '/w44061', + '/w44062', + '/wd4018', # implicit signed/unsigned conversion + '/wd4146', # unary minus on unsigned (beware INT_MIN) + '/wd4244', # lossy type conversion (e.g. double -> int) + '/wd4305', # truncating type conversion (e.g. double -> float) + mesno.get_supported_arguments(['/utf-8']), language: args_for_langs) +endif + +subdir('src') + +unity_dep = declare_dependency( + version: meson.project_version(), + link_with: unity_lib, + include_directories: unity_dir) From bd4d35ddd0755d7214fa7a8df53a8b7ce9ccaea6 Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Tue, 2 Jul 2019 19:58:16 -0700 Subject: [PATCH 2/8] Added meson.build in src directory. --- src/meson.build | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/meson.build diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..5d8c452 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,20 @@ +################################################################################### +# # +# NAME: src/meson.build # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### + + + +unity_src = files('unity.c') + +unity_dir = include_directories('.') + +unity_lib = library(meson.project_name(), + sources: unity_src, + include_directories: unity_dir) \ No newline at end of file From ab9f8d0959969dcc06216d801ae98bc10e71f394 Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Wed, 3 Jul 2019 15:30:50 -0700 Subject: [PATCH 3/8] Added example 4 in examples directory. --- examples/example_4/meson.build | 17 +++++ examples/example_4/readme.txt | 5 ++ examples/example_4/src/ProductionCode.c | 24 +++++++ examples/example_4/src/ProductionCode.h | 3 + examples/example_4/src/ProductionCode2.c | 11 ++++ examples/example_4/src/ProductionCode2.h | 2 + examples/example_4/src/meson.build | 23 +++++++ examples/example_4/test/TestProductionCode.c | 62 +++++++++++++++++++ examples/example_4/test/TestProductionCode2.c | 31 ++++++++++ examples/example_4/test/meson.build | 14 +++++ .../test_runners/TestProductionCode2_Runner.c | 53 ++++++++++++++++ .../test_runners/TestProductionCode_Runner.c | 57 +++++++++++++++++ .../example_4/test/test_runners/meson.build | 24 +++++++ examples/meson.build | 14 +++++ meson_options.txt | 17 +++++ 15 files changed, 357 insertions(+) create mode 100644 examples/example_4/meson.build create mode 100644 examples/example_4/readme.txt create mode 100644 examples/example_4/src/ProductionCode.c create mode 100644 examples/example_4/src/ProductionCode.h create mode 100644 examples/example_4/src/ProductionCode2.c create mode 100644 examples/example_4/src/ProductionCode2.h create mode 100644 examples/example_4/src/meson.build create mode 100644 examples/example_4/test/TestProductionCode.c create mode 100644 examples/example_4/test/TestProductionCode2.c create mode 100644 examples/example_4/test/meson.build create mode 100644 examples/example_4/test/test_runners/TestProductionCode2_Runner.c create mode 100644 examples/example_4/test/test_runners/TestProductionCode_Runner.c create mode 100644 examples/example_4/test/test_runners/meson.build create mode 100644 examples/meson.build create mode 100755 meson_options.txt diff --git a/examples/example_4/meson.build b/examples/example_4/meson.build new file mode 100644 index 0000000..5e34a33 --- /dev/null +++ b/examples/example_4/meson.build @@ -0,0 +1,17 @@ +################################################################################### +# # +# NAME: examples/example_4/meson.build # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### + + + +example_dir = include_directories('.', join_paths('.', 'src')) + +subdir('src') +subdir('test') \ No newline at end of file diff --git a/examples/example_4/readme.txt b/examples/example_4/readme.txt new file mode 100644 index 0000000..dfed815 --- /dev/null +++ b/examples/example_4/readme.txt @@ -0,0 +1,5 @@ +Example 1 +========= + +Close to the simplest possible example of Unity, using only basic features. +Run make to build & run the example tests. \ No newline at end of file diff --git a/examples/example_4/src/ProductionCode.c b/examples/example_4/src/ProductionCode.c new file mode 100644 index 0000000..db128e5 --- /dev/null +++ b/examples/example_4/src/ProductionCode.c @@ -0,0 +1,24 @@ + +#include "ProductionCode.h" + +int Counter = 0; +int NumbersToFind[9] = { 0, 34, 55, 66, 32, 11, 1, 77, 888 }; /* some obnoxious array to search that is 1-based indexing instead of 0. */ + +/* This function is supposed to search through NumbersToFind and find a particular number. + * If it finds it, the index is returned. Otherwise 0 is returned which sorta makes sense since + * NumbersToFind is indexed from 1. Unfortunately it's broken + * (and should therefore be caught by our tests) */ +int FindFunction_WhichIsBroken(int NumberToFind) +{ + int i = 0; + while (i < 8) /* Notice I should have been in braces */ + i++; + if (NumbersToFind[i] == NumberToFind) /* Yikes! I'm getting run after the loop finishes instead of during it! */ + return i; + return 0; +} + +int FunctionWhichReturnsLocalVariable(void) +{ + return Counter; +} diff --git a/examples/example_4/src/ProductionCode.h b/examples/example_4/src/ProductionCode.h new file mode 100644 index 0000000..250ca0d --- /dev/null +++ b/examples/example_4/src/ProductionCode.h @@ -0,0 +1,3 @@ + +int FindFunction_WhichIsBroken(int NumberToFind); +int FunctionWhichReturnsLocalVariable(void); diff --git a/examples/example_4/src/ProductionCode2.c b/examples/example_4/src/ProductionCode2.c new file mode 100644 index 0000000..98ee7ee --- /dev/null +++ b/examples/example_4/src/ProductionCode2.c @@ -0,0 +1,11 @@ + +#include "ProductionCode2.h" + +char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction) +{ + (void)Poor; + (void)LittleFunction; + /* Since There Are No Tests Yet, This Function Could Be Empty For All We Know. + * Which isn't terribly useful... but at least we put in a TEST_IGNORE so we won't forget */ + return (char*)0; +} diff --git a/examples/example_4/src/ProductionCode2.h b/examples/example_4/src/ProductionCode2.h new file mode 100644 index 0000000..34ae980 --- /dev/null +++ b/examples/example_4/src/ProductionCode2.h @@ -0,0 +1,2 @@ + +char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction); diff --git a/examples/example_4/src/meson.build b/examples/example_4/src/meson.build new file mode 100644 index 0000000..77c3919 --- /dev/null +++ b/examples/example_4/src/meson.build @@ -0,0 +1,23 @@ +################################################################################### +# # +# NAME: examples/example_4/src/meson.build # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### + + + +example_src = files('ProductionCode.c', 'ProductionCode2.c') + +example_lib = library(meson.project_name(), + sources: example_src, + include_directories: example_dir) + +example_dep = declare_dependency( + version: meson.project_version(), + link_with: example_lib, + include_directories: example_dir) \ No newline at end of file diff --git a/examples/example_4/test/TestProductionCode.c b/examples/example_4/test/TestProductionCode.c new file mode 100644 index 0000000..404c371 --- /dev/null +++ b/examples/example_4/test/TestProductionCode.c @@ -0,0 +1,62 @@ + +#include "ProductionCode.h" +#include "unity.h" + +/* sometimes you may want to get at local data in a module. + * for example: If you plan to pass by reference, this could be useful + * however, it should often be avoided */ +extern int Counter; + +void setUp(void) +{ + /* This is run before EACH TEST */ + Counter = 0x5a5a; +} + +void tearDown(void) +{ +} + +void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void) +{ + /* All of these should pass */ + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(78)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(2)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(33)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(999)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(-1)); +} + +void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void) +{ + /* You should see this line fail in your test summary */ + TEST_ASSERT_EQUAL(1, FindFunction_WhichIsBroken(34)); + + /* Notice the rest of these didn't get a chance to run because the line above failed. + * Unit tests abort each test function on the first sign of trouble. + * Then NEXT test function runs as normal. */ + TEST_ASSERT_EQUAL(8, FindFunction_WhichIsBroken(8888)); +} + +void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void) +{ + /* This should be true because setUp set this up for us before this test */ + TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable()); + + /* This should be true because we can still change our answer */ + Counter = 0x1234; + TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable()); +} + +void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void) +{ + /* This should be true again because setup was rerun before this test (and after we changed it to 0x1234) */ + TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable()); +} + +void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void) +{ + /* Sometimes you get the test wrong. When that happens, you get a failure too... and a quick look should tell + * you what actually happened...which in this case was a failure to setup the initial condition. */ + TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable()); +} diff --git a/examples/example_4/test/TestProductionCode2.c b/examples/example_4/test/TestProductionCode2.c new file mode 100644 index 0000000..7d940c1 --- /dev/null +++ b/examples/example_4/test/TestProductionCode2.c @@ -0,0 +1,31 @@ + +#include "ProductionCode2.h" +#include "unity.h" + +/* These should be ignored because they are commented out in various ways: +#include "whatever.h" +#include "somethingelse.h" +*/ + +void setUp(void) +{ +} + +void tearDown(void) +{ +} + +void test_IgnoredTest(void) +{ + TEST_IGNORE_MESSAGE("This Test Was Ignored On Purpose"); +} + +void test_AnotherIgnoredTest(void) +{ + TEST_IGNORE_MESSAGE("These Can Be Useful For Leaving Yourself Notes On What You Need To Do Yet"); +} + +void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void) +{ + TEST_IGNORE(); /* Like This */ +} diff --git a/examples/example_4/test/meson.build b/examples/example_4/test/meson.build new file mode 100644 index 0000000..d551df9 --- /dev/null +++ b/examples/example_4/test/meson.build @@ -0,0 +1,14 @@ +################################################################################### +# # +# NAME: examples/example_4/test/meson.build # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### + + + +subdir('test_runners') \ No newline at end of file diff --git a/examples/example_4/test/test_runners/TestProductionCode2_Runner.c b/examples/example_4/test/test_runners/TestProductionCode2_Runner.c new file mode 100644 index 0000000..cf72c21 --- /dev/null +++ b/examples/example_4/test/test_runners/TestProductionCode2_Runner.c @@ -0,0 +1,53 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +/*=======Test Runner Used To Run Each Test Below=====*/ +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(); \ + } \ + if (TEST_PROTECT()) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +/*=======Automagically Detected Files To Include=====*/ +#include "unity.h" +#include +#include +#include "ProductionCode2.h" + +/*=======External Functions This Runner Calls=====*/ +extern void setUp(void); +extern void tearDown(void); +extern void test_IgnoredTest(void); +extern void test_AnotherIgnoredTest(void); +extern void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void); + + +/*=======Test Reset Option=====*/ +void resetTest(void); +void resetTest(void) +{ + tearDown(); + setUp(); +} + + +/*=======MAIN=====*/ +int main(void) +{ + UnityBegin("test/TestProductionCode2.c"); + RUN_TEST(test_IgnoredTest, 18); + RUN_TEST(test_AnotherIgnoredTest, 23); + RUN_TEST(test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented, 28); + + return (UnityEnd()); +} diff --git a/examples/example_4/test/test_runners/TestProductionCode_Runner.c b/examples/example_4/test/test_runners/TestProductionCode_Runner.c new file mode 100644 index 0000000..3b49af7 --- /dev/null +++ b/examples/example_4/test/test_runners/TestProductionCode_Runner.c @@ -0,0 +1,57 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +/*=======Test Runner Used To Run Each Test Below=====*/ +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(); \ + } \ + if (TEST_PROTECT()) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +/*=======Automagically Detected Files To Include=====*/ +#include "unity.h" +#include +#include +#include "ProductionCode.h" + +/*=======External Functions This Runner Calls=====*/ +extern void setUp(void); +extern void tearDown(void); +extern void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void); +extern void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void); +extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void); +extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void); +extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void); + + +/*=======Test Reset Option=====*/ +void resetTest(void); +void resetTest(void) +{ + tearDown(); + setUp(); +} + + +/*=======MAIN=====*/ +int main(void) +{ + UnityBegin("test/TestProductionCode.c"); + RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode, 20); + RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken, 30); + RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue, 41); + RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain, 51); + RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed, 57); + + return (UnityEnd()); +} diff --git a/examples/example_4/test/test_runners/meson.build b/examples/example_4/test/test_runners/meson.build new file mode 100644 index 0000000..edf35bb --- /dev/null +++ b/examples/example_4/test/test_runners/meson.build @@ -0,0 +1,24 @@ +################################################################################### +# # +# NAME: examples/example_4/test/test_runners/meson.build # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### + + + +test_src_1 = [ + 'TestProductionCode_Runner.c', + join_paths('..' ,'TestProductionCode.c') + ] +test_src_2 = [ + 'TestProductionCode2_Runner.c', + join_paths('..' ,'TestProductionCode2.c') + ] + +test('Test production code one', executable('test-1', test_src_1, dependencies: [ example_dep, unity_dep ])) +test('Test production code two', executable('test-2', test_src_2, dependencies: [ example_dep, unity_dep ])) \ No newline at end of file diff --git a/examples/meson.build b/examples/meson.build new file mode 100644 index 0000000..df0e7fe --- /dev/null +++ b/examples/meson.build @@ -0,0 +1,14 @@ +################################################################################### +# # +# NAME: examples/meson.build # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### + + + +subdir('example_4') \ No newline at end of file diff --git a/meson_options.txt b/meson_options.txt new file mode 100755 index 0000000..89f43a0 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,17 @@ +################################################################################### +# # +# NAME: meson_options.txt # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### + + + +option('with_examples', + type: 'feature', value : 'disabled', + description: 'Enable Unity for unit testing.' +) \ No newline at end of file From b1fd5ad887cebf96b61c2feb9e144c79168a085d Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Wed, 3 Jul 2019 15:31:26 -0700 Subject: [PATCH 4/8] Added option with_examples and version info. --- meson.build | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/meson.build b/meson.build index 0c6a344..68f081b 100644 --- a/meson.build +++ b/meson.build @@ -12,6 +12,7 @@ project('unity', 'c', + version : '2.4.3', license : 'MIT', meson_version : '>=0.50.0', default_options : @@ -77,3 +78,8 @@ unity_dep = declare_dependency( version: meson.project_version(), link_with: unity_lib, include_directories: unity_dir) + + +if get_option('with_examples').enabled() + subdir('examples') +endif \ No newline at end of file From e89b281e433cab49f67d73a4514258acb3d00801 Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Wed, 3 Jul 2019 15:54:19 -0700 Subject: [PATCH 5/8] Wrote info in readme.txt --- examples/example_4/readme.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/example_4/readme.txt b/examples/example_4/readme.txt index dfed815..790a6fb 100644 --- a/examples/example_4/readme.txt +++ b/examples/example_4/readme.txt @@ -1,5 +1,14 @@ -Example 1 +Example 4 ========= Close to the simplest possible example of Unity, using only basic features. -Run make to build & run the example tests. \ No newline at end of file +to build this example run meson setup . + +Meson uses the Ninja build system to actually build the code. To start the +build, simply type the following command. + +"ninja -C " + +Meson provides native support for running tests. The command to do that is simple. + +"meson test -C ". \ No newline at end of file From c7185b3a5a000b9ed1d1b574357d2e263246f5e0 Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Wed, 3 Jul 2019 15:55:19 -0700 Subject: [PATCH 6/8] Added prototypes to stop errors when Ninja. --- examples/example_4/test/TestProductionCode.c | 6 ++++++ examples/example_4/test/TestProductionCode2.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/examples/example_4/test/TestProductionCode.c b/examples/example_4/test/TestProductionCode.c index 404c371..b6c00ae 100644 --- a/examples/example_4/test/TestProductionCode.c +++ b/examples/example_4/test/TestProductionCode.c @@ -17,6 +17,12 @@ void tearDown(void) { } +void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void); +void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void); +void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void); +void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void); +void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void); + void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void) { /* All of these should pass */ diff --git a/examples/example_4/test/TestProductionCode2.c b/examples/example_4/test/TestProductionCode2.c index 7d940c1..2578ca9 100644 --- a/examples/example_4/test/TestProductionCode2.c +++ b/examples/example_4/test/TestProductionCode2.c @@ -15,6 +15,10 @@ void tearDown(void) { } +void test_IgnoredTest(void); +void test_AnotherIgnoredTest(void); +void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void); + void test_IgnoredTest(void) { TEST_IGNORE_MESSAGE("This Test Was Ignored On Purpose"); From c10f87f1e60c19a04c4feabae3964c25837e9a9a Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Wed, 3 Jul 2019 21:03:39 -0700 Subject: [PATCH 7/8] Fixed issues regarding the example Meson project. --- examples/example_4/meson.build | 3 +++ examples/example_4/readme.txt | 5 +++-- examples/example_4/src/meson.build | 22 +++++++++++++------ examples/example_4/subprojects/unity.wrap | 4 ++++ examples/example_4/test/TestProductionCode.c | 5 ----- .../example_4/test/test_runners/meson.build | 4 ++-- examples/meson.build | 14 ------------ meson.build | 7 +----- meson_options.txt | 17 -------------- 9 files changed, 28 insertions(+), 53 deletions(-) create mode 100755 examples/example_4/subprojects/unity.wrap delete mode 100644 examples/meson.build delete mode 100755 meson_options.txt diff --git a/examples/example_4/meson.build b/examples/example_4/meson.build index 5e34a33..21d1001 100644 --- a/examples/example_4/meson.build +++ b/examples/example_4/meson.build @@ -10,6 +10,9 @@ ################################################################################### +project('example-4') + +unity_dep = dependency('unity', fallback : ['unity', 'unity_dep']) example_dir = include_directories('.', join_paths('.', 'src')) diff --git a/examples/example_4/readme.txt b/examples/example_4/readme.txt index 790a6fb..c8f45a8 100644 --- a/examples/example_4/readme.txt +++ b/examples/example_4/readme.txt @@ -2,7 +2,7 @@ Example 4 ========= Close to the simplest possible example of Unity, using only basic features. -to build this example run meson setup . +to build this example run "meson setup ". Meson uses the Ninja build system to actually build the code. To start the build, simply type the following command. @@ -11,4 +11,5 @@ build, simply type the following command. Meson provides native support for running tests. The command to do that is simple. -"meson test -C ". \ No newline at end of file +"meson test -C ". + \ No newline at end of file diff --git a/examples/example_4/src/meson.build b/examples/example_4/src/meson.build index 77c3919..5f7e5da 100644 --- a/examples/example_4/src/meson.build +++ b/examples/example_4/src/meson.build @@ -11,13 +11,21 @@ -example_src = files('ProductionCode.c', 'ProductionCode2.c') - -example_lib = library(meson.project_name(), - sources: example_src, +a_lib = library( + 'production-code-1', + 'ProductionCode.c', include_directories: example_dir) -example_dep = declare_dependency( - version: meson.project_version(), - link_with: example_lib, +b_lib = library( + 'production-code-2', + 'ProductionCode2.c', + include_directories: example_dir) + + +a_dep = declare_dependency( + link_with: a_lib, + include_directories: example_dir) + +b_dep = declare_dependency( + link_with: b_lib, include_directories: example_dir) \ No newline at end of file diff --git a/examples/example_4/subprojects/unity.wrap b/examples/example_4/subprojects/unity.wrap new file mode 100755 index 0000000..bc5b386 --- /dev/null +++ b/examples/example_4/subprojects/unity.wrap @@ -0,0 +1,4 @@ +[wrap-git] +directory = unity +url = https://github.com/squidfarts/Unity.git +revision = head diff --git a/examples/example_4/test/TestProductionCode.c b/examples/example_4/test/TestProductionCode.c index b6c00ae..526a84e 100644 --- a/examples/example_4/test/TestProductionCode.c +++ b/examples/example_4/test/TestProductionCode.c @@ -17,11 +17,6 @@ void tearDown(void) { } -void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void); -void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void); -void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void); -void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void); -void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void); void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void) { diff --git a/examples/example_4/test/test_runners/meson.build b/examples/example_4/test/test_runners/meson.build index edf35bb..005ca67 100644 --- a/examples/example_4/test/test_runners/meson.build +++ b/examples/example_4/test/test_runners/meson.build @@ -20,5 +20,5 @@ test_src_2 = [ join_paths('..' ,'TestProductionCode2.c') ] -test('Test production code one', executable('test-1', test_src_1, dependencies: [ example_dep, unity_dep ])) -test('Test production code two', executable('test-2', test_src_2, dependencies: [ example_dep, unity_dep ])) \ No newline at end of file +test('Test production code one', executable('test-1', test_src_1, dependencies: [ a_dep, unity_dep ])) +test('Test production code two', executable('test-2', test_src_2, dependencies: [ b_dep, unity_dep ])) \ No newline at end of file diff --git a/examples/meson.build b/examples/meson.build deleted file mode 100644 index df0e7fe..0000000 --- a/examples/meson.build +++ /dev/null @@ -1,14 +0,0 @@ -################################################################################### -# # -# NAME: examples/meson.build # -# # -# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # -# WRITTEN BY: Michael Brockus. # -# # -# License: MIT # -# # -################################################################################### - - - -subdir('example_4') \ No newline at end of file diff --git a/meson.build b/meson.build index 68f081b..7b9732a 100644 --- a/meson.build +++ b/meson.build @@ -77,9 +77,4 @@ subdir('src') unity_dep = declare_dependency( version: meson.project_version(), link_with: unity_lib, - include_directories: unity_dir) - - -if get_option('with_examples').enabled() - subdir('examples') -endif \ No newline at end of file + include_directories: unity_dir) \ No newline at end of file diff --git a/meson_options.txt b/meson_options.txt deleted file mode 100755 index 89f43a0..0000000 --- a/meson_options.txt +++ /dev/null @@ -1,17 +0,0 @@ -################################################################################### -# # -# NAME: meson_options.txt # -# # -# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # -# WRITTEN BY: Michael Brockus. # -# # -# License: MIT # -# # -################################################################################### - - - -option('with_examples', - type: 'feature', value : 'disabled', - description: 'Enable Unity for unit testing.' -) \ No newline at end of file From af4c20fa20c51963652471bf4ab73db9a3492ba7 Mon Sep 17 00:00:00 2001 From: Michael Brockus Date: Wed, 3 Jul 2019 21:04:07 -0700 Subject: [PATCH 8/8] Updating CMakeLists.txt. --- CMakeLists.txt | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0eddcd7..bf74cec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,13 @@ -##################################################### -# FILE NAME CMakeLists.txt # -# # -# WRITTEN BY Michael Brockus. # -# # -# PURPOSE contains CMake statements. # -# # -##################################################### +################################################################################### +# # +# NAME: CMakeLsits.txt # +# # +# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. # +# WRITTEN BY: Michael Brockus. # +# # +# License: MIT # +# # +################################################################################### cmake_minimum_required(VERSION 3.13.2.0 FATAL_ERROR) @@ -58,12 +60,9 @@ install(TARGETS "unity" EXPORT "unityConfig" ARCHIVE DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_BINDIR}" - - INCLUDES DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) + INCLUDES DESTINATION "${CMAKE_INSTALL_LIBDIR}") install(DIRECTORY src/ DESTINATION src) - install(EXPORT unityConfig DESTINATION share/unityConfig/cmake) # This makes the project importable from the build directory