   @discardableResult
   private func tryInitial(checkDiagnostics: Bool = false,
                   extraArguments: [String] = []
-  ) throws -> Driver? {
+  ) throws -> Driver {
     try doABuild(
       "initial",
       checkDiagnostics: checkDiagnostics,

                extraArguments: [String],
                expecting expectations: [Diagnostic.Message],
                expectingWhenAutolinking autolinkExpectations: [Diagnostic.Message]
  ) throws -> Driver? {
    print("*** starting build \(message) ***", to: &stderrStream); stderrStream.flush()

    func doTheCompile(_ driver: inout Driver) {
      let jobs = try! driver.planBuild()
      try? driver.run(jobs: jobs)
    }

    guard let sdkArgumentsForTesting = try Driver.sdkArgumentsForTesting()
    else {
      throw XCTSkip("Cannot perform this test on this host")
    }
    let allArgs = commonArgs + extraArguments + sdkArgumentsForTesting
    let postMortemDriver: Driver?
    if checkDiagnostics {
      postMortemDriver = try assertDriverDiagnostics(args: allArgs) {driver, verifier in
        verifier.forbidUnexpected(.error, .warning, .note, .remark, .ignored)
        expectations.forEach {verifier.expect($0)}
        if driver.isAutolinkExtractJobNeeded {
          autolinkExpectations.forEach {verifier.expect($0)}
        }
        doTheCompile(&driver)
        return driver
      }
    }
    else {
      let diagnosticEngine = DiagnosticsEngine(handlers: [
        {print($0, to: &stderrStream); stderrStream.flush()}
      ])
      var driver = try Driver(args: allArgs, env: ProcessEnv.vars,
                              diagnosticsEngine: diagnosticEngine,
                              fileSystem: localFileSystem)
      doTheCompile(&driver)
      postMortemDriver = driver
    }
    print("", to: &stderrStream); stderrStream.flush()
    return postMortemDriver
  }
}


  private func replace(contentsOf name: String, with replacement: String ) {
    print("*** replacing \(name) ***", to: &stderrStream); stderrStream.flush()
    let path = inputPath(basename: name)
    let previousContents = try! localFileSystem.readFileContents(path).cString
    try! localFileSystem.writeFileContents(path) { $0 <<< replacement }
    let newContents = try! localFileSystem.readFileContents(path).cString
    XCTAssert(previousContents != newContents, "\(path.pathString) unchanged after write")
    XCTAssert(replacement == newContents, "\(path.pathString) failed to write")
  }

  private func write(_ contents: String, to basename: String) {
    print("*** writing \(contents) to \(basename)")
    try! localFileSystem.writeFileContents(inputPath(basename: basename)) {
      $0 <<< contents
    }
  }
}

