Bundled the static files into the App test target.
This commit is contained in:
@@ -120,7 +120,12 @@ let package = Package(
|
|||||||
package: "hummingbird"
|
package: "hummingbird"
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
path: "Tests/App"
|
path: "Tests/App",
|
||||||
|
resources: [
|
||||||
|
// `Static` links to the service's `Resources/Static`, copying it into the test bundle at build
|
||||||
|
// time — the tests must not read the repository tree, which Xcode's test runner is denied.
|
||||||
|
.copy("Static")
|
||||||
|
]
|
||||||
),
|
),
|
||||||
.testTarget(
|
.testTarget(
|
||||||
name: "WebsiteLibraryTests",
|
name: "WebsiteLibraryTests",
|
||||||
|
|||||||
@@ -20,14 +20,18 @@ struct AppTests {
|
|||||||
.js
|
.js
|
||||||
]
|
]
|
||||||
|
|
||||||
// Absolute path to the package's "Resources/Static" folder, derived from this
|
// Absolute path to the copy of the package's "Resources/Static" folder made into the test bundle
|
||||||
// file's location so the static files resolve regardless of the working directory.
|
// at build time — the repository tree itself is off limits to Xcode's test runner.
|
||||||
private let staticFilesPath = URL(fileURLWithPath: #filePath)
|
private let staticFilesPath: String = {
|
||||||
.deletingLastPathComponent() // Tests/App
|
guard let url = Bundle.module.url(
|
||||||
.deletingLastPathComponent() // Tests
|
forResource: "Static",
|
||||||
.deletingLastPathComponent() // package root
|
withExtension: nil
|
||||||
.appendingPathComponent(.Path.staticResources)
|
) else {
|
||||||
.path
|
preconditionFailure("The static files are missing from the test bundle.")
|
||||||
|
}
|
||||||
|
|
||||||
|
return url.path
|
||||||
|
}()
|
||||||
|
|
||||||
// MARK: Functional tests
|
// MARK: Functional tests
|
||||||
|
|
||||||
|
|||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
../../Resources/Static
|
||||||
Reference in New Issue
Block a user