Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Test target #484

Merged
merged 20 commits into from
Sep 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
[submodule "Carthage/Checkouts/xcconfigs"]
path = Carthage/Checkouts/xcconfigs
url = https://github.com/jspahrsummers/xcconfigs.git
[submodule "Carthage/Checkouts/ZipArchive"]
path = Carthage/Checkouts/ZipArchive
url = https://github.com/ZipArchive/ZipArchive.git
1 change: 1 addition & 0 deletions Cartfile.private
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github "jspahrsummers/xcconfigs" >= 0.7.1
github "Quick/Quick" ~> 0.3
github "Quick/Nimble" ~> 0.4
github "ZipArchive/ZipArchive" ~> 0.3
1 change: 1 addition & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github "Quick/Nimble" "v0.4.2"
github "Quick/Quick" "v0.3.1"
github "ZipArchive/ZipArchive" "v0.3.2"
github "jspahrsummers/xcconfigs" "0.7.2"
1 change: 1 addition & 0 deletions Carthage/Checkouts/ZipArchive
Submodule ZipArchive added at 60312c
411 changes: 398 additions & 13 deletions ObjectiveGitFramework.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D01B6EDC19F82E2000D411BC"
BlueprintIdentifier = "F879D8351B4B7F7C002D5C07"
BuildableName = "ObjectiveGit-iOSTests.xctest"
BlueprintName = "ObjectiveGit-iOSTests"
ReferencedContainer = "container:ObjectiveGitFramework.xcodeproj">
Expand Down
3 changes: 3 additions & 0 deletions ObjectiveGitFramework.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ObjectiveGitTests/ObjectiveGitTests-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.libgit2.${PRODUCT_NAME:rfc1034identifier}</string>
<string>org.libgit2.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
Expand Down
25 changes: 25 additions & 0 deletions ObjectiveGitTests/QuickSpec+GTFixtures.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#import "QuickSpec+GTFixtures.h"
#import <objc/runtime.h>

#if TARGET_OS_IPHONE
#import "SSZipArchive.h"
#endif

static const NSInteger FixturesErrorUnzipFailed = 666;

static NSString * const FixturesErrorDomain = @"com.objectivegit.Fixtures";
Expand Down Expand Up @@ -95,6 +99,24 @@ - (NSString *)pathForFixtureRepositoryNamed:(NSString *)repositoryName {
}

- (BOOL)unzipFile:(NSString *)member fromArchiveAtPath:(NSString *)zipPath intoDirectory:(NSString *)destinationPath error:(NSError **)error {

#if TARGET_OS_IPHONE
// iOS: unzip in-process using SSZipArchive
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to use SSZipArchive on both?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would certainly make things cleaner. My only concern is speed. The iOS tests are quite a bit slower than the Mac tests and I'm not sure why. I'll experiment with using SSZipArchive for the Mac tests to see if they slow down or not.

//
// system() and NSTask() are not available when running tests in the iOS simulator

BOOL success = [SSZipArchive unzipFileAtPath:zipPath toDestination:destinationPath overwrite:YES password:nil error:error];

if (!success) {
NSLog(@"Unzip failed");
return NO;
}

return YES;

#else
// OS X: shell out to unzip using NSTask

NSTask *task = [[NSTask alloc] init];
task.launchPath = @"/usr/bin/unzip";
task.arguments = @[ @"-qq", @"-d", destinationPath, zipPath, [member stringByAppendingString:@"*"] ];
Expand All @@ -108,6 +130,9 @@ - (BOOL)unzipFile:(NSString *)member fromArchiveAtPath:(NSString *)zipPath intoD
}

return success;

#endif

}

#pragma mark API
Expand Down
4 changes: 2 additions & 2 deletions script/cibuild
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ build_scheme ()
if [ "$awkstatus" -eq "1" ]
then
# SDK not found, try for iphonesimulator.
sdkflag="-sdk iphonesimulator"
sdkflag='-sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 5"'

# Determine whether the unit tests will run with iphonesimulator
run_xctool $sdkflag -scheme "$scheme" run-tests | parse_build
run_xctool "$sdkflag" -scheme "$scheme" run-tests | parse_build

awkstatus=$?

Expand Down