Permalink
Browse files

update ghunit for 4.0 devices. Build HTTPRiot for iOS 4.0

  • Loading branch information...
1 parent 894f765 commit 7923af3442b4140aa251f52a3d142f03f35e4f27 @Caged committed Jun 28, 2010
Showing with 468 additions and 318 deletions.
  1. +58 −55 HTTPRiot.xcodeproj/project.pbxproj
  2. +2 −2 Rakefile
  3. +0 −2 Resources/iPhoneUnitTestsRunner-Info.plist
  4. +2 −1 Source/HTTPRiot/HTTPRiot.h
  5. +1 −1 Source/HTTPRiot/Utilities/HRBase64.m
  6. +33 −26 Source/HTTPRiot/Vendor/gh-unit-iphone/GHAsyncTestCase.h
  7. +40 −0 Source/HTTPRiot/Vendor/gh-unit-iphone/GHTest+JUnitXML.h
  8. +58 −52 Source/HTTPRiot/Vendor/gh-unit-iphone/GHTest.h
  9. +3 −3 Source/HTTPRiot/Vendor/gh-unit-iphone/GHTestCase.h
  10. +9 −7 Source/HTTPRiot/Vendor/gh-unit-iphone/{GHUNSObject+Swizzle.h → GHTestGroup+JUnitXML.h}
  11. +33 −49 Source/HTTPRiot/Vendor/gh-unit-iphone/GHTestGroup.h
  12. +6 −3 Source/HTTPRiot/Vendor/gh-unit-iphone/GHTestMacros.h
  13. +42 −0 Source/HTTPRiot/Vendor/gh-unit-iphone/GHTestOperation.h
  14. +20 −14 Source/HTTPRiot/Vendor/gh-unit-iphone/GHTestRunner.h
  15. +12 −6 Source/HTTPRiot/Vendor/gh-unit-iphone/GHTestSuite.h
  16. +36 −5 Source/HTTPRiot/Vendor/gh-unit-iphone/GHTesting.h
  17. +24 −3 Source/HTTPRiot/Vendor/gh-unit-iphone/GHUnitIPhoneAppDelegate.h
  18. +62 −41 Source/HTTPRiot/Vendor/gh-unit-iphone/GHUnitIPhoneTestMain.m
  19. +7 −6 Source/HTTPRiot/Vendor/gh-unit-iphone/Makefile
  20. +5 −0 Source/HTTPRiot/Vendor/gh-unit-iphone/NSException+GHTestFailureExceptions.h
  21. +0 −28 Source/HTTPRiot/Vendor/gh-unit-iphone/RunTests.sh
  22. BIN Source/HTTPRiot/Vendor/gh-unit-iphone/libGHUnitIPhone3_0.a
  23. BIN Source/HTTPRiot/Vendor/gh-unit-iphone/libGHUnitIPhone4_0.a
  24. +1 −1 Source/Tests/HRExtensionsTest.m
  25. +14 −13 Source/Tests/HTTPRiotRequestTest.m

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -3,8 +3,8 @@ require 'rake/packagetask'
require 'plist'
require 'versionomy'
-IPHONE_BUILD_TARGETS = %w(3.0 3.1 3.1.2 3.1.3 3.2).collect {|v| Versionomy.parse(v)}
-OSX_BUILD_TARGETS = %w(10.5 10.6).collect {|v| Versionomy.parse(v)}
+IPHONE_BUILD_TARGETS = %w(3.2 4.0).collect {|v| Versionomy.parse(v)}
+OSX_BUILD_TARGETS = %w(10.6).collect {|v| Versionomy.parse(v)}
CONFIGURATION = "Release"
namespace :iphone do
@@ -16,7 +16,5 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
- <key>NSMainNibFile</key>
- <string>MainWindow</string>
</dict>
</plist>
@@ -94,11 +94,12 @@ can share it with all your iPhone projects.
where it can be shared.
-# Create a new project or open an existing project in XCode. Select your application's target and
press<strong class="key"> ⌘i</strong> to bring up the properties window. Set the <strong><tt>Additional SDKs</tt></strong>
- property to <strong><tt>~/Library/SDKs/httpriot-0.4.0/\$(PLATFORM_NAME)\$(IPHONEOS_DEPLOYMENT_TARGET).sdk</tt></strong>
+ property to <strong><tt>~/Library/SDKs/httpriot-0.6.10/\$(PLATFORM_NAME)\$(IPHONEOS_DEPLOYMENT_TARGET).sdk</tt></strong>
@image html additional-sdks.png
-# Set the <strong><tt>Other Linker Flags</tt></strong> to <tt>-lhttpriot -lxml2 -ObjC -all_load</tt></strong>
@image html other-linker-flags.png
-# Set <strong><tt>Header Search Paths</tt></strong> to <strong><tt>/usr/include/libxml2/**</tt></strong>
+-# If building for the iPad or iPhone 4 OS you'll need to set 'Architectures' to "Optimized" or "arm6,arm7"
-# Use <strong><tt>\#include <HTTPRiot/HTTPRiot.h></tt></strong> in one of your application's files.
That's it! Now you're ready to use HTTPRiot!
@@ -20,7 +20,7 @@ @implementation NSData (MBBase64)
+ (id)dataWithBase64EncodedString:(NSString *)string {
if (string == nil)
- [NSException raise:NSInvalidArgumentException format:nil];
+ [NSException raise:NSInvalidArgumentException format:@""];
if ([string length] == 0)
return [NSData data];
@@ -31,48 +31,55 @@
// Some default statuses to use; Or define and use your own
enum {
- kGHUnitWaitStatusUnknown = 0,
- kGHUnitWaitStatusSuccess,
- kGHUnitWaitStatusFailure,
- kGHUnitWaitStatusCancelled
+ kGHUnitWaitStatusUnknown = 0,
+ kGHUnitWaitStatusSuccess,
+ kGHUnitWaitStatusFailure,
+ kGHUnitWaitStatusCancelled
};
/*!
Asynchronous test case with wait and notify.
- Handles the case of notify occuring before wait has started (if it was a synchronous call).
+ If notify occurs before wait has started (if it was a synchronous call), this test
+ case will still work.
+
Be sure to call prepare before the asynchronous method (otherwise an exception will raise).
@code
- (void)testSuccess {
- [self prepare];
-
- // Do asynchronous task here
- [self performSelector:@selector(_succeed) withObject:nil afterDelay:0.1];
-
- [self waitForStatus:kGHUnitWaitStatusSuccess timeout:1.0];
+ [self prepare];
+
+ // Do asynchronous task here
+ [self performSelector:@selector(_succeed) withObject:nil afterDelay:0.1];
+
+ [self waitForStatus:kGHUnitWaitStatusSuccess timeout:1.0];
}
- (void)_succeed {
// Notice the forSelector points to the test above. This is so that
// stray notifies don't error or falsely succeed other tests.
+ // To ignore the check, forSelector can be NULL.
[self notify:kGHUnitWaitStatusSuccess forSelector:@selector(testSuccess)];
}
@endcode
*/
@interface GHAsyncTestCase : GHTestCase {
- NSInteger waitForStatus_;
- NSInteger notifiedStatus_;
-
- BOOL prepared_; // Whether prepared was called before waitForStatus:timeout:
- NSRecursiveLock *lock_; // Lock to synchronize on
- SEL waitSelector_; // The selector we are waiting on
-
- NSArray *_runLoopModes; // Run loop modes to run while waiting; Defaults to NSDefaultRunLoopMode, NSRunLoopCommonModes, NSConnectionReplyMode
+ NSInteger waitForStatus_;
+ NSInteger notifiedStatus_;
+
+ BOOL prepared_; // Whether prepared was called before waitForStatus:timeout:
+ NSRecursiveLock *lock_; // Lock to synchronize on
+ SEL waitSelector_; // The selector we are waiting on
+
+ NSArray *_runLoopModes;
}
-@property (retain, nonatomic) NSArray *runLoopModes;
+/*!
+ Run loop modes to run while waiting;
+ Defaults to NSDefaultRunLoopMode, NSRunLoopCommonModes, NSConnectionReplyMode
+ */
+@property (retain, nonatomic) NSArray *runLoopModes;
/*!
Prepare before calling the asynchronous method.
@@ -93,11 +100,11 @@ enum {
For example,
@code
- - (void)testFoo {
- [self prepare];
- // Do asynchronous task here
- [self waitForStatus:kGHUnitWaitStatusSuccess timeout:1.0];
- }
+ - (void)testFoo {
+ [self prepare];
+ // Do asynchronous task here
+ [self waitForStatus:kGHUnitWaitStatusSuccess timeout:1.0];
+ }
@endcode
@param status kGHUnitWaitStatusSuccess, kGHUnitWaitStatusFailure or custom status
@@ -119,7 +126,7 @@ enum {
Notify waiting of status for test selector.
@param status Status, for example, kGHUnitWaitStatusSuccess
@param selector If not NULL, then will verify this selector is where we are waiting.
- This prevents stray asynchronous callbacks to fail a later test
+ This prevents stray asynchronous callbacks to fail a later test
*/
- (void)notify:(NSInteger)status forSelector:(SEL)selector;
@@ -0,0 +1,40 @@
+//
+// GHTest+JUnitXML.h
+// GHUnit
+//
+// Created by Gabriel Handford on 6/4/10.
+// Copyright 2010. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#import "GHTest.h"
+
+@interface GHTest (JUnitXML)
+
+/*!
+ Return test results in JUnit XML format for external parsing use
+ (such as a Continuous Integration system like Hudson)
+ */
+- (NSString *)JUnitXML;
+
+@end
@@ -31,31 +31,44 @@
Test status.
*/
typedef enum {
- GHTestStatusNone = 0,
- GHTestStatusRunning, // Test is running
- GHTestStatusCancelling, // Test is being cancelled
- GHTestStatusCancelled, // Test was cancelled
- GHTestStatusSucceeded, // Test finished and succeeded
- GHTestStatusErrored, // Test finished and errored
+ GHTestStatusNone = 0,
+ GHTestStatusRunning, // Test is running
+ GHTestStatusCancelling, // Test is being cancelled
+ GHTestStatusCancelled, // Test was cancelled
+ GHTestStatusSucceeded, // Test finished and succeeded
+ GHTestStatusErrored, // Test finished and errored
} GHTestStatus;
+enum {
+ GHTestOptionReraiseExceptions = 1 << 0, // Allows exceptions to be raised (so you can trigger the debugger)
+ GHTestOptionForceSetUpTearDownClass = 1 << 1, // Runs setUpClass/tearDownClass for this (each) test; Used when re-running a single test in a group
+};
+typedef NSInteger GHTestOptions;
+
/*!
Generate string from GHTestStatus
@param status
*/
extern NSString* NSStringFromGHTestStatus(GHTestStatus status);
+/*!
+ Check if test is running (or trying to cancel).
+ */
extern BOOL GHTestStatusIsRunning(GHTestStatus status);
+
+/*!
+ Check if test has succeeded, errored or cancelled.
+ */
extern BOOL GHTestStatusEnded(GHTestStatus status);
/*!
Test stats.
*/
typedef struct {
- NSInteger succeedCount; // Number of succeeded tests
- NSInteger failureCount; // Number of failed tests
- NSInteger cancelCount; // Number of aborted tests
- NSInteger testCount; // Total number of tests
+ NSInteger succeedCount; // Number of succeeded tests
+ NSInteger failureCount; // Number of failed tests
+ NSInteger cancelCount; // Number of aborted tests
+ NSInteger testCount; // Total number of tests
} GHTestStats;
/*!
@@ -73,29 +86,25 @@ extern NSString *NSStringFromGHTestStats(GHTestStats stats);
The base interface for a runnable test.
A runnable with a unique identifier, display name, stats, timer, delegate, log and error handling.
*/
-@protocol GHTest <NSObject>
+@protocol GHTest <NSObject, NSCoding, NSCopying>
-- (void)run;
+- (void)run:(GHTestOptions)options;
-- (NSString *)identifier;
-- (NSString *)name;
-
-- (NSTimeInterval)interval;
-- (GHTestStatus)status;
-- (GHTestStats)stats;
-
-- (void)setDelegate:(id<GHTestDelegate>)delegate;
-
-- (NSException *)exception;
-- (void)setException:(NSException *)exception;
+@property (readonly, nonatomic) NSString *identifier; // Unique identifier for test
+@property (readonly, nonatomic) NSString *name;
+@property (assign, nonatomic) NSTimeInterval interval;
+@property (assign, nonatomic) GHTestStatus status;
+@property (readonly, nonatomic) GHTestStats stats;
+@property (retain, nonatomic) NSException *exception;
+@property (assign, nonatomic, getter=isDisabled) BOOL disabled;
+@property (assign, nonatomic, getter=isHidden) BOOL hidden;
+@property (assign, nonatomic) id<GHTestDelegate> delegate; // weak
- (NSArray *)log;
- (void)reset;
- (void)cancel;
-- (void)setDisabled:(BOOL)disabled;
-- (BOOL)isDisabled;
- (NSInteger)disabledCount;
@end
@@ -117,46 +126,42 @@ extern NSString *NSStringFromGHTestStats(GHTestStats stats);
- (void)log:(NSString *)message testCase:(id)testCase;
@end
-@interface GHTestOperation : NSOperation {
- id<GHTest> test_;
-}
-@end
-
/*!
Default test implementation with a target/selector pair.
- - Consists of a target/selector
+ - Tests a target and selector
- Notifies a test delegate
- Keeps track of status, running time and failures
- Stores any test specific logging
*/
@interface GHTest : NSObject <GHTest, GHTestCaseLogWriter> {
-
- NSObject<GHTestDelegate> *delegate_; // weak
-
- id target_;
- SEL selector_;
-
- NSString *identifier_;
- NSString *name_;
- GHTestStatus status_;
- NSTimeInterval interval_;
- BOOL disabled_;
- NSException *exception_; // If failed
-
- NSMutableArray *log_;
+
+ NSObject<GHTestDelegate> *delegate_; // weak
+
+ id target_;
+ SEL selector_;
+
+ NSString *identifier_;
+ NSString *name_;
+ GHTestStatus status_;
+ NSTimeInterval interval_;
+ BOOL disabled_;
+ BOOL hidden_;
+ NSException *exception_; // If failed
+
+ NSMutableArray *log_;
+
}
@property (readonly, nonatomic) id target;
@property (readonly, nonatomic) SEL selector;
-@property (readonly, nonatomic) NSString *identifier; // Unique identifier for test
-@property (readonly, nonatomic) NSString *name;
-@property (readonly, nonatomic) NSTimeInterval interval;
-@property (retain, nonatomic) NSException *exception;
-@property (readonly, nonatomic) GHTestStatus status;
-@property (assign, nonatomic, getter=isDisabled) BOOL disabled;
@property (readonly, nonatomic) NSArray *log;
-@property (assign, nonatomic) NSObject<GHTestDelegate> *delegate;
+/*!
+ Create test with identifier, name.
+ @param identifier Unique identifier
+ @param name Name
+ */
+- (id)initWithIdentifier:(NSString *)identifier name:(NSString *)name;
/*!
Create test with target/selector.
@@ -173,3 +178,4 @@ extern NSString *NSStringFromGHTestStats(GHTestStats stats);
+ (id)testWithTarget:(id)target selector:(SEL)selector;
@end
+
@@ -90,9 +90,9 @@
*/
@interface GHTestCase : NSObject {
- id<GHTestCaseLogWriter> logWriter_; // weak
-
- SEL currentSelector_;
+ id<GHTestCaseLogWriter> logWriter_; // weak
+
+ SEL currentSelector_;
}
//! The current test selector
@@ -1,9 +1,9 @@
//
-// GHNSObject+Swizzle.h
+// GHTestGroup+JUnitXML.h
// GHUnit
//
-// Created by Gabriel Handford on 4/13/09.
-// Copyright 2009. All rights reserved.
+// Created by Gabriel Handford on 6/4/10.
+// Copyright 2010. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -27,10 +27,12 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
-@interface NSObject (GHUSwizzle)
+#import "GHTestGroup.h"
-+ (void)ghu_swizzleMethod:(SEL)original withMethod:(SEL)alternate;
-+ (void)ghu_swizzleClassMethod:(SEL)original withClassMethod:(SEL)alternate;
+@interface GHTestGroup (JUnitXML)
-@end
+- (NSString *)JUnitXML;
+
+- (BOOL)writeJUnitXMLAtPath:(NSString *)documentsPath error:(NSError **)error;
+@end
Oops, something went wrong.

0 comments on commit 7923af3

Please sign in to comment.