Skip to content

[Windows] Fix TestURL/test_URLStrings #2506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion TestFoundation/Resources/NSURLTestData.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3493,14 +3493,68 @@
</dict>
<dict>
<key>In-Title</key>
<string>NSURLWithString-parse-absolute-escape-006</string>
<string>NSURLWithString-parse-absolute-escape-006-pipe-invalid</string>
<key>In-URLCreator</key>
<string>NSURLWithString</string>
<key>In-Url</key>
<string>http://test.com/unescaped|pipe</string>
<key>Out-NSResults</key>
<string>&lt;null url&gt;</string>
</dict>
<dict>
<key>In-Title</key>
<string>NSURLWithString-parse-absolute-escape-006-pipe-valid</string>
<key>In-URLCreator</key>
<string>NSURLWithString</string>
<key>In-Url</key>
<string>http://test.com/unescaped|pipe</string>
<key>Out-NSResults</key>
<dict>
<key>absoluteString</key>
<string>http://test.com/unescaped%7Cpipe</string>
<key>absoluteURLString</key>
<string>http://test.com/unescaped%7Cpipe</string>
<key>baseURLString</key>
<string>&lt;null&gt;</string>
<key>deletingLastPathComponent</key>
<string>http://test.com/</string>
<key>deletingLastPathExtension</key>
<string>http://test.com/unescaped%7Cpipe</string>
<key>fragment</key>
<string>&lt;null&gt;</string>
<key>host</key>
<string>test.com</string>
<key>isFileURL</key>
<string>NO</string>
<key>lastPathComponent</key>
<string>unescaped|pipe</string>
<key>password</key>
<string>&lt;null&gt;</string>
<key>path</key>
<string>/unescaped|pipe</string>
<key>pathComponents</key>
<array>
<string>/</string>
<string>unescaped|pipe</string>
</array>
<key>pathExtension</key>
<string></string>
<key>port</key>
<string>&lt;null&gt;</string>
<key>query</key>
<string>&lt;null&gt;</string>
<key>relativePath</key>
<string>/unescaped|pipe</string>
<key>relativeString</key>
<string>http://test.com/unescaped%7Cpipe</string>
<key>scheme</key>
<string>http</string>
<key>standardizedURL</key>
<string>http://test.com/unescaped%7Cpipe</string>
<key>user</key>
<string>&lt;null&gt;</string>
</dict>
</dict>
<dict>
<key>In-Title</key>
<string>NSURLWithString-parse-absolute-escape-007</string>
Expand Down
43 changes: 29 additions & 14 deletions TestFoundation/TestURL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -248,25 +248,40 @@ class TestURL : XCTestCase {
default:
XCTFail()
}
if title == "NSURLWithString-parse-ambiguous-url-001" {
// TODO: Fix this test
} else {
if let url = url {
let results = generateResults(url, pathComponent: inPathComponent, pathExtension: inPathExtension)
if let expected = expectedNSResult as? [String: Any] {
let (isEqual, differences) = compareResults(url, expected: expected, got: results)
XCTAssertTrue(isEqual, "\(title): \(differences.joined(separator: "\n"))")
} else {
XCTFail("\(url) should not be a valid url")
}

#if os(Windows)
// On Windows, pipes are valid charcters which can be used
// to replace a ':'. See RFC 8089 Section E.2.2 for
// details.
//
// Skip the test which expects pipes to be invalid
let skippedPipeTest = "NSURLWithString-parse-absolute-escape-006-pipe-invalid"
#else
// On other platforms, pipes are not valid
//
// Skip the test which expects pipes to be valid
let skippedPipeTest = "NSURLWithString-parse-absolute-escape-006-pipe-valid"
#endif
let skippedTests = [
"NSURLWithString-parse-ambiguous-url-001", // TODO: Fix Test
skippedPipeTest,
]
if skippedTests.contains(title) { continue }

if let url = url {
let results = generateResults(url, pathComponent: inPathComponent, pathExtension: inPathExtension)
if let expected = expectedNSResult as? [String: Any] {
let (isEqual, differences) = compareResults(url, expected: expected, got: results)
XCTAssertTrue(isEqual, "\(title): \(differences.joined(separator: "\n"))")
} else {
XCTAssertEqual(expectedNSResult as? String, kNullURLString)
XCTFail("\(url) should not be a valid url")
}
} else {
XCTAssertEqual(expectedNSResult as? String, kNullURLString)
}
}

}

static let gBaseTemporaryDirectoryPath = (NSTemporaryDirectory() as NSString).appendingPathComponent("org.swift.foundation.TestFoundation.TestURL.\(ProcessInfo.processInfo.processIdentifier)")
static var gBaseCurrentWorkingDirectoryPath : String {
return FileManager.default.currentDirectoryPath
Expand Down