From 06c95fcb083948f09c40ae2241b159b7754ff27f Mon Sep 17 00:00:00 2001 From: "ThingamaByte, LLC" Date: Thu, 18 Jun 2015 10:38:20 -0400 Subject: [PATCH] - Fixed broken examples --- examples/example_1/makefile | 10 +- .../test_runners/TestProductionCode2_Runner.c | 86 ++++++++++------- .../test_runners/TestProductionCode_Runner.c | 94 +++++++++++-------- examples/example_2/makefile | 8 +- examples/example_3/makefile | 62 ------------ .../test/no_ruby/TestProductionCode2_Runner.c | 33 ------- .../test/no_ruby/TestProductionCode_Runner.c | 37 -------- 7 files changed, 122 insertions(+), 208 deletions(-) delete mode 100644 examples/example_3/makefile delete mode 100644 examples/example_3/test/no_ruby/TestProductionCode2_Runner.c delete mode 100644 examples/example_3/test/no_ruby/TestProductionCode_Runner.c diff --git a/examples/example_1/makefile b/examples/example_1/makefile index c8c4b9e..e4cacef 100644 --- a/examples/example_1/makefile +++ b/examples/example_1/makefile @@ -9,7 +9,11 @@ ifeq ($(OSTYPE),cygwin) CLEANUP = rm -f MKDIR = mkdir -p TARGET_EXTENSION=.out -else ifeq ($(OS),Windows_NT) +elseifeq ($(OSTYPE),msys) + CLEANUP = rm -f + MKDIR = mkdir -p + TARGET_EXTENSION=.exe +elseifeq ($(OS),Windows_NT) CLEANUP = del /F /Q MKDIR = mkdir TARGET_EXTENSION=.exe @@ -50,8 +54,8 @@ SYMBOLS=-DTEST all: clean default default: -# ruby auto/generate_test_runner.rb test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c -# ruby auto/generate_test_runner.rb test/TestProductionCode2.c test/test_runners/TestProductionCode2_Runner.c + 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 $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1) $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES2) -o $(TARGET2) ./$(TARGET1) diff --git a/examples/example_1/test/test_runners/TestProductionCode2_Runner.c b/examples/example_1/test/test_runners/TestProductionCode2_Runner.c index 4d67701..b7e70a2 100644 --- a/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +++ b/examples/example_1/test/test_runners/TestProductionCode2_Runner.c @@ -1,33 +1,53 @@ -/* AUTOGENERATED FILE. DO NOT EDIT. */ -#include "unity.h" -#include -#include - -char MessageBuffer[50]; - -extern void setUp(void); -extern void tearDown(void); - -extern void test_IgnoredTest(void); -extern void test_AnotherIgnoredTest(void); -extern void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void); - -void resetTest(void); -void resetTest(void) -{ - tearDown(); - setUp(); -} - - -int main(void) -{ - UnityBegin("test/TestProductionCode2.c"); - - RUN_TEST(test_IgnoredTest, 13); - RUN_TEST(test_AnotherIgnoredTest, 18); - RUN_TEST(test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented, 23); - - UnityEnd(); - return 0; -} +/* 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() && !TEST_IS_IGNORED) \ + { \ + 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_1/test/test_runners/TestProductionCode_Runner.c b/examples/example_1/test/test_runners/TestProductionCode_Runner.c index 0a795ec..c18025e 100644 --- a/examples/example_1/test/test_runners/TestProductionCode_Runner.c +++ b/examples/example_1/test/test_runners/TestProductionCode_Runner.c @@ -1,37 +1,57 @@ -/* AUTOGENERATED FILE. DO NOT EDIT. */ -#include "unity.h" -#include -#include - -char MessageBuffer[50]; - -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); - -void resetTest(void); -void resetTest(void) -{ - tearDown(); - setUp(); -} - - -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); - - UnityEnd(); - return 0; -} +/* 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() && !TEST_IS_IGNORED) \ + { \ + 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_2/makefile b/examples/example_2/makefile index 80956b6..e195db6 100644 --- a/examples/example_2/makefile +++ b/examples/example_2/makefile @@ -9,7 +9,11 @@ ifeq ($(OSTYPE),cygwin) CLEANUP = rm -f MKDIR = mkdir -p TARGET_EXTENSION=.out -else ifeq ($(OS),Windows_NT) +elseifeq ($(OSTYPE),msys) + CLEANUP = rm -f + MKDIR = mkdir -p + TARGET_EXTENSION=.exe +elseifeq ($(OS),Windows_NT) CLEANUP = del /F /Q MKDIR = mkdir TARGET_EXTENSION=.exe @@ -58,8 +62,6 @@ SYMBOLS= all: clean default default: -# ruby auto/generate_test_runner.rb test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c -# ruby auto/generate_test_runner.rb test/TestProductionCode2.c test/test_runners/TestProductionCode2_Runner.c $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1) ./$(TARGET1) diff --git a/examples/example_3/makefile b/examples/example_3/makefile deleted file mode 100644 index b2d299f..0000000 --- a/examples/example_3/makefile +++ /dev/null @@ -1,62 +0,0 @@ -# ========================================== -# Unity Project - A Test Framework for C -# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams -# [Released under MIT License. Please refer to license.txt for details] -# ========================================== - -#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 -else ifeq ($(OS),Windows_NT) - CLEANUP = del /F /Q - MKDIR = mkdir - TARGET_EXTENSION=.exe -else - CLEANUP = rm -f - MKDIR = mkdir -p - TARGET_EXTENSION=.out -endif - -UNITY_ROOT=../.. -C_COMPILER=gcc - -CFLAGS=-std=c99 -CFLAGS += -Wall -CFLAGS += -Wextra -CFLAGS += -Werror -CFLAGS += -Wpointer-arith -CFLAGS += -Wcast-align -CFLAGS += -Wwrite-strings -CFLAGS += -Wswitch-default -CFLAGS += -Wunreachable-code -CFLAGS += -Winit-self -CFLAGS += -Wmissing-field-initializers -CFLAGS += -Wno-unknown-pragmas -CFLAGS += -Wstrict-prototypes -CFLAGS += -Wundef -CFLAGS += -Wold-style-definition - -TARGET_BASE1=test1 -TARGET_BASE2=test2 -TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION) -TARGET2 = $(TARGET_BASE2)$(TARGET_EXTENSION) -SRC_FILES1=$(UNITY_ROOT)/src/unity.c src/ProductionCode.c test/TestProductionCode.c test/no_ruby/TestProductionCode_Runner.c -SRC_FILES2=$(UNITY_ROOT)/src/unity.c src/ProductionCode2.c test/TestProductionCode2.c test/no_ruby/TestProductionCode2_Runner.c -INC_DIRS=-Isrc -I$(UNITY_ROOT)/src -SYMBOLS=-DTEST - -all: clean default - -default: -# ruby auto/generate_test_runner.rb test/TestProductionCode.c test/no_ruby/TestProductionCode_Runner.c -# ruby auto/generate_test_runner.rb test/TestProductionCode2.c test/no_ruby/TestProductionCode2_Runner.c - $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1) - $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES2) -o $(TARGET2) - ./$(TARGET1) - ./$(TARGET2) - -clean: - $(CLEANUP) - diff --git a/examples/example_3/test/no_ruby/TestProductionCode2_Runner.c b/examples/example_3/test/no_ruby/TestProductionCode2_Runner.c deleted file mode 100644 index 4d67701..0000000 --- a/examples/example_3/test/no_ruby/TestProductionCode2_Runner.c +++ /dev/null @@ -1,33 +0,0 @@ -/* AUTOGENERATED FILE. DO NOT EDIT. */ -#include "unity.h" -#include -#include - -char MessageBuffer[50]; - -extern void setUp(void); -extern void tearDown(void); - -extern void test_IgnoredTest(void); -extern void test_AnotherIgnoredTest(void); -extern void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void); - -void resetTest(void); -void resetTest(void) -{ - tearDown(); - setUp(); -} - - -int main(void) -{ - UnityBegin("test/TestProductionCode2.c"); - - RUN_TEST(test_IgnoredTest, 13); - RUN_TEST(test_AnotherIgnoredTest, 18); - RUN_TEST(test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented, 23); - - UnityEnd(); - return 0; -} diff --git a/examples/example_3/test/no_ruby/TestProductionCode_Runner.c b/examples/example_3/test/no_ruby/TestProductionCode_Runner.c deleted file mode 100644 index 0a795ec..0000000 --- a/examples/example_3/test/no_ruby/TestProductionCode_Runner.c +++ /dev/null @@ -1,37 +0,0 @@ -/* AUTOGENERATED FILE. DO NOT EDIT. */ -#include "unity.h" -#include -#include - -char MessageBuffer[50]; - -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); - -void resetTest(void); -void resetTest(void) -{ - tearDown(); - setUp(); -} - - -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); - - UnityEnd(); - return 0; -}