Skip to content

Commit b280852

Browse files
authored
Merge pull request #2506 from gmittert/StillLegalInSanFrancisco
[Windows] Fix TestURL/test_URLStrings
2 parents 1a72fc8 + 5ef5dc3 commit b280852

File tree

2 files changed

+84
-15
lines changed

2 files changed

+84
-15
lines changed

TestFoundation/Resources/NSURLTestData.plist

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3493,14 +3493,68 @@
34933493
</dict>
34943494
<dict>
34953495
<key>In-Title</key>
3496-
<string>NSURLWithString-parse-absolute-escape-006</string>
3496+
<string>NSURLWithString-parse-absolute-escape-006-pipe-invalid</string>
34973497
<key>In-URLCreator</key>
34983498
<string>NSURLWithString</string>
34993499
<key>In-Url</key>
35003500
<string>http://test.com/unescaped|pipe</string>
35013501
<key>Out-NSResults</key>
35023502
<string>&lt;null url&gt;</string>
35033503
</dict>
3504+
<dict>
3505+
<key>In-Title</key>
3506+
<string>NSURLWithString-parse-absolute-escape-006-pipe-valid</string>
3507+
<key>In-URLCreator</key>
3508+
<string>NSURLWithString</string>
3509+
<key>In-Url</key>
3510+
<string>http://test.com/unescaped|pipe</string>
3511+
<key>Out-NSResults</key>
3512+
<dict>
3513+
<key>absoluteString</key>
3514+
<string>http://test.com/unescaped%7Cpipe</string>
3515+
<key>absoluteURLString</key>
3516+
<string>http://test.com/unescaped%7Cpipe</string>
3517+
<key>baseURLString</key>
3518+
<string>&lt;null&gt;</string>
3519+
<key>deletingLastPathComponent</key>
3520+
<string>http://test.com/</string>
3521+
<key>deletingLastPathExtension</key>
3522+
<string>http://test.com/unescaped%7Cpipe</string>
3523+
<key>fragment</key>
3524+
<string>&lt;null&gt;</string>
3525+
<key>host</key>
3526+
<string>test.com</string>
3527+
<key>isFileURL</key>
3528+
<string>NO</string>
3529+
<key>lastPathComponent</key>
3530+
<string>unescaped|pipe</string>
3531+
<key>password</key>
3532+
<string>&lt;null&gt;</string>
3533+
<key>path</key>
3534+
<string>/unescaped|pipe</string>
3535+
<key>pathComponents</key>
3536+
<array>
3537+
<string>/</string>
3538+
<string>unescaped|pipe</string>
3539+
</array>
3540+
<key>pathExtension</key>
3541+
<string></string>
3542+
<key>port</key>
3543+
<string>&lt;null&gt;</string>
3544+
<key>query</key>
3545+
<string>&lt;null&gt;</string>
3546+
<key>relativePath</key>
3547+
<string>/unescaped|pipe</string>
3548+
<key>relativeString</key>
3549+
<string>http://test.com/unescaped%7Cpipe</string>
3550+
<key>scheme</key>
3551+
<string>http</string>
3552+
<key>standardizedURL</key>
3553+
<string>http://test.com/unescaped%7Cpipe</string>
3554+
<key>user</key>
3555+
<string>&lt;null&gt;</string>
3556+
</dict>
3557+
</dict>
35043558
<dict>
35053559
<key>In-Title</key>
35063560
<string>NSURLWithString-parse-absolute-escape-007</string>

TestFoundation/TestURL.swift

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -248,25 +248,40 @@ class TestURL : XCTestCase {
248248
default:
249249
XCTFail()
250250
}
251-
if title == "NSURLWithString-parse-ambiguous-url-001" {
252-
// TODO: Fix this test
253-
} else {
254-
if let url = url {
255-
let results = generateResults(url, pathComponent: inPathComponent, pathExtension: inPathExtension)
256-
if let expected = expectedNSResult as? [String: Any] {
257-
let (isEqual, differences) = compareResults(url, expected: expected, got: results)
258-
XCTAssertTrue(isEqual, "\(title): \(differences.joined(separator: "\n"))")
259-
} else {
260-
XCTFail("\(url) should not be a valid url")
261-
}
251+
252+
#if os(Windows)
253+
// On Windows, pipes are valid charcters which can be used
254+
// to replace a ':'. See RFC 8089 Section E.2.2 for
255+
// details.
256+
//
257+
// Skip the test which expects pipes to be invalid
258+
let skippedPipeTest = "NSURLWithString-parse-absolute-escape-006-pipe-invalid"
259+
#else
260+
// On other platforms, pipes are not valid
261+
//
262+
// Skip the test which expects pipes to be valid
263+
let skippedPipeTest = "NSURLWithString-parse-absolute-escape-006-pipe-valid"
264+
#endif
265+
let skippedTests = [
266+
"NSURLWithString-parse-ambiguous-url-001", // TODO: Fix Test
267+
skippedPipeTest,
268+
]
269+
if skippedTests.contains(title) { continue }
270+
271+
if let url = url {
272+
let results = generateResults(url, pathComponent: inPathComponent, pathExtension: inPathExtension)
273+
if let expected = expectedNSResult as? [String: Any] {
274+
let (isEqual, differences) = compareResults(url, expected: expected, got: results)
275+
XCTAssertTrue(isEqual, "\(title): \(differences.joined(separator: "\n"))")
262276
} else {
263-
XCTAssertEqual(expectedNSResult as? String, kNullURLString)
277+
XCTFail("\(url) should not be a valid url")
264278
}
279+
} else {
280+
XCTAssertEqual(expectedNSResult as? String, kNullURLString)
265281
}
266282
}
267-
268283
}
269-
284+
270285
static let gBaseTemporaryDirectoryPath = (NSTemporaryDirectory() as NSString).appendingPathComponent("org.swift.foundation.TestFoundation.TestURL.\(ProcessInfo.processInfo.processIdentifier)")
271286
static var gBaseCurrentWorkingDirectoryPath : String {
272287
return FileManager.default.currentDirectoryPath

0 commit comments

Comments
 (0)