Skip to content

Commit d27410b

Browse files
committed
Add TracingTests
1 parent 24d0dd8 commit d27410b

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

Sources/OpenSwiftUICore/Util/Tracing.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ enum Tracing {
3434
} else {
3535
#if canImport(Darwin)
3636
var info = Dl_info()
37-
guard dladdr(nominalDescriptor, &info) == 0 else {
37+
guard dladdr(nominalDescriptor, &info) != 0 else {
3838
return unknown
3939
}
4040
let name = (String(cString: info.dli_fname) as NSString).lastPathComponent
4141
moduleLookupCache.value[nominalDescriptor] = name
42-
return unknown
42+
return name
4343
#else
4444
// TODO: [Easy] Add a C layer to import dladdr on non-Darwin Swift platform
4545
// See https://forums.swift.org/t/dladdr-and-the-clang-importer/26379/11

Tests/OpenSwiftUICoreTests/Util/ThreadUtilsTest.swift renamed to Tests/OpenSwiftUICoreTests/Util/ThreadUtilsTests.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
//
2-
// ThreadUtilsTest.swift
2+
// ThreadUtilsTests.swift
33
// OpenSwiftUICoreTests
44

55
import OpenSwiftUICore
66
import Testing
77

8-
struct ThreadUtilsTest {
8+
struct ThreadUtilsTests {
99
static let defaultValue: Int = 1
1010
static let box = ThreadSpecific(defaultValue)
1111

1212
@Test
1313
func value() async throws {
14-
let box = ThreadUtilsTest.box
15-
#expect(box.value == ThreadUtilsTest.defaultValue)
14+
let box = ThreadUtilsTests.box
15+
#expect(box.value == ThreadUtilsTests.defaultValue)
1616
try await withThrowingTaskGroup(of: Int.self) { group in
1717
group.addTask {
1818
await Task.detached {
@@ -30,7 +30,7 @@ struct ThreadUtilsTest {
3030
}
3131
let result = try await group.reduce(0, +)
3232
#expect(result == 7)
33-
#expect(box.value == ThreadUtilsTest.defaultValue)
33+
#expect(box.value == ThreadUtilsTests.defaultValue)
3434
}
3535
}
3636
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// TracingTests.swift
3+
// OpenSwiftUICoreTests
4+
5+
@testable import OpenSwiftUICore
6+
import OpenGraphShims
7+
import Testing
8+
9+
@Suite(.disabled(if: !attributeGraphEnabled, "Not implemented in OG yet"))
10+
struct TracingTests {
11+
struct Demo {}
12+
13+
@Test(.disabled(if: !attributeGraphEnabled, "OGTypeDescription is not implemented yet"))
14+
func name() {
15+
#expect(Tracing.nominalTypeName(Int.self) == "Int")
16+
#expect(Tracing.nominalTypeName(String.self) == "String")
17+
#expect(Tracing.nominalTypeName(Demo.self) == "TracingTests.Demo")
18+
}
19+
20+
@Test(.disabled(if: !attributeGraphEnabled, "OGTypeNominalDescriptor is not implemented yet"))
21+
func library() async throws {
22+
#expect(Tracing.libraryName(defining: Int.self) == "libswiftCore.dylib")
23+
#expect(Tracing.libraryName(defining: String.self) == "libswiftCore.dylib")
24+
#expect(Tracing.libraryName(defining: Demo.self) == "OpenSwiftUICoreTests")
25+
}
26+
}

0 commit comments

Comments
 (0)