Skip to content
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

[GR-48855] Test truffleruby on JDK latest #3288

Merged
merged 4 commits into from
Oct 13, 2023
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
116 changes: 55 additions & 61 deletions ci.jsonnet

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b15-debug", "platformspecific": true },
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b15-sulong", "platformspecific": true },

"oraclejdk-latest": {"name": "jpg-jdk", "version": "22", "build_id": "16", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22+16-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+16-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+16-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22+16-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22+16-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22+16-jvmci-b01-sulong", "platformspecific": true }
"oraclejdk-latest": {"name": "jpg-jdk", "version": "22", "build_id": "17", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22+17-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+17-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+17-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22+17-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22+17-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22+17-jvmci-b01-sulong", "platformspecific": true }
},

"eclipse": {
Expand Down
4 changes: 2 additions & 2 deletions mx.truffleruby/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{
"name": "regex",
"subdir": True,
"version": "c1b45e412a198f635e468e9906bc9103a7ea9c3a",
"version": "7f29f8bd69ebeb74f4ba2ce0a7096388bf757dfa",
"urls": [
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
Expand All @@ -29,7 +29,7 @@
{
"name": "sulong",
"subdir": True,
"version": "c1b45e412a198f635e468e9906bc9103a7ea9c3a",
"version": "7f29f8bd69ebeb74f4ba2ce0a7096388bf757dfa",
"urls": [
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
Expand Down
4 changes: 2 additions & 2 deletions src/launcher/java/org/truffleruby/launcher/RubyLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ protected boolean parseCommonOption(String defaultOptionPrefix, Map<String, Stri
@Override
protected boolean runLauncherAction() {
String pager;
if (helpOptionUsed && System.console() != null && !(pager = getPagerFromEnv()).isEmpty()) {
if (helpOptionUsed && isTTY() && !(pager = getPagerFromEnv()).isEmpty()) {
try {
Process process = new ProcessBuilder(pager.split(" "))
.redirectOutput(Redirect.INHERIT) // set the output of the pager to the terminal and not a pipe
Expand Down Expand Up @@ -264,7 +264,7 @@ private int runRubyMain(Context.Builder contextBuilder, CommandLineOptions confi
break;
case IRB:
config.executionAction = ExecutionAction.PATH;
if (System.console() != null) {
if (isTTY()) {
getError().println(
"[ruby] WARNING: truffleruby starts IRB when stdin is a TTY instead of reading from stdin, use '-' to read from stdin");
config.executionAction = ExecutionAction.PATH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ private ConsoleHolder(
this.in = new IoStream(context, language, inFd, inIo);
this.out = new IoStream(context, language, outFd, outIo);

boolean isTTY = System.console() != null;
boolean system = isTTY && inFd == 0 && outFd == 1;
boolean system = IsTTYHelper.isTTY() && inFd == 0 && outFd == 1;

final Terminal terminal;
try {
Expand Down
44 changes: 44 additions & 0 deletions src/main/java/org/truffleruby/stdlib/readline/IsTTYHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 2.0, or
* GNU General Public License version 2, or
* GNU Lesser General Public License version 2.1.
*/
package org.truffleruby.stdlib.readline;

import java.io.Console;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public final class IsTTYHelper {

private static final Method IS_TERMINAL_METHOD = getIsTerminalMethod();

private static Method getIsTerminalMethod() {
try {
return Console.class.getMethod("isTerminal");
} catch (NoSuchMethodException e) {
return null;
}
}

public static boolean isTTY() {
Console console = System.console();
if (console == null) {
return false;
}
if (IS_TERMINAL_METHOD != null) {
try {
return (boolean) IS_TERMINAL_METHOD.invoke(console);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new Error(e);
}
} else {
return true;
}
}

}
51 changes: 6 additions & 45 deletions tool/jt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
# Expand GEM_HOME relative to cwd so it cannot be misinterpreted later.
ENV['GEM_HOME'] = File.expand_path(ENV['GEM_HOME']) if ENV['GEM_HOME']

JDK_VERSIONS = [21, 17]
DEFAULT_JDK_VERSION = JDK_VERSIONS.first
JDK_VERSIONS = %w[latest 21]
DEFAULT_JDK_VERSION = JDK_VERSIONS.last

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

if os_version_changed?
warn "Kernel version changed since last build: #{build_kernel_ver.inspect} -> #{host_kernel_ver.inspect}"
remove_shared_compile_artifacts
end

if options.delete('--new-hash')
build_information_path = "#{TRUFFLERUBY_DIR}/src/shared/java/org/truffleruby/shared/BuildInformation.java"
raise unless File.exist?(build_information_path) # in case the file moves in the future
Expand Down Expand Up @@ -2595,40 +2590,6 @@ def bootstrap_toolchain
end
end

def remove_shared_compile_artifacts
if build_information_path.file?
warn "Deleting shared build artifacts to trigger rebuild: #{shared_path}"
shared_path.rmtree
end
end

def os_version_changed?
build_kernel_ver != host_kernel_ver
end

def host_kernel_ver
`uname -r`[/^\d+/]
end

def build_kernel_ver
return '' unless build_information_path.file?

build_information = build_information_path.readlines
build_os_ver_loc = build_information.index { |l| l.include?('getKernelMajorVersion') }
return '' unless build_os_ver_loc

build_information[build_os_ver_loc + 1][/"(\d+)/, 1]
end

def shared_path
Pathname.new("#{TRUFFLERUBY_DIR}/mxbuild/jdk#{@jdk_version}/org.truffleruby.shared")
end

def build_information_path
shared_path
.join('src_gen/org/truffleruby/shared/BuildInformationImpl.java')
end

def next(*args)
puts `cat spec/tags/core/**/**.txt | grep 'fails:'`.lines.sample
end
Expand Down Expand Up @@ -3237,7 +3198,7 @@ def process_pre_args(args)
needs_rebuild = false
@silent = false
@verbose = false
@jdk_version = Integer(ENV['JT_JDK'] || DEFAULT_JDK_VERSION)
@jdk_version = ENV['JT_JDK'] || DEFAULT_JDK_VERSION

until args.empty?
arg = args.shift
Expand All @@ -3253,7 +3214,7 @@ def process_pre_args(args)
when '-v', '--verbose'
@verbose = true
when '--jdk'
@jdk_version = Integer(args.shift)
@jdk_version = args.shift
when '-h', '-help', '--help'
help
exit
Expand All @@ -3263,7 +3224,7 @@ def process_pre_args(args)
end
end

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

if needs_rebuild
rebuild
Expand Down