From 65b757c269dc435e6fa0a4c384c77303db13467d Mon Sep 17 00:00:00 2001 From: Gabriel Handford Date: Fri, 28 Jan 2011 15:58:25 -0800 Subject: [PATCH] - Building as GHUnitIOS.framework for iOS. - Fix issue #37 - Fix issue #38 - Fix issue #39 Renamed IPhone, iPhone --- CHANGELOG.md | 7 +++++++ Classes/GHTest/GHTestGroup.h | 21 +++++++++++++++++++ Classes/GHTest/GHTestGroup.m | 7 ++++++- Classes/GHTest/GHTestRunner.m | 7 ++++--- Classes/GHUnit.h | 16 ++++++++------ .../GHUnitIPhone.xcodeproj/project.pbxproj | 4 ---- Project-IPhone/Makefile | 6 +++--- Project/GHUnit.xcodeproj/project.pbxproj | 4 ++-- Scripts/iPhoneFramework.sh | 2 +- XcodeConfig/Shared-IPhone.xcconfig | 8 ------- XcodeConfig/Shared.xcconfig | 2 +- XcodeConfig/iPhoneDevice-Debug.xcconfig | 4 ++++ XcodeConfig/iPhoneDevice-Release.xcconfig | 4 +++- XcodeConfig/iPhoneSimulator-Debug.xcconfig | 4 ++++ XcodeConfig/iPhoneSimulator-Release.xcconfig | 4 ++++ 15 files changed, 70 insertions(+), 30 deletions(-) delete mode 100644 XcodeConfig/Shared-IPhone.xcconfig diff --git a/CHANGELOG.md b/CHANGELOG.md index 29ca5262..0fe7cc2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# Release 0.4.28 +- Building as GHUnitIOS.framework for iOS. +- Fix issue #37 +- Fix issue #38 +- Fix issue #39 +- Fix issue #36 + # Release 0.4.27 - Added in GHUnitIPhoneAppDelegate for subclassing test app delegate diff --git a/Classes/GHTest/GHTestGroup.h b/Classes/GHTest/GHTestGroup.h index 6b53b643..16894103 100644 --- a/Classes/GHTest/GHTestGroup.h +++ b/Classes/GHTest/GHTestGroup.h @@ -128,14 +128,35 @@ */ - (void)addTestCase:(id)testCase; +/*! + Add a test group to this test group. + @param testGroup Test group to add + */ - (void)addTestGroup:(GHTestGroup *)testGroup; +/*! + Add tests to this group. + @param tests Tests to add + */ - (void)addTests:(NSArray */*of id*/)tests; +/*! + Add test to this group. + @param test Test to add + */ - (void)addTest:(id)test; +/*! + Whether the test group should run on the main thread. + Call passes to test case instance if enabled. + */ - (BOOL)shouldRunOnMainThread; +/*! + @result YES if we have any enabled chilren, NO if all children have been disabled. + */ +- (BOOL)hasEnabledChildren; + /*! Get list of failed tests. @result Failed tests diff --git a/Classes/GHTest/GHTestGroup.m b/Classes/GHTest/GHTestGroup.m index b8570afc..72e173b5 100644 --- a/Classes/GHTest/GHTestGroup.m +++ b/Classes/GHTest/GHTestGroup.m @@ -261,8 +261,12 @@ - (void)tearDownClass { } } +- (BOOL)hasEnabledChildren { + return (([children_ count] - [self disabledCount]) <= 0); +} + - (void)_run:(NSOperationQueue *)operationQueue { - if (status_ == GHTestStatusCancelled || (([children_ count] - [self disabledCount]) <= 0)) { + if (status_ == GHTestStatusCancelled || [self hasEnabledChildren]) { return; } @@ -320,6 +324,7 @@ - (void)runInOperationQueue:(NSOperationQueue *)operationQueue options:(GHTestOp } - (BOOL)shouldRunOnMainThread { + if (self.isDisabled) return NO; if ([testCase_ respondsToSelector:@selector(shouldRunOnMainThread)]) return [testCase_ shouldRunOnMainThread]; return NO; diff --git a/Classes/GHTest/GHTestRunner.m b/Classes/GHTest/GHTestRunner.m index 72ba0ec4..df9b1b42 100644 --- a/Classes/GHTest/GHTestRunner.m +++ b/Classes/GHTest/GHTestRunner.m @@ -168,7 +168,8 @@ - (void)log:(NSString *)message { } - (void)_log:(NSString *)message { - fputs([[message stringByAppendingString:@"\n"] UTF8String], stdout); + fputs([message UTF8String], stdout); + fputs("\n", stdout); fflush(stdout); if ([delegate_ respondsToSelector:@selector(testRunner:didLog:)]) @@ -179,7 +180,7 @@ - (void)_log:(NSString *)message { - (void)testDidStart:(id)test source:(id)source { if (![source conformsToProtocol:@protocol(GHTestGroup)]) { - [self log:[NSString stringWithFormat:@"%@ ", [source identifier]]]; + [self log:[NSString stringWithFormat:@"Starting %@\n", [source identifier]]]; } if ([delegate_ respondsToSelector:@selector(testRunner:didStartTest:)]) @@ -195,7 +196,7 @@ - (void)testDidEnd:(id)test source:(id)source { if ([source status] != GHTestStatusCancelled) { if (![source conformsToProtocol:@protocol(GHTestGroup)]) { - NSString *message = [NSString stringWithFormat:@"%@ (%0.3fs)\n", + NSString *message = [NSString stringWithFormat:@" %@ (%0.3fs)\n\n", ([source stats].failureCount > 0 ? @"FAIL" : @"OK"), [source interval]]; [self log:message]; } diff --git a/Classes/GHUnit.h b/Classes/GHUnit.h index 881455ec..38056e89 100644 --- a/Classes/GHUnit.h +++ b/Classes/GHUnit.h @@ -103,9 +103,9 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@ @section InstallingIOS Installing (iOS) - Add a New Target. Select Cocoa Touch -> Application. Name it Tests (or something similar). - - Add the GHUnit.framework to your project. + - Add the GHUnitIOS.framework to your project. - Add the following frameworks to Linked Libraries: - - GHUnit.framework + - GHUnitIOS.framework - CoreGraphics.framework - Foundation.framework - UIKit.framework @@ -113,7 +113,7 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@ - Under 'Other Linker Flags' in the Tests target, add -ObjC and -all_load - By default, the Tests-Info.plist file includes MainWindow for Main nib file base name. You should clear this field. - Add the GHUnitIOSTestMain.m (http://github.com/gabriel/gh-unit/blob/master/Project-IPhone/GHUnitIOSTestMain.m) file into your project. - - (Optional) Create and and set a prefix header (Tests_Prefix.pch) and add #import to it, and then you won't have to include that import for every test. + - (Optional) Create and and set a prefix header (Tests_Prefix.pch) and add #import to it, and then you won't have to include that import for every test. - (Optional) @ref Makefile "Install Makefile" - @ref Examples "Create a test" @@ -180,7 +180,9 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@ For example ExampleTest.m: @code - #import + #import + // For Mac OS X + //#import @interface ExampleTest : GHTestCase { } @end @@ -230,7 +232,9 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@ @section ExampleAsyncTestCase Example Async Test Case @code - #import + #import + // For Mac OS X + //#import @interface ExampleAsyncTest : GHAsyncTestCase { } @end @@ -567,7 +571,7 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@ the following in Test report XMLs: @verbatim - build/test-results/*.xml + build/test-results/\*.xml @endverbatim That's all it takes. Check in a change that breaks one of your tests. Hudson diff --git a/Project-IPhone/GHUnitIPhone.xcodeproj/project.pbxproj b/Project-IPhone/GHUnitIPhone.xcodeproj/project.pbxproj index 31c11588..3495f89f 100755 --- a/Project-IPhone/GHUnitIPhone.xcodeproj/project.pbxproj +++ b/Project-IPhone/GHUnitIPhone.xcodeproj/project.pbxproj @@ -906,7 +906,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = 0002873B1181491F00D74BBD /* iPhoneSimulator-Debug.xcconfig */; buildSettings = { - SDKROOT = iphonesimulator4.0; }; name = Debug; }; @@ -914,7 +913,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = 0002873C1181499000D74BBD /* iPhoneSimulator-Release.xcconfig */; buildSettings = { - SDKROOT = iphonesimulator4.0; }; name = Release; }; @@ -922,7 +920,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = 00028740118149E700D74BBD /* iPhoneDevice-Debug.xcconfig */; buildSettings = { - SDKROOT = iphoneos4.1; }; name = Debug; }; @@ -930,7 +927,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = 0002873E118149CE00D74BBD /* iPhoneDevice-Release.xcconfig */; buildSettings = { - SDKROOT = iphoneos4.1; }; name = Release; }; diff --git a/Project-IPhone/Makefile b/Project-IPhone/Makefile index d903d6cc..d998f683 100644 --- a/Project-IPhone/Makefile +++ b/Project-IPhone/Makefile @@ -1,7 +1,7 @@ default: - xcodebuild -target "GHUnitIPhone (Simulator)" -configuration Release build - xcodebuild -target "GHUnitIPhone (Device)" -configuration Release build + xcodebuild -target "GHUnitIPhone (Device)" -configuration Release + xcodebuild -target "GHUnitIPhone (Simulator)" -configuration Release BUILD_DIR="build" BUILD_STYLE="Release" sh ../Scripts/CombineLibs.sh sh ../Scripts/iPhoneFramework.sh @@ -10,4 +10,4 @@ clean: -rm -rf build/* test: - GHUNIT_CLI=1 xcodebuild -target Tests -configuration Debug -sdk iphonesimulator4.0 build + GHUNIT_CLI=1 xcodebuild -target Tests -configuration Debug build diff --git a/Project/GHUnit.xcodeproj/project.pbxproj b/Project/GHUnit.xcodeproj/project.pbxproj index 55ecdb8c..d7091454 100644 --- a/Project/GHUnit.xcodeproj/project.pbxproj +++ b/Project/GHUnit.xcodeproj/project.pbxproj @@ -196,7 +196,7 @@ 005FDD200F33D259006B369F /* GTMSenTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTMSenTestCase.h; sourceTree = ""; }; 005FDD210F33D259006B369F /* GTMSenTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMSenTestCase.m; sourceTree = ""; }; 006307900F8E760800C9602A /* Shared.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Shared.xcconfig; sourceTree = ""; }; - 006307910F8E761C00C9602A /* Shared-IPhone.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Shared-IPhone.xcconfig"; sourceTree = ""; }; + 006307910F8E761C00C9602A /* Shared-iPhone.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Shared-iPhone.xcconfig"; sourceTree = ""; }; 00772F8A0F8D7A6400586577 /* GHAsyncTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHAsyncTestCase.h; sourceTree = ""; }; 00772F8B0F8D7A6400586577 /* GHAsyncTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHAsyncTestCase.m; sourceTree = ""; }; 00772F910F8D7ABA00586577 /* GHAsyncTestCaseTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHAsyncTestCaseTest.m; sourceTree = ""; }; @@ -452,7 +452,7 @@ isa = PBXGroup; children = ( 006307900F8E760800C9602A /* Shared.xcconfig */, - 006307910F8E761C00C9602A /* Shared-IPhone.xcconfig */, + 006307910F8E761C00C9602A /* Shared-iPhone.xcconfig */, 00CD28271211C79100DF808D /* GHUnit.xcconfig */, 00CD28301211C8A300DF808D /* GHUnit-Debug.xcconfig */, 00CD28251211C75100DF808D /* GHUnit-Release.xcconfig */, diff --git a/Scripts/iPhoneFramework.sh b/Scripts/iPhoneFramework.sh index 475c4114..dadfc8dc 100755 --- a/Scripts/iPhoneFramework.sh +++ b/Scripts/iPhoneFramework.sh @@ -7,7 +7,7 @@ set -e # Define these to suit your nefarious purposes - FRAMEWORK_NAME=GHUnit + FRAMEWORK_NAME=GHUnitIOS LIB_NAME=libGHUnitIOS FRAMEWORK_VERSION=A BUILD_TYPE=Release diff --git a/XcodeConfig/Shared-IPhone.xcconfig b/XcodeConfig/Shared-IPhone.xcconfig deleted file mode 100644 index 2db3811d..00000000 --- a/XcodeConfig/Shared-IPhone.xcconfig +++ /dev/null @@ -1,8 +0,0 @@ -#include "Shared.xcconfig" - -GCC_PREFIX_HEADER = GHUnitIPhone_Prefix.pch -ZERO_LINK = NO -IPHONEOS_DEPLOYMENT_TARGET = 3.0 - -// Testing with LLVM -//GCC_VERSION = com.apple.compilers.llvm.clang.1_0 diff --git a/XcodeConfig/Shared.xcconfig b/XcodeConfig/Shared.xcconfig index 4b24ddcf..77925346 100644 --- a/XcodeConfig/Shared.xcconfig +++ b/XcodeConfig/Shared.xcconfig @@ -1,4 +1,4 @@ -GHUNIT_VERSION = 0.4.27 +GHUNIT_VERSION = 0.4.28 GHUNIT_GENERAL_OTHER_CFLAGS = -Wdiv-by-zero -Wbad-function-cast -Wnested-externs -Wold-style-definition diff --git a/XcodeConfig/iPhoneDevice-Debug.xcconfig b/XcodeConfig/iPhoneDevice-Debug.xcconfig index 93cf4918..401a7994 100644 --- a/XcodeConfig/iPhoneDevice-Debug.xcconfig +++ b/XcodeConfig/iPhoneDevice-Debug.xcconfig @@ -3,5 +3,9 @@ PRODUCT_NAME = GHUnitIOSDevice +SDKROOT = iphoneos +ARCHS = armv6 armv7 +VALID_ARCHS = armv6 armv7 + GCC_PREPROCESSOR_DEFINITIONS = DEBUG GCC_OPTIMIZATION_LEVEL = 0 diff --git a/XcodeConfig/iPhoneDevice-Release.xcconfig b/XcodeConfig/iPhoneDevice-Release.xcconfig index 7b746a9c..3a1680e8 100644 --- a/XcodeConfig/iPhoneDevice-Release.xcconfig +++ b/XcodeConfig/iPhoneDevice-Release.xcconfig @@ -3,4 +3,6 @@ PRODUCT_NAME = GHUnitIOSDevice - +SDKROOT = iphoneos +ARCHS = armv6 armv7 +VALID_ARCHS = armv6 armv7 \ No newline at end of file diff --git a/XcodeConfig/iPhoneSimulator-Debug.xcconfig b/XcodeConfig/iPhoneSimulator-Debug.xcconfig index 203627a2..3fbab18a 100644 --- a/XcodeConfig/iPhoneSimulator-Debug.xcconfig +++ b/XcodeConfig/iPhoneSimulator-Debug.xcconfig @@ -3,5 +3,9 @@ PRODUCT_NAME = GHUnitIOSSimulator +SDKROOT = iphonesimulator +ARCHS = i386 +VALID_ARCHS = i386 + GCC_PREPROCESSOR_DEFINITIONS = DEBUG GCC_OPTIMIZATION_LEVEL = 0 diff --git a/XcodeConfig/iPhoneSimulator-Release.xcconfig b/XcodeConfig/iPhoneSimulator-Release.xcconfig index 3f3590db..69d3b2c7 100644 --- a/XcodeConfig/iPhoneSimulator-Release.xcconfig +++ b/XcodeConfig/iPhoneSimulator-Release.xcconfig @@ -2,3 +2,7 @@ #include "Shared-iPhone.xcconfig" PRODUCT_NAME = GHUnitIOSSimulator + +SDKROOT = iphonesimulator +ARCHS = i386 +VALID_ARCHS = i386 \ No newline at end of file