Skip to content

Commit 463a96b

Browse files
authored
Revert "Tests: Convert Environment/Graph and other suites to ST (#8624)"
This reverts commit 26d8417.
1 parent a4cd504 commit 463a96b

File tree

9 files changed

+234
-329
lines changed

9 files changed

+234
-329
lines changed

Sources/_InternalTestSupport/Observability.swift

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift open source project
44
//
5-
// Copyright (c) 2021-2025 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2021 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
@@ -18,7 +18,6 @@ import func XCTest.XCTFail
1818
import struct TSCBasic.StringError
1919

2020
import TSCTestSupport
21-
import Testing
2221

2322
extension ObservabilitySystem {
2423
public static func makeForTesting(verbose: Bool = true) -> TestingObservability {
@@ -140,37 +139,6 @@ public func testDiagnostics(
140139
}
141140
}
142141

143-
public func expectDiagnostics(
144-
_ diagnostics: [Basics.Diagnostic],
145-
problemsOnly: Bool = true,
146-
sourceLocation: SourceLocation = #_sourceLocation,
147-
handler: (DiagnosticsTestResult) throws -> Void
148-
) throws {
149-
try expectDiagnostics(
150-
diagnostics,
151-
minSeverity: problemsOnly ? .warning : .debug,
152-
sourceLocation: sourceLocation,
153-
handler: handler
154-
)
155-
}
156-
157-
158-
public func expectDiagnostics(
159-
_ diagnostics: [Basics.Diagnostic],
160-
minSeverity: Basics.Diagnostic.Severity,
161-
sourceLocation: SourceLocation = #_sourceLocation,
162-
handler: (DiagnosticsTestResult) throws -> Void
163-
) throws {
164-
let diagnostics = diagnostics.filter { $0.severity >= minSeverity }
165-
let testResult = DiagnosticsTestResult(diagnostics)
166-
167-
try handler(testResult)
168-
169-
if !testResult.uncheckedDiagnostics.isEmpty {
170-
Issue.record("unchecked diagnostics \(testResult.uncheckedDiagnostics)", sourceLocation: sourceLocation)
171-
}
172-
}
173-
174142
public func testPartialDiagnostics(
175143
_ diagnostics: [Basics.Diagnostic],
176144
minSeverity: Basics.Diagnostic.Severity,

Tests/BasicsTests/Environment/EnvironmentKeyTests.swift

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,100 +2,91 @@
22
//
33
// This source file is part of the Swift open source project
44
//
5-
// Copyright (c) 2021-2025 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2021 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
99
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010
//
1111
//===----------------------------------------------------------------------===//
12-
import Foundation
1312

1413
@testable import Basics
15-
import Testing
14+
import XCTest
1615

17-
struct EnvironmentKeyTests {
18-
@Test
19-
func comparable() {
16+
final class EnvironmentKeyTests: XCTestCase {
17+
func test_comparable() {
2018
let key0 = EnvironmentKey("Test")
2119
let key1 = EnvironmentKey("Test1")
22-
#expect(key0 < key1)
20+
XCTAssertLessThan(key0, key1)
2321

2422
let key2 = EnvironmentKey("test")
25-
#expect(key0 < key2)
23+
XCTAssertLessThan(key0, key2)
2624
}
2725

28-
@Test
29-
func customStringConvertible() {
26+
func test_customStringConvertible() {
3027
let key = EnvironmentKey("Test")
31-
#expect(key.description == "Test")
28+
XCTAssertEqual(key.description, "Test")
3229
}
3330

34-
@Test
35-
func encodable() throws {
31+
func test_encodable() throws {
3632
let key = EnvironmentKey("Test")
3733
let data = try JSONEncoder().encode(key)
3834
let string = String(data: data, encoding: .utf8)
39-
#expect(string == #""Test""#)
35+
XCTAssertEqual(string, #""Test""#)
4036
}
4137

42-
@Test
43-
func equatable() {
38+
func test_equatable() {
4439
let key0 = EnvironmentKey("Test")
4540
let key1 = EnvironmentKey("Test")
46-
#expect(key0 == key1)
41+
XCTAssertEqual(key0, key1)
4742

4843
let key2 = EnvironmentKey("Test2")
49-
#expect(key0 != key2)
44+
XCTAssertNotEqual(key0, key2)
5045

5146
#if os(Windows)
5247
// Test case insensitivity on windows
5348
let key3 = EnvironmentKey("teSt")
54-
#expect(key0 == key3)
49+
XCTAssertEqual(key0, key3)
5550
#endif
5651
}
5752

58-
@Test
59-
func expressibleByStringLiteral() {
53+
func test_expressibleByStringLiteral() {
6054
let key0 = EnvironmentKey("Test")
61-
#expect(key0 == "Test")
55+
XCTAssertEqual(key0, "Test")
6256
}
6357

64-
@Test
65-
func decodable() throws {
58+
func test_decodable() throws {
6659
let jsonString = #""Test""#
6760
let data = jsonString.data(using: .utf8)!
6861
let key = try JSONDecoder().decode(EnvironmentKey.self, from: data)
69-
#expect(key.rawValue == "Test")
62+
XCTAssertEqual(key.rawValue, "Test")
7063
}
7164

72-
@Test
73-
func hashable() {
65+
func test_hashable() {
7466
var set = Set<EnvironmentKey>()
7567
let key0 = EnvironmentKey("Test")
76-
#expect(set.insert(key0).inserted)
68+
XCTAssertTrue(set.insert(key0).inserted)
7769

7870
let key1 = EnvironmentKey("Test")
79-
#expect(set.contains(key1))
80-
#expect(!set.insert(key1).inserted)
71+
XCTAssertTrue(set.contains(key1))
72+
XCTAssertFalse(set.insert(key1).inserted)
8173

8274
let key2 = EnvironmentKey("Test2")
83-
#expect(!set.contains(key2))
84-
#expect(set.insert(key2).inserted)
75+
XCTAssertFalse(set.contains(key2))
76+
XCTAssertTrue(set.insert(key2).inserted)
8577

8678
#if os(Windows)
8779
// Test case insensitivity on windows
8880
let key3 = EnvironmentKey("teSt")
89-
#expect(set.contains(key3))
90-
#expect(!set.insert(key3).inserted)
81+
XCTAssertTrue(set.contains(key3))
82+
XCTAssertFalse(set.insert(key3).inserted)
9183
#endif
9284

93-
#expect(set == ["Test", "Test2"])
85+
XCTAssertEqual(set, ["Test", "Test2"])
9486
}
9587

96-
@Test
97-
func rawRepresentable() {
88+
func test_rawRepresentable() {
9889
let key = EnvironmentKey(rawValue: "Test")
99-
#expect(key?.rawValue == "Test")
90+
XCTAssertEqual(key?.rawValue, "Test")
10091
}
10192
}

0 commit comments

Comments
 (0)