Skip to content

Commit 98d6cba

Browse files
committed
Add an expectation of a warning diagnostic to tests that hide libSwiftScan.
Such tests cause the driver to take a code-path that results in a warning: 'warning: Unable to locate libSwiftScan. Fallback to `swift-frontend` dependency scanner invocation.' This needs to be taken into account.
1 parent f55fbef commit 98d6cba

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Tests/CommandsTests/PackageCommandTests.swift

+11-5
Original file line numberDiff line numberDiff line change
@@ -2267,6 +2267,12 @@ final class PackageCommandTests: CommandsTestCase {
22672267
let containsRemark = StringPattern.contains("command plugin: Diagnostics.remark")
22682268
let containsWarning = StringPattern.contains("command plugin: Diagnostics.warning")
22692269
let containsError = StringPattern.contains("command plugin: Diagnostics.error")
2270+
let hiddenLibSwiftScanWarnPattern = StringPattern.equal(
2271+
"""
2272+
warning: 'miscellaneous_plugins_commandpluginteststub': warning: Unable to locate libSwiftScan. Fallback to `swift-frontend` dependency scanner invocation.
2273+
warning: Unable to locate libSwiftScan. Fallback to `swift-frontend` dependency scanner invocation.
2274+
warning: Unable to locate libSwiftScan. Fallback to `swift-frontend` dependency scanner invocation.
2275+
""")
22702276

22712277
try await fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in
22722278
func runPlugin(flags: [String], diagnostics: [String], completion: (String, String) -> Void) async throws {
@@ -2290,7 +2296,7 @@ final class PackageCommandTests: CommandsTestCase {
22902296

22912297
try await runPlugin(flags: [], diagnostics: ["print"]) { stdout, stderr in
22922298
XCTAssertMatch(stdout, isOnlyPrint)
2293-
XCTAssertMatch(stderr, isEmpty)
2299+
XCTAssertMatch(stderr, hiddenLibSwiftScanWarnPattern)
22942300
}
22952301

22962302
try await runPlugin(flags: [], diagnostics: ["print", "progress"]) { stdout, stderr in
@@ -2322,7 +2328,7 @@ final class PackageCommandTests: CommandsTestCase {
23222328

23232329
try await runPlugin(flags: ["-q"], diagnostics: ["print"]) { stdout, stderr in
23242330
XCTAssertMatch(stdout, isOnlyPrint)
2325-
XCTAssertMatch(stderr, isEmpty)
2331+
XCTAssertMatch(stderr, hiddenLibSwiftScanWarnPattern)
23262332
}
23272333

23282334
try await runPlugin(flags: ["-q"], diagnostics: ["print", "progress"]) { stdout, stderr in
@@ -2461,7 +2467,7 @@ final class PackageCommandTests: CommandsTestCase {
24612467
let containsLogtext = StringPattern.contains("command plugin: packageManager.build logtext: Building for debugging...")
24622468

24632469
// Echoed logs have no prefix
2464-
let containsLogecho = StringPattern.regex("^Building for debugging...\n")
2470+
let containsLogecho = StringPattern.contains("Building for debugging...\n")
24652471

24662472
// These tests involve building a target, so each test must run with a fresh copy of the fixture
24672473
// otherwise the logs may be different in subsequent tests.
@@ -2470,14 +2476,14 @@ final class PackageCommandTests: CommandsTestCase {
24702476
try await fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in
24712477
let (stdout, stderr) = try await SwiftPM.Package.execute(["print-diagnostics", "build"], packagePath: fixturePath, env: ["SWIFT_DRIVER_SWIFTSCAN_LIB" : "/this/is/a/bad/path"])
24722478
XCTAssertMatch(stdout, isEmpty)
2473-
XCTAssertMatch(stderr, isEmpty)
2479+
XCTAssertMatch(stderr, hiddenLibSwiftScanWarnPattern)
24742480
}
24752481

24762482
// Check that logs are returned to the plugin when echoLogs is false
24772483
try await fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in
24782484
let (stdout, stderr) = try await SwiftPM.Package.execute(["print-diagnostics", "build", "printlogs"], packagePath: fixturePath, env: ["SWIFT_DRIVER_SWIFTSCAN_LIB" : "/this/is/a/bad/path"])
24792485
XCTAssertMatch(stdout, containsLogtext)
2480-
XCTAssertMatch(stderr, isEmpty)
2486+
XCTAssertMatch(stderr, hiddenLibSwiftScanWarnPattern)
24812487
}
24822488

24832489
// Check that logs echoed to the console (on stderr) when echoLogs is true

0 commit comments

Comments
 (0)