Skip to content

Commit

Permalink
Improve Parallel Testing (#3182)
Browse files Browse the repository at this point in the history
* Fix Sendable warning in RFC1123

* Fix warning with test file

* Fix post assignement in tests

* Revert "Fix Sendable warning in RFC1123"

This reverts commit a85e5cb.
  • Loading branch information
0xTim committed Apr 30, 2024
1 parent e87730e commit e91021c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/test.yml
Expand Up @@ -46,3 +46,13 @@ jobs:
uses: vapor/ci/.github/workflows/run-unit-tests.yml@main
with:
with_tsan: false

test-parallel:
if: ${{ !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
container: swift:5.10
steps:
- name: Check out Vapor
uses: actions/checkout@v4
- name: Run tests
run: swift test --parallel
1 change: 1 addition & 0 deletions Package.swift
Expand Up @@ -121,6 +121,7 @@ let package = Package(
.copy("Utilities/my-secret-env-content"),
.copy("Utilities/expired.crt"),
.copy("Utilities/expired.key"),
.copy("Utilities/long-test-file.txt"),
]),
]
)
1 change: 1 addition & 0 deletions Package@swift-5.9.swift
Expand Up @@ -129,6 +129,7 @@ let package = Package(
.copy("Utilities/my-secret-env-content"),
.copy("Utilities/expired.crt"),
.copy("Utilities/expired.key"),
.copy("Utilities/long-test-file.txt"),
],
swiftSettings: [
.enableUpcomingFeature("BareSlashRegexLiterals"),
Expand Down
6 changes: 3 additions & 3 deletions Tests/VaporTests/FileTests.swift
Expand Up @@ -20,7 +20,7 @@ final class FileTests: XCTestCase {
}
}

try app.testable(method: .running).test(.GET, "/file-stream") { res in
try app.testable(method: .running(port: 0)).test(.GET, "/file-stream") { res in
let test = "the quick brown fox"
XCTAssertNotNil(res.headers.first(name: .eTag))
XCTAssertContains(res.body.string, test)
Expand Down Expand Up @@ -104,7 +104,7 @@ final class FileTests: XCTestCase {
}
}

try app.testable(method: .running).test(.GET, "/file-stream") { res in
try app.testable(method: .running(port: 0)).test(.GET, "/file-stream") { res in
let fileData = try Data(contentsOf: URL(fileURLWithPath: #file))
let digest = SHA256.hash(data: fileData)
let eTag = res.headers.first(name: "etag")
Expand All @@ -126,7 +126,7 @@ final class FileTests: XCTestCase {
}
}

try app.testable(method: .running).test(.GET, "/file-stream") { res in
try app.testable(method: .running(port: 0)).test(.GET, "/file-stream") { res in
let attributes = try FileManager.default.attributesOfItem(atPath: #file)
let modifiedAt = attributes[.modificationDate] as! Date
let fileSize = (attributes[.size] as? NSNumber)!.intValue
Expand Down

0 comments on commit e91021c

Please sign in to comment.