Skip to content

Commit

Permalink
- Building as GHUnitIOS.framework for iOS.
Browse files Browse the repository at this point in the history
- Fix issue gh-unit#37
- Fix issue gh-unit#38
- Fix issue gh-unit#39
Renamed IPhone, iPhone
  • Loading branch information
gabriel committed Jan 29, 2011
1 parent 5d2fb11 commit 65b757c
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 30 deletions.
7 changes: 7 additions & 0 deletions 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

Expand Down
21 changes: 21 additions & 0 deletions Classes/GHTest/GHTestGroup.h
Expand Up @@ -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<GHTest>*/)tests;

/*!
Add test to this group.
@param test Test to add
*/
- (void)addTest:(id<GHTest>)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
Expand Down
7 changes: 6 additions & 1 deletion Classes/GHTest/GHTestGroup.m
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions Classes/GHTest/GHTestRunner.m
Expand Up @@ -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:)])
Expand All @@ -179,7 +180,7 @@ - (void)_log:(NSString *)message {

- (void)testDidStart:(id<GHTest>)test source:(id<GHTest>)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:)])
Expand All @@ -195,7 +196,7 @@ - (void)testDidEnd:(id<GHTest>)test source:(id<GHTest>)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];
}
Expand Down
16 changes: 10 additions & 6 deletions Classes/GHUnit.h
Expand Up @@ -103,17 +103,17 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@
@section InstallingIOS Installing (iOS)
- Add a <tt>New Target</tt>. Select <tt>Cocoa Touch -> Application</tt>. Name it <tt>Tests</tt> (or something similar).
- Add the <tt>GHUnit.framework</tt> to your project.
- Add the <tt>GHUnitIOS.framework</tt> to your project.
- Add the following frameworks to <tt>Linked Libraries</tt>:
- <tt>GHUnit.framework</tt>
- <tt>GHUnitIOS.framework</tt>
- <tt>CoreGraphics.framework</tt>
- <tt>Foundation.framework</tt>
- <tt>UIKit.framework</tt>
- Under 'Framework Search Paths' make sure the (parent) directory to GHUnit.framework is listed.
- Under 'Other Linker Flags' in the <tt>Tests</tt> target, add <tt>-ObjC</tt> and <tt>-all_load</tt>
- By default, the Tests-Info.plist file includes <tt>MainWindow</tt> for <tt>Main nib file base name</tt>. 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 (<tt>Tests_Prefix.pch</tt>) and add <tt>#import <GHUnit/GHUnit.h></tt> to it, and then you won't have to include that import for every test.
- (Optional) Create and and set a prefix header (<tt>Tests_Prefix.pch</tt>) and add <tt>#import <GHUnitIOS/GHUnit.h></tt> 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"
Expand Down Expand Up @@ -180,7 +180,9 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@
For example <tt>ExampleTest.m</tt>:
@code
#import <GHUnit/GHUnit.h>
#import <GHUnitIOS/GHUnit.h>
// For Mac OS X
//#import <GHUnit/GHUnit.h>
@interface ExampleTest : GHTestCase { }
@end
Expand Down Expand Up @@ -230,7 +232,9 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@
@section ExampleAsyncTestCase Example Async Test Case
@code
#import <GHUnit/GHUnit.h>
#import <GHUnitIOS/GHUnit.h>
// For Mac OS X
//#import <GHUnit/GHUnit.h>
@interface ExampleAsyncTest : GHAsyncTestCase { }
@end
Expand Down Expand Up @@ -567,7 +571,7 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@
the following in <tt>Test report XMLs</tt>:
@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
Expand Down
4 changes: 0 additions & 4 deletions Project-IPhone/GHUnitIPhone.xcodeproj/project.pbxproj
Expand Up @@ -906,31 +906,27 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 0002873B1181491F00D74BBD /* iPhoneSimulator-Debug.xcconfig */;
buildSettings = {
SDKROOT = iphonesimulator4.0;
};
name = Debug;
};
0002877111814A1F00D74BBD /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 0002873C1181499000D74BBD /* iPhoneSimulator-Release.xcconfig */;
buildSettings = {
SDKROOT = iphonesimulator4.0;
};
name = Release;
};
000287A111814A5300D74BBD /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 00028740118149E700D74BBD /* iPhoneDevice-Debug.xcconfig */;
buildSettings = {
SDKROOT = iphoneos4.1;
};
name = Debug;
};
000287A211814A5300D74BBD /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 0002873E118149CE00D74BBD /* iPhoneDevice-Release.xcconfig */;
buildSettings = {
SDKROOT = iphoneos4.1;
};
name = Release;
};
Expand Down
6 changes: 3 additions & 3 deletions 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

Expand All @@ -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
4 changes: 2 additions & 2 deletions Project/GHUnit.xcodeproj/project.pbxproj
Expand Up @@ -196,7 +196,7 @@
005FDD200F33D259006B369F /* GTMSenTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTMSenTestCase.h; sourceTree = "<group>"; };
005FDD210F33D259006B369F /* GTMSenTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMSenTestCase.m; sourceTree = "<group>"; };
006307900F8E760800C9602A /* Shared.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Shared.xcconfig; sourceTree = "<group>"; };
006307910F8E761C00C9602A /* Shared-IPhone.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Shared-IPhone.xcconfig"; sourceTree = "<group>"; };
006307910F8E761C00C9602A /* Shared-iPhone.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Shared-iPhone.xcconfig"; sourceTree = "<group>"; };
00772F8A0F8D7A6400586577 /* GHAsyncTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHAsyncTestCase.h; sourceTree = "<group>"; };
00772F8B0F8D7A6400586577 /* GHAsyncTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHAsyncTestCase.m; sourceTree = "<group>"; };
00772F910F8D7ABA00586577 /* GHAsyncTestCaseTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHAsyncTestCaseTest.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -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 */,
Expand Down
2 changes: 1 addition & 1 deletion Scripts/iPhoneFramework.sh
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions XcodeConfig/Shared-IPhone.xcconfig

This file was deleted.

2 changes: 1 addition & 1 deletion 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

Expand Down
4 changes: 4 additions & 0 deletions XcodeConfig/iPhoneDevice-Debug.xcconfig
Expand Up @@ -3,5 +3,9 @@

PRODUCT_NAME = GHUnitIOSDevice

SDKROOT = iphoneos
ARCHS = armv6 armv7
VALID_ARCHS = armv6 armv7

GCC_PREPROCESSOR_DEFINITIONS = DEBUG
GCC_OPTIMIZATION_LEVEL = 0
4 changes: 3 additions & 1 deletion XcodeConfig/iPhoneDevice-Release.xcconfig
Expand Up @@ -3,4 +3,6 @@

PRODUCT_NAME = GHUnitIOSDevice


SDKROOT = iphoneos
ARCHS = armv6 armv7
VALID_ARCHS = armv6 armv7
4 changes: 4 additions & 0 deletions XcodeConfig/iPhoneSimulator-Debug.xcconfig
Expand Up @@ -3,5 +3,9 @@

PRODUCT_NAME = GHUnitIOSSimulator

SDKROOT = iphonesimulator
ARCHS = i386
VALID_ARCHS = i386

GCC_PREPROCESSOR_DEFINITIONS = DEBUG
GCC_OPTIMIZATION_LEVEL = 0
4 changes: 4 additions & 0 deletions XcodeConfig/iPhoneSimulator-Release.xcconfig
Expand Up @@ -2,3 +2,7 @@
#include "Shared-iPhone.xcconfig"

PRODUCT_NAME = GHUnitIOSSimulator

SDKROOT = iphonesimulator
ARCHS = i386
VALID_ARCHS = i386

0 comments on commit 65b757c

Please sign in to comment.