     }
   }
 
+  func testNumThreads() throws {
+    XCTAssertEqual(try Driver(args: ["swiftc"]).numThreads, 0)
+
+    XCTAssertEqual(try Driver(args: ["swiftc", "-num-threads", "4"]).numThreads, 4)
+
+    XCTAssertEqual(try Driver(args: ["swiftc", "-num-threads", "0"]).numThreads, 0)
+
+    try assertDriverDiagnostics(args: ["swift", "-num-threads", "-1"]) { driver, verify in
+      verify.expect(.error("invalid value '-1' in '-num-threads'"))
+      XCTAssertEqual(driver.numThreads, 0)
+    }
+
+    try assertDriverDiagnostics(args: "swiftc", "-enable-batch-mode", "-num-threads", "4") { driver, verify in
+      verify.expect(.warning("ignoring -num-threads argument; cannot multithread batch mode"))
+      XCTAssertEqual(driver.numThreads, 0)
+    }
+  }
+
   func testScanDependenciesOption() throws {
     do {
       var driver = try Driver(args: ["swiftc", "-scan-dependencies", "foo.swift"])

  }

    func testMultithreading() throws {

      XCTAssertEqual(try Driver(args: ["swiftc"]).numThreads, 0)

      XCTAssertEqual(try Driver(args: ["swiftc", "-num-threads", "4"]).numThreads, 4)

      XCTAssertEqual(try Driver(args: ["swiftc", "-num-threads", "0"]).numThreads, 0)

      XCTAssertEqual(try Driver(args: ["swiftc", "-num-threads", "-1"]).numThreads, 0)

      XCTAssertEqual(try Driver(args: ["swiftc", "-enable-batch-mode", "-num-threads", "4"]).numThreads, 0)

      XCTAssertNil(try Driver(args: ["swiftc"]).numParallelJobs)

      XCTAssertEqual(try Driver(args: ["swiftc", "-j", "4"]).numParallelJobs, 4)

    }

    func testMultithreadingDiagnostics() throws {
      try assertDriverDiagnostics(args: "swiftc", "-j", "0") {
        $1.expect(.error("invalid value '0' in '-j'"))
      }
