-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix up tests for Windows #5074
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
Fix up tests for Windows #5074
Changes from all commits
f71d985
d4115b7
3f320d8
6d746d9
19b3598
bb28f60
c8ba73d
a0a89f0
700c147
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,14 @@ class BundlePlayground { | |
#endif | ||
} | ||
} | ||
|
||
var fileNameSuffix: String? { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't believe Foundation's tests have been run in debug mode before, so this test was failing when Foundation was built in debug mode and this fixes it by adding the appropriate file suffix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct! We always build in release mode currently due to other limitations that I would like to see lifted. |
||
#if os(Windows) && DEBUG | ||
"_debug" | ||
#else | ||
nil | ||
#endif | ||
} | ||
|
||
var flatPathExtension: String? { | ||
#if os(Windows) | ||
|
@@ -216,7 +224,7 @@ class BundlePlayground { | |
|
||
// Make a main and an auxiliary executable: | ||
self.mainExecutableURL = bundleURL | ||
.appendingPathComponent(bundleName) | ||
.appendingPathComponent(bundleName + (executableType.fileNameSuffix ?? "")) | ||
|
||
if let ext = executableType.flatPathExtension { | ||
self.mainExecutableURL.appendPathExtension(ext) | ||
|
@@ -227,7 +235,7 @@ class BundlePlayground { | |
} | ||
|
||
var auxiliaryExecutableURL = bundleURL | ||
.appendingPathComponent(auxiliaryExecutableName) | ||
.appendingPathComponent(auxiliaryExecutableName + (executableType.fileNameSuffix ?? "")) | ||
|
||
if let ext = executableType.flatPathExtension { | ||
auxiliaryExecutableURL.appendPathExtension(ext) | ||
|
@@ -270,7 +278,7 @@ class BundlePlayground { | |
// Make a main and an auxiliary executable: | ||
self.mainExecutableURL = temporaryDirectory | ||
.appendingPathComponent(executableType.fhsPrefix) | ||
.appendingPathComponent(executableType.nonFlatFilePrefix + bundleName) | ||
.appendingPathComponent(executableType.nonFlatFilePrefix + bundleName + (executableType.fileNameSuffix ?? "")) | ||
|
||
if let ext = executableType.pathExtension { | ||
self.mainExecutableURL.appendPathExtension(ext) | ||
|
@@ -280,7 +288,7 @@ class BundlePlayground { | |
let executablesDirectory = temporaryDirectory.appendingPathComponent("libexec").appendingPathComponent("\(bundleName).executables") | ||
try FileManager.default.createDirectory(atPath: executablesDirectory.path, withIntermediateDirectories: true, attributes: nil) | ||
var auxiliaryExecutableURL = executablesDirectory | ||
.appendingPathComponent(executableType.nonFlatFilePrefix + auxiliaryExecutableName) | ||
.appendingPathComponent(executableType.nonFlatFilePrefix + auxiliaryExecutableName + (executableType.fileNameSuffix ?? "")) | ||
|
||
if let ext = executableType.pathExtension { | ||
auxiliaryExecutableURL.appendPathExtension(ext) | ||
|
@@ -317,7 +325,7 @@ class BundlePlayground { | |
|
||
// Make a main executable: | ||
self.mainExecutableURL = temporaryDirectory | ||
.appendingPathComponent(executableType.nonFlatFilePrefix + bundleName) | ||
.appendingPathComponent(executableType.nonFlatFilePrefix + bundleName + (executableType.fileNameSuffix ?? "")) | ||
|
||
if let ext = executableType.pathExtension { | ||
self.mainExecutableURL.appendPathExtension(ext) | ||
|
@@ -330,7 +338,7 @@ class BundlePlayground { | |
|
||
// Make an auxiliary executable: | ||
var auxiliaryExecutableURL = resourcesDirectory | ||
.appendingPathComponent(executableType.nonFlatFilePrefix + auxiliaryExecutableName) | ||
.appendingPathComponent(executableType.nonFlatFilePrefix + auxiliaryExecutableName + (executableType.fileNameSuffix ?? "")) | ||
if let ext = executableType.pathExtension { | ||
auxiliaryExecutableURL.appendPathExtension(ext) | ||
} | ||
|
@@ -516,11 +524,14 @@ class TestBundle : XCTestCase { | |
XCTFail("should not fail to load") | ||
} | ||
|
||
// This causes a dialog box to appear on Windows which will suspend the tests, so skip testing this on Windows for now | ||
#if !os(Windows) | ||
// Executable cannot be located | ||
try! _withEachPlaygroundLayout { (playground) in | ||
let bundle = Bundle(path: playground.bundlePath) | ||
XCTAssertThrowsError(try bundle!.loadAndReturnError()) | ||
} | ||
#endif | ||
} | ||
|
||
func test_bundleWithInvalidPath() { | ||
|
@@ -531,12 +542,15 @@ class TestBundle : XCTestCase { | |
func test_bundlePreflight() { | ||
XCTAssertNoThrow(try testBundle(executable: true).preflight()) | ||
|
||
// Windows DLL bundles are always executable | ||
#if !os(Windows) | ||
try! _withEachPlaygroundLayout { (playground) in | ||
let bundle = Bundle(path: playground.bundlePath)! | ||
|
||
// Must throw as the main executable is a dummy empty file. | ||
XCTAssertThrowsError(try bundle.preflight()) | ||
} | ||
#endif | ||
} | ||
|
||
func test_bundleFindExecutable() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was necessary to ensure that paths with drive letters do not have a leading slash (the file system representation standardizes that)