     XCTAssertTrue(matchTemporary(plannedJobs[0].outputs.first!.file, "foo.o"))
     XCTAssertEqual(plannedJobs[1].outputs.count, 1)
     XCTAssertTrue(matchTemporary(plannedJobs[1].outputs.first!.file, "bar.o"))
-    XCTAssertTrue(plannedJobs[2].tool.name.contains(driver1.targetTriple.isDarwin ? "ld" : "clang"))
+    XCTAssertTrue(plannedJobs[2].tool.name.contains(driver1.targetTriple.isDarwin ? executableName("ld") : executableName("clang")))
     XCTAssertEqual(plannedJobs[2].outputs.count, 1)
-    XCTAssertEqual(plannedJobs[2].outputs.first!.file, VirtualPath.relative(RelativePath("Test")))
+    XCTAssertEqual(plannedJobs[2].outputs.first!.file, VirtualPath.relative(RelativePath(executableName("Test"))))
 
     // Forwarding of arguments.
     var driver2 = try Driver(args: ["swiftc", "-color-diagnostics", "foo.swift", "bar.swift", "-working-directory", "/tmp", "-api-diff-data-file", "diff.txt", "-Xfrontend", "-HI", "-no-color-diagnostics", "-g"])

    var output = ""
    serializer.writeDOT(to: &output)

    let linkerDriver = driver.targetTriple.isDarwin ? "ld" : "clang"
    #if os(Linux) || os(Android)
    XCTAssertEqual(output,
    """
    digraph Jobs {
      "emitModule (swift-frontend)" [style=bold];
      "test.swift" [fontsize=12];
      "test.swift" -> "emitModule (swift-frontend)" [color=blue];
      "test.swiftmodule" [fontsize=12];
      "emitModule (swift-frontend)" -> "test.swiftmodule" [color=green];
      "test.swiftdoc" [fontsize=12];
      "emitModule (swift-frontend)" -> "test.swiftdoc" [color=green];
      "test.abi.json" [fontsize=12];
      "emitModule (swift-frontend)" -> "test.abi.json" [color=green];
      "compile (swift-frontend)" [style=bold];
      "test.swift" -> "compile (swift-frontend)" [color=blue];
      "test-1.o" [fontsize=12];
      "compile (swift-frontend)" -> "test-1.o" [color=green];
      "autolinkExtract (swift-autolink-extract)" [style=bold];
      "test-1.o" -> "autolinkExtract (swift-autolink-extract)" [color=blue];
      "test-2.autolink" [fontsize=12];
      "autolinkExtract (swift-autolink-extract)" -> "test-2.autolink" [color=green];
      "link (clang)" [style=bold];
      "test-1.o" -> "link (clang)" [color=blue];
      "test-2.autolink" -> "link (clang)" [color=blue];
      "test" [fontsize=12];
      "link (clang)" -> "test" [color=green];
    }

    """)

    XCTAssertEqual(driver5.args, ["swift", "-repl"])

    let driver6 = try Driver.invocationRunMode(forArgs: ["swift", "foo", "bar"])
    XCTAssertEqual(driver6.mode, .subcommand(executableName("swift-foo")))
    XCTAssertEqual(driver6.args, [executableName("swift-foo"), "bar"])

    let driver7 = try Driver.invocationRunMode(forArgs: ["swift", "-frontend", "foo", "bar"])
    XCTAssertEqual(driver7.mode, .subcommand(executableName("swift-frontend")))
    XCTAssertEqual(driver7.args, [executableName("swift-frontend"), "foo", "bar"])

    let driver8 = try Driver.invocationRunMode(forArgs: ["swift", "-modulewrap", "foo", "bar"])
    XCTAssertEqual(driver8.mode, .subcommand(executableName("swift-frontend")))
    XCTAssertEqual(driver8.args, [executableName("swift-frontend"), "-modulewrap", "foo", "bar"])
  }

  func testSubcommandsHandling() throws {
