Skip to content

Commit 0c9c869

Browse files
committed
Tests: simplify test condition (NFCI)
Rather than iterating over all the jobs (even if there are only two) to find a matching job, extract the module emission job and verify that the assertions hold over the job.
1 parent 5c1c6a0 commit 0c9c869

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2590,12 +2590,14 @@ final class SwiftDriverTests: XCTestCase {
25902590
"swiftc", "foo.swift", "-module-name", "Foo", "-module-alias", "Car=Bar",
25912591
"-emit-module", "-emit-module-path", "/tmp/dir/Foo.swiftmodule",
25922592
])
2593+
25932594
let plannedJobs = try driver.planBuild()
2594-
XCTAssertTrue(plannedJobs.contains { job in
2595-
job.commandLine.contains(.flag("-module-alias")) &&
2596-
job.commandLine.contains(.flag("Car=Bar")) &&
2597-
job.outputs[0].file.absolutePath?.pathString == "/tmp/dir/Foo.swiftmodule"
2598-
})
2595+
2596+
let moduleJob = plannedJobs.first(where: { $0.kind == .emitModule })!
2597+
XCTAssertTrue(moduleJob.commandLine.contains("-module-alias"))
2598+
XCTAssertTrue(moduleJob.commandLine.contains("Car=Bar"))
2599+
XCTAssertEqual(moduleJob.outputs[0].file, .absolute(AbsolutePath("/tmp/dir/Foo.swiftmodule")))
2600+
25992601
XCTAssertEqual(driver.moduleOutputInfo.name, "Foo")
26002602
XCTAssertNotNil(driver.moduleOutputInfo.aliases)
26012603
XCTAssertEqual(driver.moduleOutputInfo.aliases!.count, 1)

0 commit comments

Comments
 (0)