From 22916b38ad73d69362e4d3bf65b0faa10fbe8d7b Mon Sep 17 00:00:00 2001 From: Allan Shortlidge Date: Sat, 19 Aug 2023 23:25:27 -0700 Subject: [PATCH 1/2] Tests: Address warnings about unused results by adding missing assertions. --- Tests/SwiftDriverTests/SwiftDriverTests.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/SwiftDriverTests/SwiftDriverTests.swift b/Tests/SwiftDriverTests/SwiftDriverTests.swift index d920b12b9..cdddb413e 100644 --- a/Tests/SwiftDriverTests/SwiftDriverTests.swift +++ b/Tests/SwiftDriverTests/SwiftDriverTests.swift @@ -6863,8 +6863,8 @@ final class SwiftDriverTests: XCTestCase { let jobs = try driver.planBuild().removingAutolinkExtractJobs() XCTAssertEqual(jobs.count, 2) let (compileJob, linkJob) = (jobs[0], jobs[1]) - compileJob.commandLine.contains(.flag("--gcc-toolchain=foo/as/blarpy")) - linkJob.commandLine.contains(.flag("--gcc-toolchain=foo/as/blarpy")) + XCTAssert(compileJob.commandLine.contains(.flag("--gcc-toolchain=foo/as/blarpy"))) + XCTAssert(linkJob.commandLine.contains(.flag("--gcc-toolchain=foo/as/blarpy"))) } func testPluginPaths() throws { From 88b4a7ce8ca2d0e767a538337309500def7bd024 Mon Sep 17 00:00:00 2001 From: Allan Shortlidge Date: Sat, 19 Aug 2023 23:30:18 -0700 Subject: [PATCH 2/2] Tests: Address unused variable warnings. --- .../DependencyGraphSerializationTests.swift | 13 ++--------- .../ExplicitModuleBuildTests.swift | 23 ------------------- 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/Tests/SwiftDriverTests/DependencyGraphSerializationTests.swift b/Tests/SwiftDriverTests/DependencyGraphSerializationTests.swift index 27195f608..76305704c 100644 --- a/Tests/SwiftDriverTests/DependencyGraphSerializationTests.swift +++ b/Tests/SwiftDriverTests/DependencyGraphSerializationTests.swift @@ -27,12 +27,7 @@ class DependencyGraphSerializationTests: XCTestCase, ModuleDependencyGraphMocker let graph = Self.mockGraphCreator.mockUpAGraph() let currentVersion = ModuleDependencyGraph.serializedGraphVersion let alteredVersion = currentVersion.withAlteredMinor - let outputFileMap = OutputFileMap.mock(maxIndex: Self.maxIndex) - let diagnosticsEngine = DiagnosticsEngine() - let info = BuildRecordInfo.mock( - diagnosticEngine: diagnosticsEngine, - outputFileMap: outputFileMap, - compilerVersion: "Swift 99") + try graph.blockingConcurrentAccessOrMutation { try graph.write( to: mockPath, @@ -63,11 +58,7 @@ class DependencyGraphSerializationTests: XCTestCase, ModuleDependencyGraphMocker let mockPath = try VirtualPath.absolute(AbsolutePath(validating: "/module-dependency-graph")) let fs = InMemoryFileSystem() let outputFileMap = OutputFileMap.mock(maxIndex: Self.maxIndex) - let diagnosticsEngine = DiagnosticsEngine() - let buildRecord = BuildRecordInfo.mock( - diagnosticEngine: diagnosticsEngine, - outputFileMap: outputFileMap, - compilerVersion: "Swift 99") + try originalGraph.blockingConcurrentMutation { try originalGraph.write( to: mockPath, on: fs, diff --git a/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift b/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift index 523425044..35fa6c04f 100644 --- a/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift +++ b/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift @@ -73,29 +73,6 @@ private func checkExplicitModuleBuildJobDependencies(job: Job, moduleInfo : ModuleInfo, dependencyGraph: InterModuleDependencyGraph ) throws { - var validateModuleMapCommandLineDependency: (ModuleDependencyId, ModuleInfo) throws -> Void = { dependencyId, dependencyInfo in - // Load the dependency JSON and verify this dependency was encoded correctly - let explicitDepsFlag = - SwiftDriver.Job.ArgTemplate.flag(String("-explicit-swift-module-map-file")) - XCTAssert(job.commandLine.contains(explicitDepsFlag)) - let jsonDepsPathIndex = job.commandLine.firstIndex(of: explicitDepsFlag) - let jsonDepsPathArg = job.commandLine[jsonDepsPathIndex! + 1] - guard case .path(let jsonDepsPath) = jsonDepsPathArg else { - XCTFail("No JSON dependency file path found.") - return - } - guard case let .temporaryWithKnownContents(_, contents) = jsonDepsPath else { - XCTFail("Unexpected path type") - return - } - let dependencyInfoList = try JSONDecoder().decode(Array.self, - from: contents) - let dependencyArtifacts = - dependencyInfoList.first(where:{ $0.moduleName == dependencyId.moduleName }) - XCTAssertEqual(dependencyArtifacts!.modulePath, dependencyInfo.modulePath) - } - - let validateSwiftCommandLineDependency: (ModuleDependencyId, ModuleInfo) -> Void = { dependencyId, dependencyInfo in let inputModulePath = dependencyInfo.modulePath.path XCTAssertTrue(job.inputs.contains(TypedVirtualPath(file: inputModulePath, type: .swiftModule)))