From d460a89a040f4f0572da4f9041aa09aa27707d61 Mon Sep 17 00:00:00 2001 From: jsalling Date: Thu, 29 Dec 2016 22:13:06 -0600 Subject: [PATCH 1/4] Get example 1 to compile easily on systems without ruby --- examples/example_1/makefile | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/example_1/makefile b/examples/example_1/makefile index 01abb55..8b8fa84 100644 --- a/examples/example_1/makefile +++ b/examples/example_1/makefile @@ -29,7 +29,6 @@ C_COMPILER=gcc CFLAGS=-std=c89 CFLAGS += -Wall CFLAGS += -Wextra -CFLAGS += -Werror CFLAGS += -Wpointer-arith CFLAGS += -Wcast-align CFLAGS += -Wwrite-strings @@ -53,14 +52,17 @@ SYMBOLS=-DTEST all: clean default -default: - ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c - ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/TestProductionCode2.c test/test_runners/TestProductionCode2_Runner.c +default: $(SRC_FILES1) $(SRC_FILES2) $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1) $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES2) -o $(TARGET2) - ./$(TARGET1) + - ./$(TARGET1) ./$(TARGET2) -clean: - $(CLEANUP) +test/test_runners/TestProductionCode_Runner.c: test/TestProductionCode.c + ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c +test/test_runners/TestProductionCode2_Runner.c: test/TestProductionCode2.c + ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/TestProductionCode2.c test/test_runners/TestProductionCode2_Runner.c + +clean: + $(CLEANUP) $(TARGET1) $(TARGET2) From 185fb4938007bcf9701ac6fac15d8e315ec9e38c Mon Sep 17 00:00:00 2001 From: jsalling Date: Wed, 18 Jan 2017 08:13:41 -0600 Subject: [PATCH 2/4] Cleanup example Makefiles, update test runners Delete clang flags that were disabled with -Wno-* --- examples/example_1/makefile | 23 +++++++------- .../test_runners/TestProductionCode2_Runner.c | 2 +- .../test_runners/TestProductionCode_Runner.c | 2 +- examples/example_2/makefile | 30 +++++++++---------- test/targets/clang_file.yml | 6 ---- test/targets/clang_strict.yml | 6 ---- 6 files changed, 28 insertions(+), 41 deletions(-) diff --git a/examples/example_1/makefile b/examples/example_1/makefile index 8b8fa84..c5a3ca4 100644 --- a/examples/example_1/makefile +++ b/examples/example_1/makefile @@ -5,17 +5,14 @@ # ========================================== #We try to detect the OS we are running on, and adjust commands as needed -ifeq ($(OSTYPE),cygwin) - CLEANUP = rm -f - MKDIR = mkdir -p - TARGET_EXTENSION=.out -elseifeq ($(OSTYPE),msys) - CLEANUP = rm -f - MKDIR = mkdir -p - TARGET_EXTENSION=.exe -elseifeq ($(OS),Windows_NT) +ifeq ($(OS),Windows_NT) + ifeq ($(shell uname -s),) # not in a bash-like shell CLEANUP = del /F /Q MKDIR = mkdir + else # in a bash-like shell, like msys + CLEANUP = rm -f + MKDIR = mkdir -p + endif TARGET_EXTENSION=.exe else CLEANUP = rm -f @@ -23,8 +20,12 @@ else TARGET_EXTENSION=.out endif -UNITY_ROOT=../.. C_COMPILER=gcc +ifeq ($(shell uname -s), Darwin) +C_COMPILER=clang +endif + +UNITY_ROOT=../.. CFLAGS=-std=c89 CFLAGS += -Wall @@ -48,7 +49,7 @@ TARGET2 = $(TARGET_BASE2)$(TARGET_EXTENSION) SRC_FILES1=$(UNITY_ROOT)/src/unity.c src/ProductionCode.c test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c SRC_FILES2=$(UNITY_ROOT)/src/unity.c src/ProductionCode2.c test/TestProductionCode2.c test/test_runners/TestProductionCode2_Runner.c INC_DIRS=-Isrc -I$(UNITY_ROOT)/src -SYMBOLS=-DTEST +SYMBOLS= all: clean default diff --git a/examples/example_1/test/test_runners/TestProductionCode2_Runner.c b/examples/example_1/test/test_runners/TestProductionCode2_Runner.c index ebe858f..cf72c21 100644 --- a/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +++ b/examples/example_1/test/test_runners/TestProductionCode2_Runner.c @@ -11,7 +11,7 @@ setUp(); \ TestFunc(); \ } \ - if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + if (TEST_PROTECT()) \ { \ tearDown(); \ } \ diff --git a/examples/example_1/test/test_runners/TestProductionCode_Runner.c b/examples/example_1/test/test_runners/TestProductionCode_Runner.c index f15a76f..3b49af7 100644 --- a/examples/example_1/test/test_runners/TestProductionCode_Runner.c +++ b/examples/example_1/test/test_runners/TestProductionCode_Runner.c @@ -11,7 +11,7 @@ setUp(); \ TestFunc(); \ } \ - if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + if (TEST_PROTECT()) \ { \ tearDown(); \ } \ diff --git a/examples/example_2/makefile b/examples/example_2/makefile index 36d3cd7..cfde2cc 100644 --- a/examples/example_2/makefile +++ b/examples/example_2/makefile @@ -5,17 +5,14 @@ # ========================================== #We try to detect the OS we are running on, and adjust commands as needed -ifeq ($(OSTYPE),cygwin) - CLEANUP = rm -f - MKDIR = mkdir -p - TARGET_EXTENSION=.out -elseifeq ($(OSTYPE),msys) - CLEANUP = rm -f - MKDIR = mkdir -p - TARGET_EXTENSION=.exe -elseifeq ($(OS),Windows_NT) +ifeq ($(OS),Windows_NT) + ifeq ($(shell uname -s),) # not in a bash-like shell CLEANUP = del /F /Q MKDIR = mkdir + else # in a bash-like shell, like msys + CLEANUP = rm -f + MKDIR = mkdir -p + endif TARGET_EXTENSION=.exe else CLEANUP = rm -f @@ -23,13 +20,16 @@ else TARGET_EXTENSION=.out endif -UNITY_ROOT=../.. C_COMPILER=gcc +ifeq ($(shell uname -s), Darwin) +C_COMPILER=clang +endif -CFLAGS = -std=c99 +UNITY_ROOT=../.. + +CFLAGS=-std=c99 CFLAGS += -Wall CFLAGS += -Wextra -CFLAGS += -Werror CFLAGS += -Wpointer-arith CFLAGS += -Wcast-align CFLAGS += -Wwrite-strings @@ -41,8 +41,6 @@ CFLAGS += -Wno-unknown-pragmas CFLAGS += -Wstrict-prototypes CFLAGS += -Wundef CFLAGS += -Wold-style-definition -CFLAGS += -Wmissing-prototypes -CFLAGS += -Wmissing-declarations TARGET_BASE1=all_tests TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION) @@ -63,8 +61,8 @@ all: clean default default: $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1) - ./$(TARGET1) -v + - ./$(TARGET1) -v clean: - $(CLEANUP) + $(CLEANUP) $(TARGET1) diff --git a/test/targets/clang_file.yml b/test/targets/clang_file.yml index 0d38e73..df1bd24 100644 --- a/test/targets/clang_file.yml +++ b/test/targets/clang_file.yml @@ -16,13 +16,10 @@ compiler: - '-Winit-self' - '-Winline' - '-Winvalid-pch' - - '-Wmissing-declarations' - '-Wmissing-include-dirs' - - '-Wmissing-prototypes' - '-Wnonnull' - '-Wpacked' - '-Wpointer-arith' - - '-Wredundant-decls' - '-Wswitch-default' - '-Wstrict-aliasing' - '-Wstrict-overflow=5' @@ -33,10 +30,7 @@ compiler: - '-Wshadow' - '-Wundef' - '-Wwrite-strings' - - '-Wno-missing-declarations' - - '-Wno-missing-prototypes' - '-Wno-nested-externs' - - '-Wno-redundant-decls' - '-Wno-unused-parameter' - '-Wno-variadic-macros' - '-Wbad-function-cast' diff --git a/test/targets/clang_strict.yml b/test/targets/clang_strict.yml index b862266..b399d76 100644 --- a/test/targets/clang_strict.yml +++ b/test/targets/clang_strict.yml @@ -16,13 +16,10 @@ compiler: - '-Winit-self' - '-Winline' - '-Winvalid-pch' - - '-Wmissing-declarations' - '-Wmissing-include-dirs' - - '-Wmissing-prototypes' - '-Wnonnull' - '-Wpacked' - '-Wpointer-arith' - - '-Wredundant-decls' - '-Wswitch-default' - '-Wstrict-aliasing' - '-Wstrict-overflow=5' @@ -33,10 +30,7 @@ compiler: - '-Wshadow' - '-Wundef' - '-Wwrite-strings' - - '-Wno-missing-declarations' - - '-Wno-missing-prototypes' - '-Wno-nested-externs' - - '-Wno-redundant-decls' - '-Wno-unused-parameter' - '-Wno-variadic-macros' - '-Wbad-function-cast' From bb7f889f03d0148b847d4a0d85e29eeb1d561943 Mon Sep 17 00:00:00 2001 From: jsalling Date: Wed, 18 Jan 2017 08:18:37 -0600 Subject: [PATCH 3/4] Compile examples in continuous integration, update example_3 readme Altered the rake build so that it passes. The example_3 shows off some failing tests, so the rake build has to ignore those. Update .gitignore file with executables from examples --- .gitignore | 7 +++---- .travis.yml | 4 ++++ examples/example_3/rakefile_helper.rb | 4 +++- examples/example_3/readme.txt | 14 ++++---------- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index f0c7c3e..a383c3c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,9 @@ build/ test/sandbox .DS_Store +examples/example_1/test1.exe +examples/example_1/test2.exe +examples/example_2/all_tests.exe examples/example_1/test1.out examples/example_1/test2.out examples/example_2/all_tests.out -examples/example_3/test1.out -examples/example_3/test2.out -test/testparameterized.c.results -test/testunity.c.results diff --git a/.travis.yml b/.travis.yml index c9af107..b90fd42 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,10 @@ install: gem install rspec script: - cd test && rake ci - make -s + - make -s DEBUG=-m32 - cd ../extras/fixture/test && rake ci - make -s default noStdlibMalloc - make -s C89 + - cd ../../../examples/example_1 && make -s + - cd ../example_2 && make -s + - cd ../example_3 && rake \ No newline at end of file diff --git a/examples/example_3/rakefile_helper.rb b/examples/example_3/rakefile_helper.rb index 6702145..ed41d80 100644 --- a/examples/example_3/rakefile_helper.rb +++ b/examples/example_3/rakefile_helper.rb @@ -251,6 +251,8 @@ module RakefileHelpers def fail_out(msg) puts msg - exit(-1) + puts "Not returning exit code so continuous integration can pass" +# exit(-1) # Only removed to pass example_3, which has failing tests on purpose. +# Still fail if the build fails for any other reason. end end diff --git a/examples/example_3/readme.txt b/examples/example_3/readme.txt index df6fb18..7371fea 100644 --- a/examples/example_3/readme.txt +++ b/examples/example_3/readme.txt @@ -4,16 +4,10 @@ Example 3 This example project gives an example of some passing, ignored, and failing tests. It's simple and meant for you to look over and get an idea for what all of this stuff does. -You can build and test using the makefile if you have gcc installed (you may need to tweak -the locations of some tools in the makefile). Otherwise, the rake version will let you -test with gcc or a couple versions of IAR. You can tweak the yaml files to get those versions -running. +You can build and test using rake. The rake version will let you test with gcc or a couple +versions of IAR. You can tweak the yaml files to get those versions running. Ruby is required if you're using the rake version (obviously). This version shows off most of Unity's advanced features (automatically creating test runners, fancy summaries, etc.) - -The makefile version doesn't require anything outside of your normal build tools, but won't do the -extras for you. So that you can test right away, we've written the test runners for you and -put them in the test\no_ruby subdirectory. If you make changes to the tests or source, you might -need to update these (like when you add or remove tests). Do that for a while and you'll learn -why you really want to start using the Ruby tools. \ No newline at end of file +Without ruby, you have to maintain your own test runners. Do that for a while and you'll learn +why you really want to start using the Ruby tools. From e0104179ed4f9ff6d567156b63a3ac5cd0dc27ad Mon Sep 17 00:00:00 2001 From: jsalling Date: Wed, 18 Jan 2017 22:18:11 -0600 Subject: [PATCH 4/4] Fix 32-bit build issues on Travis-CI by installing multilib If, longer term, the Travis-CI support for 32-bit is inconsistent the lines that failed are: - make -s DEBUG=-m32 - cd ../example_3 && rake Add target 'ci' for building examples with -Werror --- .travis.yml | 7 ++++--- examples/example_1/makefile | 2 ++ examples/example_2/makefile | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b90fd42..edf25ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ matrix: before_install: - if [ "$TRAVIS_OS_NAME" == "osx" ]; then rvm install 2.1 && rvm use 2.1 && ruby -v; fi + - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install --assume-yes --quiet gcc-multilib; fi install: gem install rspec script: - cd test && rake ci @@ -19,6 +20,6 @@ script: - cd ../extras/fixture/test && rake ci - make -s default noStdlibMalloc - make -s C89 - - cd ../../../examples/example_1 && make -s - - cd ../example_2 && make -s - - cd ../example_3 && rake \ No newline at end of file + - cd ../../../examples/example_1 && make -s ci + - cd ../example_2 && make -s ci + - cd ../example_3 && rake diff --git a/examples/example_1/makefile b/examples/example_1/makefile index c5a3ca4..cca79b4 100644 --- a/examples/example_1/makefile +++ b/examples/example_1/makefile @@ -67,3 +67,5 @@ test/test_runners/TestProductionCode2_Runner.c: test/TestProductionCode2.c clean: $(CLEANUP) $(TARGET1) $(TARGET2) +ci: CFLAGS += -Werror +ci: default diff --git a/examples/example_2/makefile b/examples/example_2/makefile index cfde2cc..99d8d96 100644 --- a/examples/example_2/makefile +++ b/examples/example_2/makefile @@ -66,3 +66,5 @@ default: clean: $(CLEANUP) $(TARGET1) +ci: CFLAGS += -Werror +ci: default