Skip to content

Commit 851cdb9

Browse files
committed
Updated podspec to have a Test Spec, and fixed all resulting errors and warnings (Issue #59)
1 parent 6e8152d commit 851cdb9

File tree

19 files changed

+157
-72
lines changed

19 files changed

+157
-72
lines changed

.travis.yml

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
11
language:
22
- objective-c
33

4-
osx_image: xcode9.2
4+
osx_image: xcode9.3
55

66
before_script:
77
# Make log level less verbose. Temporarily undo if more info is needed
88
- sudo log config --mode "level:default"
99

1010
matrix:
1111
include:
12-
- stage: Test
13-
env: Name=Mac-Tests-Zip64Large
14-
script: travis_wait 20 xcodebuild -workspace UnzipKit.xcworkspace -scheme UnzipKit -sdk macosx -configuration Release test -only-testing:UnzipKitTests/ExtractFilesTests/testExtractZip64_LargeFile ENABLE_NS_ASSERTIONS=1
15-
16-
- stage: Test
17-
env: Name=Mac-Tests-Zip64Many
18-
script: travis_wait 30 xcodebuild -workspace UnzipKit.xcworkspace -scheme UnzipKit -sdk macosx -configuration Release test -only-testing:UnzipKitTests/ExtractFilesTests/testExtractZip64_ManyFiles ENABLE_NS_ASSERTIONS=1
19-
20-
- stage: Test
21-
env: Name=Mac
22-
# The CLANG arguments and find command fail the build on analyzer errors
23-
script: xcodebuild -workspace UnzipKit.xcworkspace -scheme UnzipKit -sdk macosx -configuration Release analyze test -skip-testing:UnzipKitTests/ExtractFilesTests/testExtractZip64_LargeFile -skip-testing:UnzipKitTests/ExtractFilesTests/testExtractZip64_ManyFiles ENABLE_NS_ASSERTIONS=1 CLANG_ANALYZER_OUTPUT=html CLANG_ANALYZER_OUTPUT_DIR=analyzer-output && [[ -z `find analyzer-output -name "*.html"` ]]
24-
25-
- stage: Test
26-
env: Name=iOS
27-
# The CLANG arguments and find command fail the build on analyzer errors
28-
script: xcodebuild -workspace UnzipKit.xcworkspace -scheme UnzipKit -destination 'platform=iOS Simulator,name=iPhone 7,OS=latest' -configuration Release analyze test ENABLE_NS_ASSERTIONS=1 CLANG_ANALYZER_OUTPUT=html CLANG_ANALYZER_OUTPUT_DIR=analyzer-output && [[ -z `find analyzer-output -name "*.html"` ]]
29-
30-
- stage: Test
31-
env: Name=DemoAppBuild
32-
# The CLANG arguments and find command fail the build on analyzer errors
33-
script: ./Scripts/install-demo-libs.sh && xcodebuild -workspace UnzipKitDemo/UnzipKitDemo.xcworkspace -scheme UnzipKitDemo -sdk iphonesimulator -configuration Release analyze CLANG_ANALYZER_OUTPUT=html CLANG_ANALYZER_OUTPUT_DIR=analyzer-output && [[ -z `find analyzer-output -name "*.html"` ]]
34-
35-
- stage: Validate
36-
env: Name=CocoaPods
37-
script: ./Scripts/cocoapod-validate.sh
38-
39-
- stage: Validate
40-
env: Name=Carthage
41-
script: ./Scripts/carthage-validate.sh
42-
43-
- stage: Release
44-
if: tag IS present
45-
before_install: brew install python3
46-
script: ./Scripts/push-output.sh
12+
- stage: Test
13+
env: Name=Mac-Tests-Zip64Large
14+
script: travis_wait 20 xcodebuild -workspace UnzipKit.xcworkspace -scheme UnzipKit -sdk macosx -configuration Release test -only-testing:UnzipKitTests/ExtractFilesTests/testExtractZip64_LargeFile ENABLE_NS_ASSERTIONS=1
15+
16+
- stage: Test
17+
env: Name=Mac-Tests-Zip64Many
18+
script: travis_wait 30 xcodebuild -workspace UnzipKit.xcworkspace -scheme UnzipKit -sdk macosx -configuration Release test -only-testing:UnzipKitTests/ExtractFilesTests/testExtractZip64_ManyFiles ENABLE_NS_ASSERTIONS=1
19+
20+
- stage: Test
21+
env: Name=Mac
22+
# The CLANG arguments and find command fail the build on analyzer errors
23+
script: xcodebuild -workspace UnzipKit.xcworkspace -scheme UnzipKit -sdk macosx -configuration Release analyze test -skip-testing:UnzipKitTests/ExtractFilesTests/testExtractZip64_LargeFile -skip-testing:UnzipKitTests/ExtractFilesTests/testExtractZip64_ManyFiles ENABLE_NS_ASSERTIONS=1 CLANG_ANALYZER_OUTPUT=html CLANG_ANALYZER_OUTPUT_DIR=analyzer-output && [[ -z `find analyzer-output -name "*.html"` ]]
24+
25+
- stage: Test
26+
env: Name=iOS
27+
# The CLANG arguments and find command fail the build on analyzer errors
28+
script: xcodebuild -workspace UnzipKit.xcworkspace -scheme UnzipKit -destination 'platform=iOS Simulator,name=iPhone 7,OS=latest' -configuration Release analyze test ENABLE_NS_ASSERTIONS=1 CLANG_ANALYZER_OUTPUT=html CLANG_ANALYZER_OUTPUT_DIR=analyzer-output && [[ -z `find analyzer-output -name "*.html"` ]]
29+
30+
- stage: Test
31+
env: Name=DemoAppBuild
32+
# The CLANG arguments and find command fail the build on analyzer errors
33+
script: ./Scripts/install-demo-libs.sh && xcodebuild -workspace UnzipKitDemo/UnzipKitDemo.xcworkspace -scheme UnzipKitDemo -sdk iphonesimulator -configuration Release analyze CLANG_ANALYZER_OUTPUT=html CLANG_ANALYZER_OUTPUT_DIR=analyzer-output && [[ -z `find analyzer-output -name "*.html"` ]]
34+
35+
- stage: Validate
36+
env: Name=CocoaPods
37+
script: ./Scripts/cocoapod-validate.sh
38+
39+
- stage: Validate
40+
env: Name=Carthage
41+
script: ./Scripts/carthage-validate.sh
42+
43+
- stage: Release
44+
if: tag IS present
45+
before_install: brew install python3
46+
script: ./Scripts/push-output.sh
4747

4848
# Turn on Docker, container-based infrastructure
4949
sudo: false

Scripts/cocoapod-validate.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
#!/bin/bash
22

33
set -ev
4+
set -o pipefail
45

56
. Scripts/set-travis-tag-to-latest.sh
67

8+
pod env
9+
10+
# Work around bug in Xcode 9.3.0 (on Travis) that causes unit tests to crash when targeting
11+
# iOS 8.0. Remove when it's no longer necessary (as well as the `mv` at the end)
12+
sed -i '.original' 's/s.ios.deployment_target = "8.0"/s.ios.deployment_target = "9.0"/g' UnzipKit.podspec
13+
714
# Lint the podspec to check for errors. Don't call `pod spec lint`, because we want it to evaluate locally
8-
pod lib lint
15+
16+
# Using sed to remove logging from output until CocoaPods issue #7577 is implemented and I can use the
17+
# OS_ACTIVITY_MODE = disable environment variable from the test spec scheme
18+
pod lib lint --verbose | sed -l '/xctest\[/d; /^$/d'
19+
20+
# Restore previous version
21+
mv UnzipKit.podspec.original UnzipKit.podspec
922

1023
. Scripts/unset-travis-tag.sh

Scripts/set-travis-tag-to-latest.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/bash
22

3+
git fetch --tags
4+
35
if [ -z "$TRAVIS_TAG" ]; then
46
TRAVIS_TAG_SUBSTITUTED=1
57
export TRAVIS_TAG="$(git tag -l | tail -1)"
68
echo "Not a tagged build. Using last tag ($TRAVIS_TAG)..."
7-
fi
9+
fi

Source/UZKArchive.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ extern NSString *UZKErrorDomain;
163163
*
164164
* Comments are written in UTF-8, and read in UTF-8 and Windows/CP-1252, falling back to defaultCStringEncoding
165165
*/
166-
@property(atomic, nullable) NSString *comment;
166+
@property(retain, atomic, nullable) NSString *comment;
167167

168168
/**
169169
* Can be used for progress reporting, but it's not necessary. You can also use

Source/UZKArchive.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ - (nullable NSData *)extractDataFromFile:(NSString *)filePath
706706
BOOL success = [self extractBufferedDataFromFile:filePath
707707
error:&extractError
708708
action:^(NSData *dataChunk, CGFloat percentDecompressed) {
709-
UZKLogDebug("Appending data chunk of size %lu (%f%% complete)", (unsigned long)dataChunk.length, (double)percentDecompressed);
709+
UZKLogDebug("Appending data chunk of size %lu (%.3f%% complete)", (unsigned long)dataChunk.length, (double)percentDecompressed * 100);
710710

711711
if (progressBlock) {
712712
progressBlock(percentDecompressed);
@@ -893,7 +893,7 @@ - (BOOL)extractBufferedDataFromFile:(NSString *)filePath
893893
break;
894894
}
895895

896-
UZKLogDebug("bytesRead: %d", bytesRead);
896+
UZKLogDebug("bytesRead: %{iec-bytes}d (%d bytes)", bytesRead, bytesRead);
897897

898898
data.length = bytesRead;
899899
bytesDecompressed += bytesRead;
@@ -1222,7 +1222,7 @@ - (BOOL)writeData:(NSData *)data
12221222

12231223
if (progressBlock) {
12241224
double percentComplete = i / (double)data.length;
1225-
UZKLogDebug("Calling progress block at %f%%", percentComplete);
1225+
UZKLogDebug("Calling progress block at %.3f%%", percentComplete * 100);
12261226
progressBlock(percentComplete);
12271227
}
12281228
}
@@ -1353,7 +1353,7 @@ - (BOOL)writeIntoBuffer:(NSString *)filePath
13531353
}
13541354

13551355
BOOL result = action(^BOOL(const void *bytes, unsigned int length) {
1356-
UZKLogInfo("Writing %u bytes into archive from buffer", length);
1356+
UZKLogInfo("Writing %{iec-bytes}u (%u bytes) into archive from buffer", length, length);
13571357
int writeErr = zipWriteInFileInZip(self.zipFile, bytes, length);
13581358
if (writeErr != ZIP_OK) {
13591359
UZKLogError("Error writing data from buffer: %d", writeErr);
@@ -2405,7 +2405,7 @@ - (NSData *)readFile:(NSString *)filePath length:(unsigned long long int)length
24052405
return nil;
24062406
}
24072407

2408-
UZKLogDebug("%d bytes read", bytes);
2408+
UZKLogDebug("%{iec-bytes}d (%d bytes) read", bytes, bytes);
24092409
data.length = bytes;
24102410
return data;
24112411
}

Tests/DeleteFileTests.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ - (void)testDeleteFile_FirstFile
3434
: nil);
3535
UZKArchive *archive = [[UZKArchive alloc] initWithURL:testArchiveURL password:password error:nil];
3636

37-
NSError *deleteError;
37+
NSError *deleteError = nil;
3838
BOOL result = [archive deleteFile:fileToDelete error:&deleteError];
3939
XCTAssertTrue(result, @"Failed to delete %@ from %@", fileToDelete, testArchiveName);
4040
XCTAssertNil(deleteError, @"Error deleting %@ from %@", fileToDelete, testArchiveName);
@@ -78,7 +78,7 @@ - (void)testDeleteFile_SecondFile
7878
: nil);
7979
UZKArchive *archive = [[UZKArchive alloc] initWithURL:testArchiveURL password:password error:nil];
8080

81-
NSError *deleteError;
81+
NSError *deleteError = nil;
8282
BOOL result = [archive deleteFile:fileToDelete error:&deleteError];
8383
XCTAssertTrue(result, @"Failed to delete %@ from %@", fileToDelete, testArchiveName);
8484
XCTAssertNil(deleteError, @"Error deleting %@ from %@", fileToDelete, testArchiveName);
@@ -122,7 +122,7 @@ - (void)testDeleteFile_ThirdFile
122122
: nil);
123123
UZKArchive *archive = [[UZKArchive alloc] initWithURL:testArchiveURL password:password error:nil];
124124

125-
NSError *deleteError;
125+
NSError *deleteError = nil;
126126
BOOL result = [archive deleteFile:fileToDelete error:&deleteError];
127127
XCTAssertTrue(result, @"Failed to delete %@ from %@", fileToDelete, testArchiveName);
128128
XCTAssertNil(deleteError, @"Error deleting %@ from %@", fileToDelete, testArchiveName);

Tests/ExtractBufferedDataTests.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#import "UnzipKitMacros.h"
1313

1414

15+
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
1516
#import <sys/kdebug_signpost.h>
1617
enum SignPostCode: uint { // Use to reference in Instruments (http://stackoverflow.com/a/39416673/105717)
1718
SignPostCodeCreateTextFile = 0,
@@ -26,6 +27,7 @@
2627
SignPostColorOrange = 3,
2728
SignPostColorRed = 4,
2829
};
30+
#endif
2931

3032
@interface ExtractBufferedDataTests : UZKArchiveTestCase
3133
@end
@@ -61,7 +63,7 @@ - (void)testExtractBufferedData
6163
@"File extracted in buffer not returned correctly");
6264
}
6365

64-
#if !TARGET_OS_IPHONE
66+
#if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
6567
- (void)testExtractBufferedData_VeryLarge
6668
{
6769
kdebug_signpost_start(SignPostCodeCreateTextFile, 0, 0, 0, SignPostColorBlue);

Tests/FileDescriptorUsageTests.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ - (void)testFileDescriptorUsage_WriteIntoArchive
108108
NSFileManager *fm = [NSFileManager defaultManager];
109109

110110
for (NSInteger i = 0; i < 100; i++) {
111+
// Keep this test from stalling out the build
112+
printf("testFileDescriptorUsage_WriteIntoArchive: Iteration %ld/100\n", (long)i);
113+
111114
NSString *tempDir = [self randomDirectoryName];
112115
NSURL *tempDirURL = [self.tempDirectory URLByAppendingPathComponent:tempDir];
113116
NSURL *testArchiveCopyURL = [tempDirURL URLByAppendingPathComponent:testArchiveName];

Tests/ProgressReportingTests.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
@interface ProgressReportingTests : UZKArchiveTestCase
1414

15-
@property NSMutableArray<NSNumber*> *fractionsCompletedReported;
16-
@property NSMutableArray<NSString*> *descriptionsReported;
17-
@property NSMutableArray<NSString*> *additionalDescriptionsReported;
18-
@property NSMutableArray<UZKFileInfo*> *fileInfosReported;
15+
@property (retain) NSMutableArray<NSNumber*> *fractionsCompletedReported;
16+
@property (retain) NSMutableArray<NSString*> *descriptionsReported;
17+
@property (retain) NSMutableArray<NSString*> *additionalDescriptionsReported;
18+
@property (retain) NSMutableArray<UZKFileInfo*> *fileInfosReported;
1919

2020
@end
2121

@@ -571,6 +571,8 @@ - (void)observeValueForKeyPath:(NSString *)keyPath
571571
if ([object isKindOfClass:[NSProgress class]]) {
572572
progress = object;
573573
[self.fractionsCompletedReported addObject:@(progress.fractionCompleted)];
574+
} else {
575+
return;
574576
}
575577

576578
if (context == ExtractFilesContext) {

Tests/UZKArchiveTestCase.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121

2222
@property BOOL testFailed;
2323

24-
@property NSURL *tempDirectory;
25-
@property NSMutableDictionary<NSString*, NSURL*> *testFileURLs;
26-
@property NSMutableDictionary *unicodeFileURLs;
27-
@property NSSet *nonZipTestFilePaths;
28-
@property NSSet *nonZipUnicodeFilePaths;
29-
@property NSURL *corruptArchive;
24+
@property (retain) NSURL *tempDirectory;
25+
@property (retain) NSMutableDictionary<NSString*, NSURL*> *testFileURLs;
26+
@property (retain) NSMutableDictionary *unicodeFileURLs;
27+
@property (retain) NSSet *nonZipTestFilePaths;
28+
@property (retain) NSSet *nonZipUnicodeFilePaths;
29+
@property (retain) NSURL *corruptArchive;
3030

3131

3232
// Helper Methods

0 commit comments

Comments
 (0)