Skip to content

Commit 1102157

Browse files
authored
Merge pull request #62 from ktoso/disable-jvm-creating-tests-on-macos-terminap
2 parents 38fdd9e + c70f3d2 commit 1102157

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

Tests/JExtractSwiftTests/VariableImportTests.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ final class VariableImportTests {
4141
)
4242
st.log.logLevel = .error
4343

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

4646
let identifier = "counterInt"
4747
let varDecl: ImportedVariable? =
@@ -59,7 +59,6 @@ final class VariableImportTests {
5959
}
6060

6161
assertOutput(
62-
dump: true,
6362
output,
6463
expected:
6564
"""

Tests/JavaKitTests/BasicRuntimeTests.swift

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,21 @@ import JavaKit
1616
import JavaKitNetwork
1717
import JavaKitVM
1818
import Testing
19+
import Foundation
20+
21+
#if os(Linux)
22+
import Glibc
23+
#else
24+
import Darwin
25+
#endif
1926

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

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

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

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

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

96+
/// Whether we're running on MacOS in an interactive terminal session.
97+
var isMacOSTerminal: Bool {
98+
isMacOS && (
99+
isatty(STDOUT_FILENO) == 1 ||
100+
ProcessInfo.processInfo.environment["IS_TTY"] != nil // since 'swift test' still sometimes hides the fact we're in tty
101+
)
102+
}
103+
89104
/// Whether we're running on MacOS.
90105
var isMacOS: Bool {
91106
#if os(macOS)

0 commit comments

Comments
 (0)