Skip to content

Commit ee64b5e

Browse files
authored
Merge branch 'main' into ks/remove-linuxmain.swift
2 parents d386ac9 + e146504 commit ee64b5e

File tree

5 files changed

+71
-53
lines changed

5 files changed

+71
-53
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ Add new items at the end of the relevant section under **Unreleased**.
1010

1111
---
1212

13+
## [1.0.2] - 2021-11-09
14+
15+
## Fixes
16+
17+
- Addresses an issue when building tests under Mac Catalyst.
18+
19+
The 1.0.2 release includes a contribution from [jakepetroules]. Thank you!
20+
1321
## [1.0.1] - 2021-09-14
1422

1523
## Fixes
@@ -535,7 +543,8 @@ This changelog's format is based on [Keep a Changelog](https://keepachangelog.co
535543

536544
<!-- Link references for releases -->
537545

538-
[Unreleased]: https://github.com/apple/swift-argument-parser/compare/1.0.1...HEAD
546+
[Unreleased]: https://github.com/apple/swift-argument-parser/compare/1.0.2...HEAD
547+
[1.0.2]: https://github.com/apple/swift-argument-parser/compare/1.0.1...1.0.2
539548
[1.0.1]: https://github.com/apple/swift-argument-parser/compare/1.0.0...1.0.1
540549
[1.0.0]: https://github.com/apple/swift-argument-parser/compare/0.5.0...1.0.0
541550
[0.5.0]: https://github.com/apple/swift-argument-parser/compare/0.4.4...0.5.0
@@ -608,6 +617,7 @@ This changelog's format is based on [Keep a Changelog](https://keepachangelog.co
608617
[imxieyi]: https://github.com/apple/swift-argument-parser/commits?author=imxieyi
609618
[IngmarStein]: https://github.com/apple/swift-argument-parser/commits?author=IngmarStein
610619
[interstateone]: https://github.com/apple/swift-argument-parser/commits?author=interstateone
620+
[jakepetroules]: https://github.com/apple/swift-argument-parser/commits?author=jakepetroules
611621
[john-mueller]: https://github.com/apple/swift-argument-parser/commits?author=john-mueller
612622
[jonathanpenn]: https://github.com/apple/swift-argument-parser/commits?author=jonathanpenn
613623
[kennyyork]: https://github.com/apple/swift-argument-parser/commits?author=kennyyork

Sources/ArgumentParserTestHelpers/TestHelpers.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ extension XCTest {
175175
command: String,
176176
expected: String? = nil,
177177
exitCode: ExitCode = .success,
178-
file: StaticString = #file, line: UInt = #line)
178+
file: StaticString = #file, line: UInt = #line) throws
179179
{
180180
let splitCommand = command.split(separator: " ")
181181
let arguments = splitCommand.dropFirst().map(String.init)
@@ -188,6 +188,7 @@ extension XCTest {
188188
return
189189
}
190190

191+
#if !canImport(Darwin) || os(macOS)
191192
let process = Process()
192193
if #available(macOS 10.13, *) {
193194
process.executableURL = commandURL
@@ -222,6 +223,9 @@ extension XCTest {
222223
}
223224

224225
XCTAssertEqual(process.terminationStatus, exitCode.rawValue, file: (file), line: line)
226+
#else
227+
throw XCTSkip("Not supported on this platform")
228+
#endif
225229
}
226230

227231
public func AssertJSONOutputEqual(
@@ -241,6 +245,7 @@ extension XCTest {
241245
return
242246
}
243247

248+
#if !canImport(Darwin) || os(macOS)
244249
let process = Process()
245250
if #available(macOS 10.13, *) {
246251
process.executableURL = commandURL
@@ -267,5 +272,8 @@ extension XCTest {
267272
let outputString = try XCTUnwrap(String(data: output.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8))
268273
XCTAssertTrue(error.fileHandleForReading.readDataToEndOfFile().isEmpty, "Error occurred with `--experimental-dump-help`")
269274
try AssertJSONEqualFromString(actual: outputString, expected: expected, for: ToolInfoV0.self)
275+
#else
276+
throw XCTSkip("Not supported on this platform")
277+
#endif
270278
}
271279
}

Tests/ArgumentParserExampleTests/MathExampleTests.swift

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import ArgumentParserTestHelpers
1515

1616
final class MathExampleTests: XCTestCase {
1717
func testMath_Simple() throws {
18-
AssertExecuteCommand(command: "math 1 2 3 4 5", expected: "15")
19-
AssertExecuteCommand(command: "math multiply 1 2 3 4 5", expected: "120")
18+
try AssertExecuteCommand(command: "math 1 2 3 4 5", expected: "15")
19+
try AssertExecuteCommand(command: "math multiply 1 2 3 4 5", expected: "120")
2020
}
2121

2222
func testMath_Help() throws {
@@ -37,9 +37,9 @@ final class MathExampleTests: XCTestCase {
3737
See 'math help <subcommand>' for detailed help.
3838
"""
3939

40-
AssertExecuteCommand(command: "math -h", expected: helpText)
41-
AssertExecuteCommand(command: "math --help", expected: helpText)
42-
AssertExecuteCommand(command: "math help", expected: helpText)
40+
try AssertExecuteCommand(command: "math -h", expected: helpText)
41+
try AssertExecuteCommand(command: "math --help", expected: helpText)
42+
try AssertExecuteCommand(command: "math help", expected: helpText)
4343
}
4444

4545
func testMath_AddHelp() throws {
@@ -57,14 +57,14 @@ final class MathExampleTests: XCTestCase {
5757
-h, --help Show help information.
5858
"""
5959

60-
AssertExecuteCommand(command: "math add -h", expected: helpText)
61-
AssertExecuteCommand(command: "math add --help", expected: helpText)
62-
AssertExecuteCommand(command: "math help add", expected: helpText)
60+
try AssertExecuteCommand(command: "math add -h", expected: helpText)
61+
try AssertExecuteCommand(command: "math add --help", expected: helpText)
62+
try AssertExecuteCommand(command: "math help add", expected: helpText)
6363

6464
// Verify that extra help flags are ignored.
65-
AssertExecuteCommand(command: "math help add -h", expected: helpText)
66-
AssertExecuteCommand(command: "math help add -help", expected: helpText)
67-
AssertExecuteCommand(command: "math help add --help", expected: helpText)
65+
try AssertExecuteCommand(command: "math help add -h", expected: helpText)
66+
try AssertExecuteCommand(command: "math help add -help", expected: helpText)
67+
try AssertExecuteCommand(command: "math help add --help", expected: helpText)
6868
}
6969

7070
func testMath_StatsMeanHelp() throws {
@@ -82,9 +82,9 @@ final class MathExampleTests: XCTestCase {
8282
-h, --help Show help information.
8383
"""
8484

85-
AssertExecuteCommand(command: "math stats average -h", expected: helpText)
86-
AssertExecuteCommand(command: "math stats average --help", expected: helpText)
87-
AssertExecuteCommand(command: "math help stats average", expected: helpText)
85+
try AssertExecuteCommand(command: "math stats average -h", expected: helpText)
86+
try AssertExecuteCommand(command: "math stats average --help", expected: helpText)
87+
try AssertExecuteCommand(command: "math help stats average", expected: helpText)
8888
}
8989

9090
func testMath_StatsQuantilesHelp() throws {
@@ -109,15 +109,15 @@ final class MathExampleTests: XCTestCase {
109109

110110
// The "quantiles" subcommand's run() method is unimplemented, so it
111111
// just generates the help text.
112-
AssertExecuteCommand(command: "math stats quantiles", expected: helpText)
112+
try AssertExecuteCommand(command: "math stats quantiles", expected: helpText)
113113

114-
AssertExecuteCommand(command: "math stats quantiles -h", expected: helpText)
115-
AssertExecuteCommand(command: "math stats quantiles --help", expected: helpText)
116-
AssertExecuteCommand(command: "math help stats quantiles", expected: helpText)
114+
try AssertExecuteCommand(command: "math stats quantiles -h", expected: helpText)
115+
try AssertExecuteCommand(command: "math stats quantiles --help", expected: helpText)
116+
try AssertExecuteCommand(command: "math help stats quantiles", expected: helpText)
117117
}
118118

119119
func testMath_CustomValidation() throws {
120-
AssertExecuteCommand(
120+
try AssertExecuteCommand(
121121
command: "math stats average --kind mode",
122122
expected: """
123123
Error: Please provide at least one value to calculate the mode.
@@ -128,38 +128,38 @@ final class MathExampleTests: XCTestCase {
128128
}
129129

130130
func testMath_Versions() throws {
131-
AssertExecuteCommand(
131+
try AssertExecuteCommand(
132132
command: "math --version",
133133
expected: "1.0.0")
134-
AssertExecuteCommand(
134+
try AssertExecuteCommand(
135135
command: "math stats --version",
136136
expected: "1.0.0")
137-
AssertExecuteCommand(
137+
try AssertExecuteCommand(
138138
command: "math stats average --version",
139139
expected: "1.5.0-alpha")
140140
}
141141

142142
func testMath_ExitCodes() throws {
143-
AssertExecuteCommand(
143+
try AssertExecuteCommand(
144144
command: "math stats quantiles --test-success-exit-code",
145145
expected: "",
146146
exitCode: .success)
147-
AssertExecuteCommand(
147+
try AssertExecuteCommand(
148148
command: "math stats quantiles --test-failure-exit-code",
149149
expected: "",
150150
exitCode: .failure)
151-
AssertExecuteCommand(
151+
try AssertExecuteCommand(
152152
command: "math stats quantiles --test-validation-exit-code",
153153
expected: "",
154154
exitCode: .validationFailure)
155-
AssertExecuteCommand(
155+
try AssertExecuteCommand(
156156
command: "math stats quantiles --test-custom-exit-code 42",
157157
expected: "",
158158
exitCode: ExitCode(42))
159159
}
160160

161161
func testMath_Fail() throws {
162-
AssertExecuteCommand(
162+
try AssertExecuteCommand(
163163
command: "math --foo",
164164
expected: """
165165
Error: Unknown option '--foo'
@@ -168,7 +168,7 @@ final class MathExampleTests: XCTestCase {
168168
""",
169169
exitCode: .validationFailure)
170170

171-
AssertExecuteCommand(
171+
try AssertExecuteCommand(
172172
command: "math ZZZ",
173173
expected: """
174174
Error: The value 'ZZZ' is invalid for '<values>'
@@ -183,45 +183,45 @@ final class MathExampleTests: XCTestCase {
183183
// MARK: - Completion Script
184184

185185
extension MathExampleTests {
186-
func testMath_CompletionScript() {
187-
AssertExecuteCommand(
186+
func testMath_CompletionScript() throws {
187+
try AssertExecuteCommand(
188188
command: "math --generate-completion-script=bash",
189189
expected: bashCompletionScriptText)
190-
AssertExecuteCommand(
190+
try AssertExecuteCommand(
191191
command: "math --generate-completion-script bash",
192192
expected: bashCompletionScriptText)
193-
AssertExecuteCommand(
193+
try AssertExecuteCommand(
194194
command: "math --generate-completion-script=zsh",
195195
expected: zshCompletionScriptText)
196-
AssertExecuteCommand(
196+
try AssertExecuteCommand(
197197
command: "math --generate-completion-script zsh",
198198
expected: zshCompletionScriptText)
199-
AssertExecuteCommand(
199+
try AssertExecuteCommand(
200200
command: "math --generate-completion-script=fish",
201201
expected: fishCompletionScriptText)
202-
AssertExecuteCommand(
202+
try AssertExecuteCommand(
203203
command: "math --generate-completion-script fish",
204204
expected: fishCompletionScriptText)
205205
}
206206

207-
func testMath_CustomCompletion() {
208-
AssertExecuteCommand(
207+
func testMath_CustomCompletion() throws {
208+
try AssertExecuteCommand(
209209
command: "math ---completion stats quantiles -- --custom",
210210
expected: """
211211
hello
212212
helicopter
213213
heliotrope
214214
""")
215215

216-
AssertExecuteCommand(
216+
try AssertExecuteCommand(
217217
command: "math ---completion stats quantiles -- --custom h",
218218
expected: """
219219
hello
220220
helicopter
221221
heliotrope
222222
""")
223223

224-
AssertExecuteCommand(
224+
try AssertExecuteCommand(
225225
command: "math ---completion stats quantiles -- --custom a",
226226
expected: """
227227
aardvark

Tests/ArgumentParserExampleTests/RepeatExampleTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import ArgumentParserTestHelpers
1515

1616
final class RepeatExampleTests: XCTestCase {
1717
func testRepeat() throws {
18-
AssertExecuteCommand(command: "repeat hello --count 6", expected: """
18+
try AssertExecuteCommand(command: "repeat hello --count 6", expected: """
1919
hello
2020
hello
2121
hello
@@ -38,12 +38,12 @@ final class RepeatExampleTests: XCTestCase {
3838
-h, --help Show help information.
3939
"""
4040

41-
AssertExecuteCommand(command: "repeat -h", expected: helpText)
42-
AssertExecuteCommand(command: "repeat --help", expected: helpText)
41+
try AssertExecuteCommand(command: "repeat -h", expected: helpText)
42+
try AssertExecuteCommand(command: "repeat --help", expected: helpText)
4343
}
4444

4545
func testRepeat_Fail() throws {
46-
AssertExecuteCommand(
46+
try AssertExecuteCommand(
4747
command: "repeat",
4848
expected: """
4949
Error: Missing expected argument '<phrase>'
@@ -60,7 +60,7 @@ final class RepeatExampleTests: XCTestCase {
6060
""",
6161
exitCode: .validationFailure)
6262

63-
AssertExecuteCommand(
63+
try AssertExecuteCommand(
6464
command: "repeat hello --count",
6565
expected: """
6666
Error: Missing value for '--count <count>'
@@ -70,7 +70,7 @@ final class RepeatExampleTests: XCTestCase {
7070
""",
7171
exitCode: .validationFailure)
7272

73-
AssertExecuteCommand(
73+
try AssertExecuteCommand(
7474
command: "repeat hello --count ZZZ",
7575
expected: """
7676
Error: The value 'ZZZ' is invalid for '--count <count>'
@@ -80,7 +80,7 @@ final class RepeatExampleTests: XCTestCase {
8080
""",
8181
exitCode: .validationFailure)
8282

83-
AssertExecuteCommand(
83+
try AssertExecuteCommand(
8484
command: "repeat --version hello",
8585
expected: """
8686
Error: Unknown option '--version'

Tests/ArgumentParserExampleTests/RollDiceExampleTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import ArgumentParserTestHelpers
1515

1616
final class RollDiceExampleTests: XCTestCase {
1717
func testRollDice() throws {
18-
AssertExecuteCommand(command: "roll --times 6")
18+
try AssertExecuteCommand(command: "roll --times 6")
1919
}
2020

2121
func testRollDice_Help() throws {
@@ -31,12 +31,12 @@ final class RollDiceExampleTests: XCTestCase {
3131
-h, --help Show help information.
3232
"""
3333

34-
AssertExecuteCommand(command: "roll -h", expected: helpText)
35-
AssertExecuteCommand(command: "roll --help", expected: helpText)
34+
try AssertExecuteCommand(command: "roll -h", expected: helpText)
35+
try AssertExecuteCommand(command: "roll --help", expected: helpText)
3636
}
3737

3838
func testRollDice_Fail() throws {
39-
AssertExecuteCommand(
39+
try AssertExecuteCommand(
4040
command: "roll --times",
4141
expected: """
4242
Error: Missing value for '--times <n>'
@@ -46,7 +46,7 @@ final class RollDiceExampleTests: XCTestCase {
4646
""",
4747
exitCode: .validationFailure)
4848

49-
AssertExecuteCommand(
49+
try AssertExecuteCommand(
5050
command: "roll --times ZZZ",
5151
expected: """
5252
Error: The value 'ZZZ' is invalid for '--times <n>'

0 commit comments

Comments
 (0)