From 69d131d4d9e1b7adf00d1f8b67a3e9d546a3f0ad Mon Sep 17 00:00:00 2001 From: Steve Moser Date: Wed, 13 Jan 2016 12:00:32 -0500 Subject: [PATCH 1/4] Convert from OCUnit to XCTest --- momdec.xcodeproj/project.pbxproj | 25 +++++++++++++------------ momdecTests/momdecTests.h | 4 ++-- momdecTests/momdecTests.m | 14 +++++++------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/momdec.xcodeproj/project.pbxproj b/momdec.xcodeproj/project.pbxproj index d2e27c9..6cedba2 100644 --- a/momdec.xcodeproj/project.pbxproj +++ b/momdec.xcodeproj/project.pbxproj @@ -9,7 +9,6 @@ /* Begin PBXBuildFile section */ EE22DD4117166355007FE629 /* NSFetchRequest+xmlElement.m in Sources */ = {isa = PBXBuildFile; fileRef = EE22DD4017166355007FE629 /* NSFetchRequest+xmlElement.m */; }; EE22DD4217166355007FE629 /* NSFetchRequest+xmlElement.m in Sources */ = {isa = PBXBuildFile; fileRef = EE22DD4017166355007FE629 /* NSFetchRequest+xmlElement.m */; }; - EE7EC7951714BB6D00A1901C /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE7EC7941714BB6D00A1901C /* SenTestingKit.framework */; }; EE7EC7971714BB6D00A1901C /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE7EC7961714BB6D00A1901C /* Cocoa.framework */; }; EE7EC7A11714BB6D00A1901C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = EE7EC79F1714BB6D00A1901C /* InfoPlist.strings */; }; EE7EC7A41714BB6D00A1901C /* momdecTests.m in Sources */ = {isa = PBXBuildFile; fileRef = EE7EC7A31714BB6D00A1901C /* momdecTests.m */; }; @@ -61,8 +60,7 @@ EE22DD3F17166355007FE629 /* NSFetchRequest+xmlElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSFetchRequest+xmlElement.h"; sourceTree = ""; }; EE22DD4017166355007FE629 /* NSFetchRequest+xmlElement.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSFetchRequest+xmlElement.m"; sourceTree = ""; }; EE2760C717121F7C0023821E /* README.md */ = {isa = PBXFileReference; lastKnownFileType = text; path = README.md; sourceTree = SOURCE_ROOT; }; - EE7EC7931714BB6D00A1901C /* momdecTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = momdecTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; - EE7EC7941714BB6D00A1901C /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; + EE7EC7931714BB6D00A1901C /* momdecTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = momdecTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; EE7EC7961714BB6D00A1901C /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = Library/Frameworks/Cocoa.framework; sourceTree = DEVELOPER_DIR; }; EE7EC7991714BB6D00A1901C /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; EE7EC79A1714BB6D00A1901C /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; @@ -100,7 +98,6 @@ buildActionMask = 2147483647; files = ( EE7EC7AE1714BC1C00A1901C /* CoreData.framework in Frameworks */, - EE7EC7951714BB6D00A1901C /* SenTestingKit.framework in Frameworks */, EE7EC7971714BB6D00A1901C /* Cocoa.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -162,7 +159,7 @@ isa = PBXGroup; children = ( EEE16BAA1710D68900F6AF6B /* momdec */, - EE7EC7931714BB6D00A1901C /* momdecTests.octest */, + EE7EC7931714BB6D00A1901C /* momdecTests.xctest */, ); name = Products; sourceTree = ""; @@ -172,7 +169,6 @@ children = ( EEE16BBB1710D6A300F6AF6B /* CoreData.framework */, EEE16BAD1710D68900F6AF6B /* Foundation.framework */, - EE7EC7941714BB6D00A1901C /* SenTestingKit.framework */, EE7EC7961714BB6D00A1901C /* Cocoa.framework */, EE7EC7981714BB6D00A1901C /* Other Frameworks */, ); @@ -232,8 +228,8 @@ ); name = momdecTests; productName = momdecTests; - productReference = EE7EC7931714BB6D00A1901C /* momdecTests.octest */; - productType = "com.apple.product-type.bundle"; + productReference = EE7EC7931714BB6D00A1901C /* momdecTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; }; EEE16BA91710D68900F6AF6B /* momdec */ = { isa = PBXNativeTarget; @@ -258,6 +254,7 @@ EEE16BA21710D68900F6AF6B /* Project object */ = { isa = PBXProject; attributes = { + LastTestingUpgradeCheck = 0720; LastUpgradeCheck = 0460; ORGANIZATIONNAME = "Tom Harrington"; }; @@ -356,12 +353,14 @@ isa = XCBuildConfiguration; buildSettings = { COMBINE_HIDPI_IMAGES = YES; - FRAMEWORK_SEARCH_PATHS = "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\""; + FRAMEWORK_SEARCH_PATHS = ( + "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", + "$(inherited)", + ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "momdecTests/momdecTests-Prefix.pch"; INFOPLIST_FILE = "momdecTests/momdecTests-Info.plist"; PRODUCT_NAME = "$(TARGET_NAME)"; - WRAPPER_EXTENSION = octest; }; name = Debug; }; @@ -369,12 +368,14 @@ isa = XCBuildConfiguration; buildSettings = { COMBINE_HIDPI_IMAGES = YES; - FRAMEWORK_SEARCH_PATHS = "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\""; + FRAMEWORK_SEARCH_PATHS = ( + "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", + "$(inherited)", + ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "momdecTests/momdecTests-Prefix.pch"; INFOPLIST_FILE = "momdecTests/momdecTests-Info.plist"; PRODUCT_NAME = "$(TARGET_NAME)"; - WRAPPER_EXTENSION = octest; }; name = Release; }; diff --git a/momdecTests/momdecTests.h b/momdecTests/momdecTests.h index 49ddcbe..5782082 100644 --- a/momdecTests/momdecTests.h +++ b/momdecTests/momdecTests.h @@ -6,8 +6,8 @@ // Copyright (c) 2013 Tom Harrington. All rights reserved. // -#import +#import -@interface momdecTests : SenTestCase +@interface momdecTests : XCTestCase @end diff --git a/momdecTests/momdecTests.m b/momdecTests/momdecTests.m index c925b13..e145f67 100644 --- a/momdecTests/momdecTests.m +++ b/momdecTests/momdecTests.m @@ -40,14 +40,14 @@ - (void)testDecompile [[NSFileManager defaultManager] createDirectoryAtPath:momdecTestDir withIntermediateDirectories:YES attributes:0 error:nil]; NSError *error = nil; NSString *decompiledModelContainerPath = [NSManagedObjectModel decompileModelAtPath:[momURL path] inDirectory:momdecTestDir error:&error]; - STAssertNil(error, [NSString stringWithFormat:@"Error decompiling model: %@", error]); - STAssertTrue(([decompiledModelContainerPath length] > 0), @"Zero-length path after decompiling model"); + XCTAssertNil(error, @"Error decompiling model: %@", error); + XCTAssertTrue(([decompiledModelContainerPath length] > 0), @"Zero-length path after decompiling model"); // Compile the temporary file copy NSString *recompiledModelPath = [momdecTestDir stringByAppendingPathComponent:@"momdecTests.momd"]; NSTask *compileTask = [NSTask launchedTaskWithLaunchPath:@"/usr/bin/xcrun" arguments:@[@"momc", decompiledModelContainerPath, recompiledModelPath]]; [compileTask waitUntilExit]; - STAssertEquals([compileTask terminationStatus], 0, @"xcrun failed to compile the model, try running 'xcrun momc' in Terminal.app and trying again"); + XCTAssertEqual([compileTask terminationStatus], 0, @"xcrun failed to compile the model, try running 'xcrun momc' in Terminal.app and trying again"); // Load the recompiled model NSManagedObjectModel *recompiledModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:[NSURL fileURLWithPath:recompiledModelPath]]; @@ -58,7 +58,7 @@ - (void)testDecompile for (NSString *entityName in originalEntities) { NSEntityDescription *originalEntity = originalEntities[entityName]; NSEntityDescription *recompiledEntity = recompiledEntities[entityName]; - STAssertEqualObjects(originalEntity, recompiledEntity, @"Entities do not match: %@", entityName); + XCTAssertEqualObjects(originalEntity, recompiledEntity, @"Entities do not match: %@", entityName); } NSDictionary *originalFetchRequests = [compiledModel fetchRequestTemplatesByName]; @@ -66,12 +66,12 @@ - (void)testDecompile for (NSString *fetchRequestName in originalFetchRequests) { NSFetchRequest *originalFetchRequest = originalFetchRequests[fetchRequestName]; NSFetchRequest *recompiledFetchRequest = recompiledFetchRequests[fetchRequestName]; - STAssertEqualObjects(originalFetchRequest, recompiledFetchRequest, @"Fetch requests do not match: %@", fetchRequestName); + XCTAssertEqualObjects(originalFetchRequest, recompiledFetchRequest, @"Fetch requests do not match: %@", fetchRequestName); } NSArray *originalConfigurations = [compiledModel configurations]; for (NSString *configurationName in originalConfigurations) { - STAssertEqualObjects([compiledModel entitiesForConfiguration:configurationName], [recompiledModel entitiesForConfiguration:configurationName], @"Configuration does not match: %@", configurationName); + XCTAssertEqualObjects([compiledModel entitiesForConfiguration:configurationName], [recompiledModel entitiesForConfiguration:configurationName], @"Configuration does not match: %@", configurationName); } } @@ -86,7 +86,7 @@ - (void)testPropertyDescriptionException exceptionThrown = YES; } @finally { - STAssertTrue(exceptionThrown, @"NSPropertyDescription should throw an exception if you ask for its xmlElement"); + XCTAssertTrue(exceptionThrown, @"NSPropertyDescription should throw an exception if you ask for its xmlElement"); } } From e9e53cf63d1808bb560d27dea146f9086e43903f Mon Sep 17 00:00:00 2001 From: Steve Moser Date: Wed, 13 Jan 2016 12:01:42 -0500 Subject: [PATCH 2/4] Fix stringWithFormat integer type --- momdec/NSFetchRequest+xmlElement.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/momdec/NSFetchRequest+xmlElement.m b/momdec/NSFetchRequest+xmlElement.m index 5ced82b..1043d04 100644 --- a/momdec/NSFetchRequest+xmlElement.m +++ b/momdec/NSFetchRequest+xmlElement.m @@ -19,7 +19,7 @@ - (NSXMLElement *)xmlElement // The following will have no effect on models compiled with Xcode until rdar://problem/13863607 is fixed, // because these attributes get stripped out at compile time. // Also see http://www.openradar.me/radar?id=3009404 - NSString *resultTypeString = [NSString stringWithFormat:@"%d", NSManagedObjectResultType]; + NSString *resultTypeString = [NSString stringWithFormat:@"%luu",(unsigned long) (unsigned long)NSManagedObjectResultType]; [element addAttribute:[NSXMLNode attributeWithName:@"resultType" stringValue:resultTypeString]]; NSString *fetchLimitString = [NSString stringWithFormat:@"%ld", (unsigned long)[self fetchLimit]]; From be1acc733c8e1103f8bab7e05e2f47d155750cfc Mon Sep 17 00:00:00 2001 From: Steve Moser Date: Wed, 13 Jan 2016 12:03:09 -0500 Subject: [PATCH 3/4] Remove RunUnitTests script http://stackoverflow.com/questions/32743321/objective-c-warning-rununitt ests-is-obsolete-xcode-7 --- momdec.xcodeproj/project.pbxproj | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/momdec.xcodeproj/project.pbxproj b/momdec.xcodeproj/project.pbxproj index 6cedba2..f47a6ce 100644 --- a/momdec.xcodeproj/project.pbxproj +++ b/momdec.xcodeproj/project.pbxproj @@ -219,7 +219,6 @@ EE7EC78E1714BB6D00A1901C /* Sources */, EE7EC78F1714BB6D00A1901C /* Frameworks */, EE7EC7901714BB6D00A1901C /* Resources */, - EE7EC7911714BB6D00A1901C /* ShellScript */, EE7EC7AF1714BC3800A1901C /* CopyFiles */, ); buildRules = ( @@ -287,22 +286,6 @@ }; /* End PBXResourcesBuildPhase section */ -/* Begin PBXShellScriptBuildPhase section */ - EE7EC7911714BB6D00A1901C /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ EE7EC78E1714BB6D00A1901C /* Sources */ = { isa = PBXSourcesBuildPhase; From 565b06333c3715a2566cdcf26abe210e03524ba3 Mon Sep 17 00:00:00 2001 From: Steve Moser Date: Wed, 13 Jan 2016 12:03:37 -0500 Subject: [PATCH 4/4] Update project settings --- momdec.xcodeproj/project.pbxproj | 7 ++++--- .../xcshareddata/xcschemes/momdec.xcscheme | 19 ++++++++++++------- .../xcschemes/momdecTests.xcscheme | 13 ++++++++----- momdecTests/momdecTests-Info.plist | 2 +- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/momdec.xcodeproj/project.pbxproj b/momdec.xcodeproj/project.pbxproj index f47a6ce..0ff15a2 100644 --- a/momdec.xcodeproj/project.pbxproj +++ b/momdec.xcodeproj/project.pbxproj @@ -254,7 +254,7 @@ isa = PBXProject; attributes = { LastTestingUpgradeCheck = 0720; - LastUpgradeCheck = 0460; + LastUpgradeCheck = 0720; ORGANIZATIONNAME = "Tom Harrington"; }; buildConfigurationList = EEE16BA51710D68900F6AF6B /* Build configuration list for PBXProject "momdec" */; @@ -343,6 +343,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "momdecTests/momdecTests-Prefix.pch"; INFOPLIST_FILE = "momdecTests/momdecTests-Info.plist"; + PRODUCT_BUNDLE_IDENTIFIER = "com.atomicbird.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -358,6 +359,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "momdecTests/momdecTests-Prefix.pch"; INFOPLIST_FILE = "momdecTests/momdecTests-Info.plist"; + PRODUCT_BUNDLE_IDENTIFIER = "com.atomicbird.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; @@ -366,7 +368,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; @@ -376,6 +377,7 @@ CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; @@ -399,7 +401,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; diff --git a/momdec.xcodeproj/xcshareddata/xcschemes/momdec.xcscheme b/momdec.xcodeproj/xcshareddata/xcschemes/momdec.xcscheme index d6391ef..6652625 100644 --- a/momdec.xcodeproj/xcshareddata/xcschemes/momdec.xcscheme +++ b/momdec.xcodeproj/xcshareddata/xcschemes/momdec.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -48,17 +48,21 @@ ReferencedContainer = "container:momdec.xcodeproj"> + + - + - + + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -23,24 +23,27 @@ + + CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - com.atomicbird.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundlePackageType