@@ -42,4 +42,75 @@ - (void)testArchiveActionTriggersBuildForProjectAndScheme
42
42
}];
43
43
}
44
44
45
+ - (void )testArchiveWithFailingCommandShouldFail
46
+ {
47
+ [[FakeTaskManager sharedManager ] runBlockWithFakeTasks: ^{
48
+ [[FakeTaskManager sharedManager ] addLaunchHandlerBlocks: @[
49
+ // Make sure -showBuildSettings returns some data
50
+ [LaunchHandlers handlerForShowBuildSettingsWithProject: TEST_DATA @" TestProject-App-OSX/TestProject-App-OSX.xcodeproj"
51
+ scheme: @" TestProject-App-OSX"
52
+ settingsPath: TEST_DATA @" TestProject-App-OSX-showBuildSettings.txt" ],
53
+ [[^(FakeTask *task){
54
+ if ([[task launchPath ] hasSuffix: @" xcodebuild" ] &&
55
+ [[task arguments ] containsObject: @" archive" ])
56
+ {
57
+ [task pretendTaskReturnsStandardOutput:
58
+ [NSString stringWithContentsOfFile: TEST_DATA @" xcodebuild-archive-bad.txt"
59
+ encoding: NSUTF8StringEncoding
60
+ error: nil ]];
61
+ // Even when archive fails, 'xcodebuild' returns zero.
62
+ [task pretendExitStatusOf: 0 ];
63
+ }
64
+ } copy] autorelease ],
65
+ ]];
66
+
67
+ XCTool *tool = [[[XCTool alloc ] init ] autorelease ];
68
+
69
+ tool.arguments = @[@" -project" , TEST_DATA @" TestProject-App-OSX/TestProject-App-OSX.xcodeproj" ,
70
+ @" -scheme" , @" TestProject-App-OSX" ,
71
+ @" archive" ,
72
+ ];
73
+
74
+ NSDictionary *output = [TestUtil runWithFakeStreams: tool];
75
+
76
+ assertThatInt ([tool exitStatus ], equalToInt (1 ));
77
+ assertThat (output[@" stdout" ], containsString (@" ** ARCHIVE FAILED **" ));
78
+ }];
79
+ }
80
+
81
+ - (void )testArchiveWithAllPassingCommandsShouldSucceed
82
+ {
83
+ [[FakeTaskManager sharedManager ] runBlockWithFakeTasks: ^{
84
+ [[FakeTaskManager sharedManager ] addLaunchHandlerBlocks: @[
85
+ // Make sure -showBuildSettings returns some data
86
+ [LaunchHandlers handlerForShowBuildSettingsWithProject: TEST_DATA @" TestProject-App-OSX/TestProject-App-OSX.xcodeproj"
87
+ scheme: @" TestProject-App-OSX"
88
+ settingsPath: TEST_DATA @" TestProject-App-OSX-showBuildSettings.txt" ],
89
+ [[^(FakeTask *task){
90
+ if ([[task launchPath ] hasSuffix: @" xcodebuild" ] &&
91
+ [[task arguments ] containsObject: @" archive" ])
92
+ {
93
+ [task pretendTaskReturnsStandardOutput:
94
+ [NSString stringWithContentsOfFile: TEST_DATA @" xcodebuild-archive-good.txt"
95
+ encoding: NSUTF8StringEncoding
96
+ error: nil ]];
97
+ [task pretendExitStatusOf: 0 ];
98
+ }
99
+ } copy] autorelease ],
100
+ ]];
101
+
102
+ XCTool *tool = [[[XCTool alloc ] init ] autorelease ];
103
+
104
+ tool.arguments = @[@" -project" , TEST_DATA @" TestProject-App-OSX/TestProject-App-OSX.xcodeproj" ,
105
+ @" -scheme" , @" TestProject-App-OSX" ,
106
+ @" archive" ,
107
+ ];
108
+
109
+ NSDictionary *output = [TestUtil runWithFakeStreams: tool];
110
+
111
+ assertThatInt ([tool exitStatus ], equalToInt (0 ));
112
+ assertThat (output[@" stdout" ], containsString (@" ** ARCHIVE SUCCEEDED **" ));
113
+ }];
114
+ }
115
+
45
116
@end
0 commit comments