Skip to content
Open
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
18 changes: 14 additions & 4 deletions Sources/_InternalTestSupport/Observability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -248,17 +248,27 @@ public class DiagnosticsTestResult {
severity: Basics.Diagnostic.Severity,
//metadata: ObservabilityMetadata? = .none,
file: StaticString = #file,
line: UInt = #line
line: UInt = #line,
sourceLocation: SourceLocation = #_sourceLocation
) -> Basics.Diagnostic? {
guard !self.uncheckedDiagnostics.isEmpty else {
XCTFail("No diagnostics left to check", file: file, line: line)
if Test.current != nil {
Issue.record("No diagnostics left to check", sourceLocation: sourceLocation)
} else {
XCTFail("No diagnostics left to check", file: file, line: line)
}
return nil
}

let diagnostic: Basics.Diagnostic = self.uncheckedDiagnostics.removeFirst()

XCTAssertMatch(diagnostic.message, message, file: file, line: line)
XCTAssertEqual(diagnostic.severity, severity, file: file, line: line)
if Test.current != nil {
#expect(diagnostic.severity == severity, sourceLocation: sourceLocation)
#expect(message ~= diagnostic.message, sourceLocation: sourceLocation)
} else {
XCTAssertMatch(diagnostic.message, message, file: file, line: line)
XCTAssertEqual(diagnostic.severity, severity, file: file, line: line)
}
// FIXME: (diagnostics) compare complete metadata when legacy bridge is removed
//XCTAssertEqual(diagnostic.metadata, metadata, file: file, line: line)
//XCTAssertEqual(diagnostic.metadata?.droppingLegacyKeys(), metadata?.droppingLegacyKeys(), file: file, line: line)
Expand Down
1 change: 1 addition & 0 deletions Tests/BasicsTests/CancellatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

@testable import Basics
import _InternalTestSupport
import Testing
import XCTest

import class Basics.AsyncProcess
Expand Down
2 changes: 1 addition & 1 deletion Tests/BasicsTests/ObservabilitySystemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ struct ObservabilitySystemTest {
#expect(diagnostic_metadata.testKey1 == metadata.testKey1)
}
do {
let diagnostic = try #require(result.check(diagnostic: "debug", severity: .error))
let diagnostic = try #require(result.check(diagnostic: "debug", severity: .debug))
let diagnostic_metadata = try #require(diagnostic.metadata)
#expect(diagnostic_metadata.testKey1 == metadata.testKey1)
}
Expand Down
1 change: 1 addition & 0 deletions Tests/PackageLoadingTests/ManifestLoaderCacheTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@testable import PackageLoading
import PackageModel
import _InternalTestSupport
import Testing
import XCTest

@available(macOS 13, iOS 16, tvOS 16, watchOS 9, *)
Expand Down
1 change: 1 addition & 0 deletions Tests/PackageLoadingTests/ModuleMapGenerationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Basics
import PackageLoading
import PackageModel
import _InternalTestSupport
import Testing
import XCTest

final class ModuleMapGeneration: XCTestCase {
Expand Down
1 change: 1 addition & 0 deletions Tests/PackageLoadingTests/PD_4_0_LoadingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Basics
import PackageLoading
import PackageModel
import _InternalTestSupport
import Testing
import XCTest

final class PackageDescription4_0LoadingTests: PackageDescriptionLoadingTests {
Expand Down
1 change: 1 addition & 0 deletions Tests/PackageLoadingTests/PD_4_2_LoadingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Dispatch
import PackageLoading
import PackageModel
import _InternalTestSupport
import Testing
import XCTest

import enum TSCBasic.PathValidationError
Expand Down
1 change: 1 addition & 0 deletions Tests/PackageLoadingTests/PD_5_0_LoadingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Basics
import PackageLoading
import PackageModel
import _InternalTestSupport
import Testing
import XCTest

import struct TSCBasic.ByteString
Expand Down
1 change: 1 addition & 0 deletions Tests/PackageLoadingTests/PD_5_2_LoadingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Basics
import PackageLoading
import PackageModel
import _InternalTestSupport
import Testing
import XCTest

final class PackageDescription5_2LoadingTests: PackageDescriptionLoadingTests {
Expand Down
1 change: 1 addition & 0 deletions Tests/PackageLoadingTests/PD_5_3_LoadingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Basics
import PackageModel
import PackageLoading
import _InternalTestSupport
import Testing
import XCTest

import enum TSCBasic.PathValidationError
Expand Down
1 change: 1 addition & 0 deletions Tests/PackageLoadingTests/PkgConfigParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import Basics
@testable import PackageLoading
import _InternalTestSupport
import Testing
import XCTest

import struct TSCBasic.ByteString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Foundation
import PackageModel
import PackageLoading
import _InternalTestSupport
import Testing
import XCTest

final class TargetSourcesBuilderTests: XCTestCase {
Expand Down
1 change: 1 addition & 0 deletions Tests/PackageModelTests/PackageModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Basics

import _InternalTestSupport
import func TSCBasic.withTemporaryFile
import Testing
import XCTest

import struct TSCBasic.ByteString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import PackageModel
@testable import PackageRegistry
@testable import PackageSigning
import _InternalTestSupport
import Testing
import XCTest

import struct TSCUtility.Version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import PackageFingerprint
import PackageModel
@testable import PackageRegistry
import _InternalTestSupport
import Testing
import XCTest

import struct TSCUtility.Version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import PackageModel
import PackageSigning
import _InternalTestSupport
import X509 // FIXME: need this import or else SwiftSigningIdentity init crashes
import Testing
import XCTest

import struct TSCUtility.Version
Expand Down
1 change: 1 addition & 0 deletions Tests/SourceControlTests/RepositoryManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import _Concurrency
import PackageModel
import _InternalTestSupport
@testable import SourceControl
import Testing
import XCTest

final class RepositoryManagerTests: XCTestCase {
Expand Down
5 changes: 0 additions & 5 deletions Tests/SwiftBuildSupportTests/FileSystemUtilsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,6 @@ struct CreateBuildSymbolicLinkFunction {
)

testDiagnostics(observability.diagnostics) { result in
result.check(
diagnostic: .contains("unable to delete"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: this test used an FileSystemDouble which throws an exception when trying to remove a file or a tree. so I would expect this diagnostic to get emitted.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see this warning locally, but maybe that's unique to my CI setup. I'll see what the CI jobs report and change this if needed

severity: .warning
)

result.check(
diagnostic: .contains("unable to create symbolic link"),
severity: .warning
Expand Down
1 change: 1 addition & 0 deletions Tests/WorkspaceTests/WorkspaceTests+Traits.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import _InternalTestSupport
import Basics
import PackageModel
import Testing
import XCTest

extension WorkspaceTests {
Expand Down
1 change: 1 addition & 0 deletions Tests/WorkspaceTests/WorkspaceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import PackageSigning
import SourceControl
import SPMBuildCore
@testable import Workspace
import Testing
import XCTest

import struct TSCBasic.ByteString
Expand Down
Loading