Skip to content

Commit ed67b73

Browse files
committed
Use a computed variable isLinux for disabling some tests
The `#if`s around `@Test` confuse some IDE tooling for tests, so replace it.
1 parent ab4c563 commit ed67b73

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Tests/JavaKitTests/BasicRuntimeTests.swift

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ let jvm = try! JavaVirtualMachine(vmOptions: [])
2424
@Suite
2525
@MainActor
2626
struct BasicRuntimeTests {
27-
#if os(Linux)
28-
@Test("Object management", .disabled("Attempts to refcount a null pointer on Linux"))
29-
#else
30-
@Test("Object management", .disabled("Bad pointer de-reference on Linux"))
31-
#endif
27+
@Test("Object management", .disabled(if: isLinux, "Attempts to refcount a null pointer on Linux"))
3228
func javaObjectManagement() throws {
3329
let sneakyJavaThis: jobject
3430
do {
@@ -54,12 +50,8 @@ struct BasicRuntimeTests {
5450
#expect(url.javaHolder === urlAgain.javaHolder)
5551
}
5652

57-
#if os(Linux)
58-
@Test("Java exceptions", .disabled("Attempts to refcount a null pointer on Linux"))
59-
#else
60-
@Test("Java exceptions")
61-
#endif
62-
func javaExceptionsInSwift() async throws {
53+
@Test("Java exceptions", .disabled(if: isLinux, "Attempts to refcount a null pointer on Linux"))
54+
func javaExceptionsInSwift() throws {
6355
do {
6456
_ = try URL("bad url", environment: jvm.environment)
6557
} catch {
@@ -77,3 +69,12 @@ struct BasicRuntimeTests {
7769
#expect(urlConnectionClass.getDefaultAllowUserInteraction() == false)
7870
}
7971
}
72+
73+
/// Whether we're running on Linux.
74+
var isLinux: Bool {
75+
#if os(Linux)
76+
return true
77+
#else
78+
return false
79+
#endif
80+
}

0 commit comments

Comments
 (0)