Skip to content

Revert "Filter superfluous diagnostics" #7293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions Sources/SPMTestSupport/Observability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ public struct TestingObservability {

// TODO: do something useful with scope
func handleDiagnostic(scope: ObservabilityScope, diagnostic: Basics.Diagnostic) {
// Filter superfluous diagnostics.
guard !diagnostic.message.hasPrefix("<unknown>:0: warning: annotation implies no releases") else {
return
}
guard !diagnostic.message.hasPrefix("<unknown>:0: note: add explicit") else {
return
}

if self.verbose {
print(diagnostic.description)
}
Expand Down
16 changes: 0 additions & 16 deletions Sources/SPMTestSupport/Toolchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,6 @@ extension UserToolchain {
}
}

// This builds a trivial program with `-warnings-as-errors`, if it fails, the compiler in use generates warnings by default and is not suitable for testing warnings as errors behaviors.
public func supportsWarningsAsErrors() -> Bool {
do {
try testWithTemporaryDirectory { tmpPath in
let inputPath = tmpPath.appending("best.swift")
try localFileSystem.writeFileContents(inputPath, string: "print(\"hello\")")
let outputPath = tmpPath.appending("foo")
let toolchainPath = self.swiftCompilerPath.parentDirectory.parentDirectory
try Process.checkNonZeroExit(arguments: ["/usr/bin/xcrun", "--toolchain", toolchainPath.pathString, "swiftc", inputPath.pathString, "-o", outputPath.pathString, "-warnings-as-errors"])
}
return true
} catch {
return false
}
}

/// Helper function to determine whether we should run SDK-dependent tests.
public func supportsSDKDependentTests() -> Bool {
return ProcessInfo.processInfo.environment["SWIFTCI_DISABLE_SDK_DEPENDENT_TESTS"] == nil
Expand Down
5 changes: 1 addition & 4 deletions Tests/CommandsTests/PackageToolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2407,10 +2407,7 @@ final class PackageToolTests: CommandsTestCase {
do {
let (stdout, stderr) = try SwiftPM.Package.execute(["plugin", "MyPlugin", "--foo", "--help", "--version", "--verbose"], packagePath: packageDir)
XCTAssertMatch(stdout, .contains("success"))
let filteredStderr = stderr.components(separatedBy: "\n").filter {
!$0.contains("annotation implies no releases") && !$0.contains("note: add explicit")
}.joined(separator: "\n")
XCTAssertEqual(filteredStderr, "")
XCTAssertEqual(stderr, "")
}

// Check default command arguments
Expand Down
2 changes: 1 addition & 1 deletion Tests/FunctionalTests/MiscellaneousTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ class MiscellaneousTestCase: XCTestCase {
func testRootPackageWithConditionals() throws {
try fixture(name: "Miscellaneous/RootPackageWithConditionals") { path in
let (_, stderr) = try SwiftPM.Build.execute(packagePath: path)
let errors = stderr.components(separatedBy: .newlines).filter { !$0.contains("[logging] misuse") && !$0.contains("annotation implies no releases") && !$0.contains("note: add explicit") && !$0.isEmpty }
let errors = stderr.components(separatedBy: .newlines).filter { !$0.contains("[logging] misuse") && !$0.isEmpty }
XCTAssertEqual(errors, [], "unexpected errors: \(errors)")
}
}
Expand Down
3 changes: 0 additions & 3 deletions Tests/FunctionalTests/ResourcesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
//===----------------------------------------------------------------------===//

import Basics
import PackageModel
import SPMTestSupport
import XCTest

Expand Down Expand Up @@ -101,8 +100,6 @@ class ResourcesTests: XCTestCase {
}

func testSwiftResourceAccessorDoesNotCauseInconsistentImportWarning() throws {
try XCTSkipIf(!UserToolchain.default.supportsWarningsAsErrors(), "skipping because test environment doesn't support warnings as errors")

try fixture(name: "Resources/FoundationlessClient/UtilsWithFoundationPkg") { fixturePath in
XCTAssertBuilds(
fixturePath,
Expand Down