Skip to content

Skipping the JVM tests on macOS terminal since unreliable (crashes in JVM create) #62

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
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
3 changes: 1 addition & 2 deletions Tests/JExtractSwiftTests/VariableImportTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final class VariableImportTests {
)
st.log.logLevel = .error

try await st.analyze(swiftInterfacePath: "/fake/Fake.swiftinterface", text: class_interfaceFile)
try st.analyze(swiftInterfacePath: "/fake/Fake.swiftinterface", text: class_interfaceFile)

let identifier = "counterInt"
let varDecl: ImportedVariable? =
Expand All @@ -59,7 +59,6 @@ final class VariableImportTests {
}

assertOutput(
dump: true,
output,
expected:
"""
Expand Down
23 changes: 19 additions & 4 deletions Tests/JavaKitTests/BasicRuntimeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@ import JavaKit
import JavaKitNetwork
import JavaKitVM
import Testing
import Foundation

#if os(Linux)
import Glibc
#else
import Darwin
#endif

@MainActor
let jvm = try! JavaVirtualMachine(vmOptions: [])

@Suite
@MainActor
struct BasicRuntimeTests {
@Test("Object management", .disabled(if: isLinux, "Attempts to refcount a null pointer on Linux"))
@Test("Object management", .disabled(if: isMacOSTerminal || isLinux, "JVM creation fails occasionally in terminal on macOS, and some issues on Linux"))
func javaObjectManagement() throws {
let sneakyJavaThis: jobject
do {
Expand All @@ -49,7 +56,7 @@ struct BasicRuntimeTests {
#expect(url.javaHolder === urlAgain.javaHolder)
}

@Test("Java exceptions", .disabled(if: isLinux, "Attempts to refcount a null pointer on Linux"))
@Test("Java exceptions", .disabled(if: isMacOSTerminal || isLinux, "JVM creation fails occasionally in terminal on macOS, and some issues on Linux"))
func javaExceptionsInSwift() throws {
do {
_ = try URL("bad url", environment: jvm.environment)
Expand All @@ -58,13 +65,13 @@ struct BasicRuntimeTests {
}
}

@Test("Static methods", .disabled(if: isMacOS, "Fails on macOS command line"))
@Test("Static methods", .disabled(if: isMacOSTerminal || isLinux, "JVM creation fails occasionally in terminal on macOS, and some issues on Linux"))
func staticMethods() throws {
let urlConnectionClass = try JavaClass<URLConnection>(in: jvm.environment)
#expect(urlConnectionClass.getDefaultAllowUserInteraction() == false)
}

@Test("Class instance lookup")
@Test("Class instance lookup", .disabled(if: isMacOSTerminal || isLinux, "JVM creation fails occasionally in terminal on macOS, and some issues on Linux"))
func classInstanceLookup() throws {
do {
_ = try JavaClass<Nonexistent>(in: jvm.environment)
Expand All @@ -86,6 +93,14 @@ var isLinux: Bool {
#endif
}

/// Whether we're running on MacOS in an interactive terminal session.
var isMacOSTerminal: Bool {
isMacOS && (
isatty(STDOUT_FILENO) == 1 ||
ProcessInfo.processInfo.environment["IS_TTY"] != nil // since 'swift test' still sometimes hides the fact we're in tty
)
}

/// Whether we're running on MacOS.
var isMacOS: Bool {
#if os(macOS)
Expand Down