Skip to content

Use a computed variable isLinux for disabling some tests #47

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
Oct 7, 2024
Merged
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
23 changes: 12 additions & 11 deletions Tests/JavaKitTests/BasicRuntimeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ let jvm = try! JavaVirtualMachine(vmOptions: [])
@Suite
@MainActor
struct BasicRuntimeTests {
#if os(Linux)
@Test("Object management", .disabled("Attempts to refcount a null pointer on Linux"))
#else
@Test("Object management", .disabled("Bad pointer de-reference on Linux"))
#endif
@Test("Object management", .disabled(if: isLinux, "Attempts to refcount a null pointer on Linux"))
func javaObjectManagement() throws {
let sneakyJavaThis: jobject
do {
Expand All @@ -54,12 +50,8 @@ struct BasicRuntimeTests {
#expect(url.javaHolder === urlAgain.javaHolder)
}

#if os(Linux)
@Test("Java exceptions", .disabled("Attempts to refcount a null pointer on Linux"))
#else
@Test("Java exceptions")
#endif
func javaExceptionsInSwift() async throws {
@Test("Java exceptions", .disabled(if: isLinux, "Attempts to refcount a null pointer on Linux"))
func javaExceptionsInSwift() throws {
do {
_ = try URL("bad url", environment: jvm.environment)
} catch {
Expand All @@ -77,3 +69,12 @@ struct BasicRuntimeTests {
#expect(urlConnectionClass.getDefaultAllowUserInteraction() == false)
}
}

/// Whether we're running on Linux.
var isLinux: Bool {
#if os(Linux)
return true
#else
return false
#endif
}
Loading