Skip to content

Commit e1fca82

Browse files
committed
[GR-51385] Avoid multiple Context#eval when possible in launcher as a workaround for chromeinspector tests
1 parent 2512cc9 commit e1fca82

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,6 @@ private int runContext(Context.Builder builder, CommandLineOptions config) {
331331
try (Context context = builder.build()) {
332332
Metrics.printTime("before-run");
333333

334-
Value rubyHome = context.eval(source(
335-
// language=ruby
336-
"Truffle::Boot.ruby_home"));
337-
if (rubyHome.isString()) {
338-
this.rubyHome = rubyHome.asString();
339-
}
340-
341334
if (config.executionAction == ExecutionAction.PATH) {
342335
final Source source = source(// language=ruby
343336
"-> name { Truffle::Boot.find_s_file(name) }");
@@ -368,6 +361,17 @@ private int runContext(Context.Builder builder, CommandLineOptions config) {
368361
final long argv = getNativeArgv();
369362
final String kind = config.executionAction.name();
370363
final int processStatus = context.eval(source).execute(argc, argv, kind, config.toExecute).asInt();
364+
365+
if (ProcessStatus.isSignal(processStatus)) {
366+
// Only fetch the ruby home when necessary, because chromeinspector tests
367+
// currently only work with a single Context#eval.
368+
Value rubyHome = context.eval(source(// language=ruby
369+
"Truffle::Boot.ruby_home"));
370+
if (rubyHome.isString()) {
371+
this.rubyHome = rubyHome.asString();
372+
}
373+
}
374+
371375
Metrics.printTime("after-run");
372376
return processStatus;
373377
} catch (PolyglotException e) {

0 commit comments

Comments
 (0)