Skip to content

Commit cf372f0

Browse files
committed
[GR-48855] Test truffleruby on JDK latest
PullRequest: truffleruby/4027
2 parents 3545de8 + bddfc4b commit cf372f0

File tree

7 files changed

+117
-119
lines changed

7 files changed

+117
-119
lines changed

ci.jsonnet

Lines changed: 55 additions & 61 deletions
Large diffs are not rendered by default.

common.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b15-debug", "platformspecific": true },
4343
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b15-sulong", "platformspecific": true },
4444

45-
"oraclejdk-latest": {"name": "jpg-jdk", "version": "22", "build_id": "16", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
46-
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22+16-jvmci-b01", "platformspecific": true },
47-
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+16-jvmci-b01-debug", "platformspecific": true },
48-
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+16-jvmci-b01-sulong", "platformspecific": true },
49-
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22+16-jvmci-b01", "platformspecific": true },
50-
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22+16-jvmci-b01-debug", "platformspecific": true },
51-
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22+16-jvmci-b01-sulong", "platformspecific": true }
45+
"oraclejdk-latest": {"name": "jpg-jdk", "version": "22", "build_id": "17", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
46+
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22+17-jvmci-b01", "platformspecific": true },
47+
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+17-jvmci-b01-debug", "platformspecific": true },
48+
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+17-jvmci-b01-sulong", "platformspecific": true },
49+
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22+17-jvmci-b01", "platformspecific": true },
50+
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22+17-jvmci-b01-debug", "platformspecific": true },
51+
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22+17-jvmci-b01-sulong", "platformspecific": true }
5252
},
5353

5454
"eclipse": {

mx.truffleruby/suite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{
2121
"name": "regex",
2222
"subdir": True,
23-
"version": "c1b45e412a198f635e468e9906bc9103a7ea9c3a",
23+
"version": "7f29f8bd69ebeb74f4ba2ce0a7096388bf757dfa",
2424
"urls": [
2525
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
2626
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
@@ -29,7 +29,7 @@
2929
{
3030
"name": "sulong",
3131
"subdir": True,
32-
"version": "c1b45e412a198f635e468e9906bc9103a7ea9c3a",
32+
"version": "7f29f8bd69ebeb74f4ba2ce0a7096388bf757dfa",
3333
"urls": [
3434
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
3535
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},

src/launcher/java/org/truffleruby/launcher/RubyLauncher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ protected boolean parseCommonOption(String defaultOptionPrefix, Map<String, Stri
230230
@Override
231231
protected boolean runLauncherAction() {
232232
String pager;
233-
if (helpOptionUsed && System.console() != null && !(pager = getPagerFromEnv()).isEmpty()) {
233+
if (helpOptionUsed && isTTY() && !(pager = getPagerFromEnv()).isEmpty()) {
234234
try {
235235
Process process = new ProcessBuilder(pager.split(" "))
236236
.redirectOutput(Redirect.INHERIT) // set the output of the pager to the terminal and not a pipe
@@ -264,7 +264,7 @@ private int runRubyMain(Context.Builder contextBuilder, CommandLineOptions confi
264264
break;
265265
case IRB:
266266
config.executionAction = ExecutionAction.PATH;
267-
if (System.console() != null) {
267+
if (isTTY()) {
268268
getError().println(
269269
"[ruby] WARNING: truffleruby starts IRB when stdin is a TTY instead of reading from stdin, use '-' to read from stdin");
270270
config.executionAction = ExecutionAction.PATH;

src/main/java/org/truffleruby/stdlib/readline/ConsoleHolder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ private ConsoleHolder(
116116
this.in = new IoStream(context, language, inFd, inIo);
117117
this.out = new IoStream(context, language, outFd, outIo);
118118

119-
boolean isTTY = System.console() != null;
120-
boolean system = isTTY && inFd == 0 && outFd == 1;
119+
boolean system = IsTTYHelper.isTTY() && inFd == 0 && outFd == 1;
121120

122121
final Terminal terminal;
123122
try {
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. This
3+
* code is released under a tri EPL/GPL/LGPL license. You can use it,
4+
* redistribute it and/or modify it under the terms of the:
5+
*
6+
* Eclipse Public License version 2.0, or
7+
* GNU General Public License version 2, or
8+
* GNU Lesser General Public License version 2.1.
9+
*/
10+
package org.truffleruby.stdlib.readline;
11+
12+
import java.io.Console;
13+
import java.lang.reflect.InvocationTargetException;
14+
import java.lang.reflect.Method;
15+
16+
public final class IsTTYHelper {
17+
18+
private static final Method IS_TERMINAL_METHOD = getIsTerminalMethod();
19+
20+
private static Method getIsTerminalMethod() {
21+
try {
22+
return Console.class.getMethod("isTerminal");
23+
} catch (NoSuchMethodException e) {
24+
return null;
25+
}
26+
}
27+
28+
public static boolean isTTY() {
29+
Console console = System.console();
30+
if (console == null) {
31+
return false;
32+
}
33+
if (IS_TERMINAL_METHOD != null) {
34+
try {
35+
return (boolean) IS_TERMINAL_METHOD.invoke(console);
36+
} catch (IllegalAccessException | InvocationTargetException e) {
37+
throw new Error(e);
38+
}
39+
} else {
40+
return true;
41+
}
42+
}
43+
44+
}

tool/jt.rb

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@
6666
# Expand GEM_HOME relative to cwd so it cannot be misinterpreted later.
6767
ENV['GEM_HOME'] = File.expand_path(ENV['GEM_HOME']) if ENV['GEM_HOME']
6868

69-
JDK_VERSIONS = [21, 17]
70-
DEFAULT_JDK_VERSION = JDK_VERSIONS.first
69+
JDK_VERSIONS = %w[latest 21]
70+
DEFAULT_JDK_VERSION = JDK_VERSIONS.last
7171

7272
MRI_TEST_RELATIVE_PREFIX = 'test/mri/tests'
7373
MRI_TEST_PREFIX = "#{TRUFFLERUBY_DIR}/#{MRI_TEST_RELATIVE_PREFIX}"
@@ -184,7 +184,7 @@ def jvmci_version
184184
@jvmci_version ||= begin
185185
ci = File.read("#{TRUFFLERUBY_DIR}/common.json")
186186
edition = ee_jdk? ? 'ee' : 'ce'
187-
regex = /{\s*"name"\s*:\s*"labsjdk"\s*,\s*"version"\s*:\s*"#{edition}-#{@jdk_version}[^"]+-(jvmci-[^"]+)"\s*,/
187+
regex = /"labsjdk-#{edition}-#{@jdk_version}":\s*\{\s*"name":\s*"labsjdk"\s*,\s*"version":\s*"[^"]+-(jvmci-[^"]+)"\s*,/
188188
raise "JVMCI version not found for labsjdk-#{edition}-#{@jdk_version} in common.json" unless regex =~ ci
189189
$1
190190
end
@@ -2506,11 +2506,6 @@ def bootstrap_toolchain
25062506
raise 'use --env jvm-ce instead' if options.delete('--graal')
25072507
raise 'use --env native instead' if options.delete('--native')
25082508

2509-
if os_version_changed?
2510-
warn "Kernel version changed since last build: #{build_kernel_ver.inspect} -> #{host_kernel_ver.inspect}"
2511-
remove_shared_compile_artifacts
2512-
end
2513-
25142509
if options.delete('--new-hash')
25152510
build_information_path = "#{TRUFFLERUBY_DIR}/src/shared/java/org/truffleruby/shared/BuildInformation.java"
25162511
raise unless File.exist?(build_information_path) # in case the file moves in the future
@@ -2595,40 +2590,6 @@ def bootstrap_toolchain
25952590
end
25962591
end
25972592

2598-
def remove_shared_compile_artifacts
2599-
if build_information_path.file?
2600-
warn "Deleting shared build artifacts to trigger rebuild: #{shared_path}"
2601-
shared_path.rmtree
2602-
end
2603-
end
2604-
2605-
def os_version_changed?
2606-
build_kernel_ver != host_kernel_ver
2607-
end
2608-
2609-
def host_kernel_ver
2610-
`uname -r`[/^\d+/]
2611-
end
2612-
2613-
def build_kernel_ver
2614-
return '' unless build_information_path.file?
2615-
2616-
build_information = build_information_path.readlines
2617-
build_os_ver_loc = build_information.index { |l| l.include?('getKernelMajorVersion') }
2618-
return '' unless build_os_ver_loc
2619-
2620-
build_information[build_os_ver_loc + 1][/"(\d+)/, 1]
2621-
end
2622-
2623-
def shared_path
2624-
Pathname.new("#{TRUFFLERUBY_DIR}/mxbuild/jdk#{@jdk_version}/org.truffleruby.shared")
2625-
end
2626-
2627-
def build_information_path
2628-
shared_path
2629-
.join('src_gen/org/truffleruby/shared/BuildInformationImpl.java')
2630-
end
2631-
26322593
def next(*args)
26332594
puts `cat spec/tags/core/**/**.txt | grep 'fails:'`.lines.sample
26342595
end
@@ -3237,7 +3198,7 @@ def process_pre_args(args)
32373198
needs_rebuild = false
32383199
@silent = false
32393200
@verbose = false
3240-
@jdk_version = Integer(ENV['JT_JDK'] || DEFAULT_JDK_VERSION)
3201+
@jdk_version = ENV['JT_JDK'] || DEFAULT_JDK_VERSION
32413202

32423203
until args.empty?
32433204
arg = args.shift
@@ -3253,7 +3214,7 @@ def process_pre_args(args)
32533214
when '-v', '--verbose'
32543215
@verbose = true
32553216
when '--jdk'
3256-
@jdk_version = Integer(args.shift)
3217+
@jdk_version = args.shift
32573218
when '-h', '-help', '--help'
32583219
help
32593220
exit
@@ -3263,7 +3224,7 @@ def process_pre_args(args)
32633224
end
32643225
end
32653226

3266-
raise "Invalid JDK version: #{@jdk_version}" unless JDK_VERSIONS.include?(@jdk_version)
3227+
raise "Invalid JDK version: #{@jdk_version}. Valid values: #{JDK_VERSIONS.join(' or ')}" unless JDK_VERSIONS.include?(@jdk_version)
32673228

32683229
if needs_rebuild
32693230
rebuild

0 commit comments

Comments
 (0)