Skip to content

Commit 86810fe

Browse files
authored
Migrate PluginTests to Swift Testing (#8793)
Migrate the test suite to Swift Testing. Explicitly mark tests that are enabled/disabled. Add bug links to issues and radars for better tracking combined withKnownIssues so that when bugs are fixed there is immediate notification that the tests can be enabled. Fix the writable directories and working directory in PIFBuilder custom tasks to the plugin working directory for plugins that don’t declare their outputs.
1 parent c4e3062 commit 86810fe

File tree

3 files changed

+468
-374
lines changed

3 files changed

+468
-374
lines changed

Sources/SwiftBuildSupport/PIFBuilder.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -359,22 +359,20 @@ public final class PIFBuilder {
359359
buildCommands: result.buildCommands.map( { buildCommand in
360360
var newEnv: Environment = buildCommand.configuration.environment
361361

362-
if let runtimeLibPaths = try? buildParameters.toolchain.runtimeLibraryPaths {
363-
for libPath in runtimeLibPaths {
364-
newEnv.appendPath(key: .libraryPath, value: libPath.pathString)
365-
}
366-
}
362+
let runtimeLibPaths = buildParameters.toolchain.runtimeLibraryPaths
367363

368-
let workingDir = buildCommand.configuration.workingDirectory
364+
for libPath in runtimeLibPaths {
365+
newEnv.appendPath(key: .libraryPath, value: libPath.pathString)
366+
}
369367

370-
let writableDirectories: [AbsolutePath] = buildCommand.outputFiles
368+
let writableDirectories: [AbsolutePath] = [pluginOutputDir]
371369

372370
return PackagePIFBuilder.CustomBuildCommand(
373371
displayName: buildCommand.configuration.displayName,
374372
executable: buildCommand.configuration.executable.pathString,
375373
arguments: buildCommand.configuration.arguments,
376374
environment: .init(newEnv),
377-
workingDir: workingDir,
375+
workingDir: package.path,
378376
inputPaths: buildCommand.inputFiles,
379377
outputPaths: buildCommand.outputFiles.map(\.pathString),
380378
sandboxProfile:

Sources/_InternalTestSupport/Observability.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ public func XCTAssertNoDiagnostics(
103103
XCTFail("Found unexpected diagnostics: \n\(description)", file: file, line: line)
104104
}
105105

106+
public func expectNoDiagnostics(
107+
_ diagnostics: [Basics.Diagnostic],
108+
problemsOnly: Bool = true,
109+
sourceLocation: SourceLocation = #_sourceLocation
110+
) {
111+
let diagnostics = problemsOnly ? diagnostics.filter { $0.severity >= .warning } : diagnostics
112+
if diagnostics.isEmpty { return }
113+
114+
let description = diagnostics.map { "- " + $0.description }.joined(separator: "\n")
115+
Issue.record("Found unexpected diagnostics: \n\(description)", sourceLocation: sourceLocation)
116+
}
117+
106118
public func testDiagnostics(
107119
_ diagnostics: [Basics.Diagnostic],
108120
problemsOnly: Bool = true,

0 commit comments

Comments
 (0)