@@ -331,13 +331,6 @@ private int runContext(Context.Builder builder, CommandLineOptions config) {
331
331
try (Context context = builder .build ()) {
332
332
Metrics .printTime ("before-run" );
333
333
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
-
341
334
if (config .executionAction == ExecutionAction .PATH ) {
342
335
final Source source = source (// language=ruby
343
336
"-> name { Truffle::Boot.find_s_file(name) }" );
@@ -349,7 +342,7 @@ private int runContext(Context.Builder builder, CommandLineOptions config) {
349
342
} else {
350
343
getError ()
351
344
.println ("truffleruby: No such file or directory -- " + config .toExecute + " (LoadError)" );
352
- return 1 ;
345
+ return ProcessStatus . exitCode ( 1 ) ;
353
346
}
354
347
}
355
348
@@ -368,13 +361,24 @@ private int runContext(Context.Builder builder, CommandLineOptions config) {
368
361
final long argv = getNativeArgv ();
369
362
final String kind = config .executionAction .name ();
370
363
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
+
371
375
Metrics .printTime ("after-run" );
372
376
return processStatus ;
373
377
} catch (PolyglotException e ) {
374
378
getError ().println (
375
379
"truffleruby: an exception escaped out of the interpreter - this is an implementation bug" );
376
380
e .printStackTrace (System .err );
377
- return 1 ;
381
+ return ProcessStatus . exitCode ( 1 ) ;
378
382
}
379
383
}
380
384
0 commit comments