Skip to content

Commit 47fe00c

Browse files
authored
Enable more ci (#712)
Enables and fixes issues with additional platform tests and the formatter with these additional rules: - UseLetInEveryBoundCaseVariable - NeverForceUnwrap - BeginDocumentationCommentWithOneLineSummary - ValidateDocumentationComments - AlwaysUseCamelCase
1 parent 462737a commit 47fe00c

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ jobs:
2020
curl -sL https://raw.githubusercontent.com/apple/swift-mmio/refs/heads/main/.swift-format -o .swift-format-mmio
2121
diff .swift-format .swift-format-mmio
2222
23+
tests:
24+
name: Test
25+
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
26+
with:
27+
windows_exclude_swift_versions: "[{\"swift_version\": \"5.9\"}]"
2328
soundness:
2429
name: Soundness
2530
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main

Sources/ArgumentParserTestHelpers/StringHelpers.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,10 @@ extension String {
2525
.map { $0.trimmed() }
2626
.joined(separator: "\n")
2727
}
28+
29+
public func normalizingLineEndings() -> String {
30+
self
31+
.replacingOccurrences(of: "\r\n", with: "\n")
32+
.replacingOccurrences(of: "\r", with: "\n")
33+
}
2834
}

Sources/ArgumentParserTestHelpers/TestHelpers.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ public func AssertEqualStrings(
161161
file: StaticString = #filePath,
162162
line: UInt = #line
163163
) {
164+
// Normalize line endings to '\n'.
165+
let actual = actual.normalizingLineEndings()
166+
let expected = expected.normalizingLineEndings()
167+
164168
// If the input strings are not equal, create a simple diff for debugging...
165169
guard actual != expected else {
166170
// Otherwise they are equal, early exit.

Tests/ArgumentParserUnitTests/CompletionScriptTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ extension CompletionScriptTests {
169169
file: StaticString = #filePath,
170170
line: UInt = #line
171171
) throws {
172+
#if !os(Windows) && !os(WASI)
172173
do {
173174
setenv("SAP_SHELL", shell, 1)
174175
defer { unsetenv("SAP_SHELL") }
@@ -189,13 +190,15 @@ extension CompletionScriptTests {
189190
file: file,
190191
line: line)
191192
}
193+
#endif
192194
}
193195

194196
func assertCustomCompletions(
195197
shell: String,
196198
file: StaticString = #filePath,
197199
line: UInt = #line
198200
) throws {
201+
#if !os(Windows) && !os(WASI)
199202
try assertCustomCompletion(
200203
"-o", shell: shell, prefix: "e", file: file, line: line)
201204
try assertCustomCompletion(
@@ -211,6 +214,7 @@ extension CompletionScriptTests {
211214
try assertCustomCompletion("--bad", shell: shell, file: file, line: line))
212215
XCTAssertThrowsError(
213216
try assertCustomCompletion("four", shell: shell, file: file, line: line))
217+
#endif
214218
}
215219

216220
func testBashCustomCompletions() throws {

Tests/ArgumentParserUnitTests/HelpGenerationTests.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ extension Foundation.URL: ArgumentParser.ExpressibleByArgument {
2626
}
2727

2828
public var defaultValueDescription: String {
29-
self.path == FileManager.default.currentDirectoryPath && self.isFileURL
30-
? "current directory"
31-
: String(describing: self)
29+
self.path
3230
}
3331
}
3432

@@ -189,8 +187,7 @@ extension HelpGenerationTests {
189187
var degree: Degree = .bachelor
190188

191189
@Option(help: "Directory.")
192-
var directory: URL = URL(
193-
fileURLWithPath: FileManager.default.currentDirectoryPath)
190+
var directory: URL = URL(fileURLWithPath: "/path/to/file")
194191

195192
enum Manual: Int, ExpressibleByArgument {
196193
case foo
@@ -229,7 +226,7 @@ extension HelpGenerationTests {
229226
--lucky <numbers> Your lucky numbers. (default: 7, 14)
230227
--optional/--required Vegan diet. (default: --optional)
231228
--degree <degree> Your degree.
232-
--directory <directory> Directory. (default: current directory)
229+
--directory <directory> Directory. (default: /path/to/file)
233230
--manual <manual> Manual Option. (default: default-value)
234231
--unspecial <unspecial> Unspecialized Synthesized (values: 0, 1; default: 0)
235232
--special <special> Specialized Synthesized (values: Apple, Banana;

0 commit comments

Comments
 (0)