Skip to content

Commit 2402906

Browse files
committed
[GR-47781] [GR-45161] Split unit tests into embedding and internal tests and run embedding tests on module path
PullRequest: truffleruby/3954
2 parents 7212053 + 417cce7 commit 2402906

39 files changed

+789
-582
lines changed

.gitattributes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
/src/main/c/truffleposix/Makefile linguist-vendored
2929
/lib/gems/gems/*/bin/setup linguist-vendored
3030
/lib/truffle/post_install_hook.sh linguist-vendored
31-
/src/test/* linguist-vendored
31+
/src/test-embedding/* linguist-vendored
32+
/src/test-internal/* linguist-vendored
3233
/src/processor/* linguist-vendored
3334

3435
# Generated code

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ AllCops:
1717
- 'lib/truffle/socket/mri.rb' # taken from MRI
1818
- 'lib/truffle/ffi/**/*.rb' # taken from FFI gem
1919
- 'src/main/ruby/truffleruby/core/truffle/ffi/pointer_extra.rb' # taken from FFI gem
20-
- 'src/test/ruby/types.rb' # deliberately strange code for debugging purposes
20+
- 'src/test-internal/ruby/types.rb' # deliberately strange code for debugging purposes
2121
- 'src/tck/ruby/lexical-context.rb' # deliberately strange code for debugging purposes
2222

2323
# Type 'Layout' (166):

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Performance:
4949

5050
Changes:
5151

52+
* The TruffleRuby `ScriptEngine` implementation is removed in favor of the generic [ScriptEngine](https://github.com/oracle/graal/blob/master/docs/reference-manual/embedding/embed-languages.md#compatibility-with-jsr-223-scriptengine) in GraalVM docs.
5253

5354
Memory Footprint:
5455

common.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Jsonnet files should not include this file directly but use ci/common.jsonnet instead."
55
],
66

7-
"mx_version": "6.41.0",
7+
"mx_version": "6.42.0",
88

99
"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
1010
"jdks": {
@@ -42,7 +42,7 @@
4242
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b13-debug", "platformspecific": true },
4343
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b13-sulong", "platformspecific": true },
4444

45-
"oraclejdk22": {"name": "jpg-jdk", "version": "22", "build_id": "2", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]}
45+
"oraclejdk22": {"name": "jpg-jdk", "version": "22", "build_id": "8", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]}
4646
},
4747

4848
"eclipse": {

doc/contributor/using-eclipse.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@ We can now import the projects:
3737
* Select this repository as root directory
3838
* Click `Finish`
3939

40-
There should be now 4 projects in your workspace:
41-
* `truffleruby`
42-
* `truffleruby-test`
43-
* `TRUFFLERUBY-TEST.dist`
44-
* `TRUFFLERUBY.dist`
40+
There should be now some projects in your workspace, like `truffleruby` and `TRUFFLERUBY.dist`.
4541

4642
## Advanced Setup
4743

doc/user/jruby-migration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ The standalone distribution does not allow for Java interoperability.
2121

2222
JRuby supports many different ways to embed Ruby in Java, including JSR 223 (also know as `javax.script`), the Bean Scripting Framework (BSF), JRuby Embed (also known as Red Bridge), and the JRuby direct embedding API.
2323

24-
Thes best way to embed TruffleRuby is to use the Polyglot API, which is part of GraalVM.
24+
The best way to embed TruffleRuby is to use the Polyglot API, which is part of GraalVM.
2525
The API is different because it is designed to support many languages, not just Ruby.
2626

2727
TruffleRuby also supports JSR 223, compatible with JRuby, to make it easier to run legacy JRuby code.
28+
See [this documentation](https://github.com/oracle/graal/blob/master/docs/reference-manual/embedding/embed-languages.md#compatibility-with-jsr-223-scriptengine) for how to use it.
2829

2930
You will need to use GraalVM to use both of these APIs.
3031

mx.truffleruby/mx_truffleruby.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def contents(self, result):
119119
'--disable-gems',
120120
'--disable-rubyopt',
121121
]
122-
command = [jdk.java] + jvm_args + [main_class] + ruby_options + ['"$@"']
122+
command = [jdk.java] + jvm_args + ['-m', 'org.graalvm.ruby.launcher/' + main_class] + ruby_options + ['"$@"']
123123
return "#!/usr/bin/env bash\n" + "exec " + " ".join(command) + "\n"
124124

125125

@@ -143,14 +143,14 @@ def build_truffleruby(args):
143143

144144
def ruby_check_heap_dump(input_args, out=None):
145145
print("mx ruby_check_heap_dump " + " ".join(input_args))
146-
dists = ['TRUFFLERUBY', 'TRUFFLE_NFI', 'SULONG_NATIVE', 'TRUFFLERUBY-TEST']
146+
dists = ['TRUFFLERUBY', 'TRUFFLE_NFI', 'SULONG_NATIVE', 'TRUFFLERUBY-TEST-INTERNAL']
147147
mx.command_function('build')(['--dependencies', ','.join(dists)])
148148
args = input_args
149149
args.insert(0, "--experimental-options")
150150
vm_args, truffleruby_args = mx.extract_VM_args(args, useDoubleDash=True, defaultAllVMArgs=False)
151151
vm_args += mx.get_runtime_jvm_args(dists)
152152
# vm_args.append("-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=y")
153-
vm_args.append("org.truffleruby.LeakTest")
153+
vm_args.append("org.truffleruby.test.internal.LeakTest")
154154
out = mx.OutputCapture() if out is None else out
155155
retval = mx.run_java(vm_args + truffleruby_args, jdk=jdk, nonZeroIsFatal=False, out=out)
156156
if retval == 0:
@@ -273,9 +273,6 @@ def verify_ci(args):
273273
'truffleruby:JCODINGS',
274274
'truffleruby:JONI',
275275
],
276-
boot_jars=[
277-
'truffleruby:TRUFFLERUBY-SERVICES'
278-
],
279276
support_distributions=[
280277
'truffleruby:TRUFFLERUBY_GRAALVM_SUPPORT',
281278
'truffleruby:TRUFFLERUBY_GRAALVM_SUPPORT_NO_NI_RESOURCES',

mx.truffleruby/suite.py

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
suite = {
2-
"mxversion": "6.41.0",
2+
"mxversion": "6.42.0",
33
"name": "truffleruby",
44
"groupId": "org.graalvm.ruby",
55
"url": "https://www.graalvm.org/ruby/",
@@ -20,7 +20,7 @@
2020
{
2121
"name": "regex",
2222
"subdir": True,
23-
"version": "97a02e74911e7446dbf53098f885bc2fceba6770",
23+
"version": "e7b40b1010e34bde2e64993ba8cece3833ec60e8",
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": "97a02e74911e7446dbf53098f885bc2fceba6770",
32+
"version": "e7b40b1010e34bde2e64993ba8cece3833ec60e8",
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"},
@@ -128,7 +128,6 @@
128128
"test/truffle/ecosystem/blog6",
129129
"test/truffle/ecosystem/hello-world",
130130
"test/truffle/ecosystem/rails-app",
131-
"test/truffle/offline",
132131
"tool/docker",
133132
"rubyspec_temp",
134133
]
@@ -320,15 +319,31 @@
320319
"license": ["EPL-2.0"],
321320
},
322321

323-
"org.truffleruby.test": {
324-
"dir": "src/test",
322+
"org.truffleruby.test.embedding": {
323+
"testProject": True,
324+
"dir": "src/test-embedding",
325+
"sourceDirs": ["java"],
326+
"requires": ["java.scripting"],
327+
"dependencies": [
328+
# Distributions
329+
"sdk:POLYGLOT",
330+
# Libraries
331+
"mx:JUNIT",
332+
],
333+
"javaCompliance": "17+",
334+
"checkstyle": "org.truffleruby",
335+
"license": ["EPL-2.0"],
336+
},
337+
338+
"org.truffleruby.test.internal": {
339+
"testProject": True,
340+
"dir": "src/test-internal",
325341
"sourceDirs": ["java", "ruby"],
326-
"requires": ["java.scripting", "java.management", "jdk.management"],
342+
"requires": ["java.management", "jdk.management"],
327343
"dependencies": [
328344
# Distributions
329345
"sdk:LAUNCHER_COMMON",
330346
"TRUFFLERUBY",
331-
"TRUFFLERUBY-SERVICES",
332347
# Libraries
333348
"mx:JUNIT",
334349
"truffleruby:NETBEANS-LIB-PROFILER",
@@ -415,6 +430,7 @@
415430
"tag": ["default", "public"],
416431
},
417432
"noMavenJavadoc": True,
433+
"useModulePath": True,
418434
},
419435

420436
# Required to share code between the launcher and the rest,
@@ -442,6 +458,7 @@
442458
"tag": ["default", "public"],
443459
},
444460
"noMavenJavadoc": True,
461+
"useModulePath": True,
445462
},
446463

447464
"TRUFFLERUBY-PROCESSOR": {
@@ -457,24 +474,6 @@
457474
"maven": False,
458475
},
459476

460-
"TRUFFLERUBY-SERVICES": {
461-
"moduleInfo": {
462-
"name": "org.graalvm.ruby.services",
463-
"exports": [
464-
"org.truffleruby.services.scriptengine",
465-
],
466-
},
467-
"dependencies": [
468-
"org.truffleruby.services"
469-
],
470-
"distDependencies": [
471-
"sdk:GRAAL_SDK",
472-
],
473-
"description": "TruffleRuby services",
474-
"license": ["EPL-2.0"],
475-
"maven": False,
476-
},
477-
478477
"TRUFFLERUBY": {
479478
"moduleInfo": {
480479
"name": "org.graalvm.ruby",
@@ -492,6 +491,9 @@
492491
"sulong:SULONG_API",
493492
"sulong:SULONG_NFI",
494493
"sdk:JLINE3",
494+
# runtime-only dependencies
495+
"truffle:TRUFFLE_NFI_LIBFFI",
496+
"sulong:SULONG_NATIVE",
495497
],
496498
"exclude": [ # Keep in sync with org.truffleruby dependencies and truffle_jars in mx_truffleruby.py
497499
"truffleruby:JCODINGS",
@@ -509,6 +511,7 @@
509511
"tag": ["default", "public"],
510512
},
511513
"noMavenJavadoc": True,
514+
"useModulePath": True,
512515
},
513516

514517
"RUBY_COMMUNITY": {
@@ -560,6 +563,7 @@
560563
"description": "TruffleRuby Launcher",
561564
"license": ["EPL-2.0"],
562565
"maven": False,
566+
"useModulePath": True,
563567
},
564568

565569
"TRUFFLERUBY_GRAALVM_SUPPORT": {
@@ -675,15 +679,35 @@
675679
},
676680
},
677681

678-
"TRUFFLERUBY-TEST": {
682+
"TRUFFLERUBY-TEST-EMBEDDING": {
683+
"testDistribution": True,
684+
"dependencies": [
685+
"org.truffleruby.test.embedding",
686+
],
687+
"distDependencies": [
688+
"sdk:POLYGLOT",
689+
# runtime-only dependencies
690+
"TRUFFLERUBY",
691+
],
692+
"exclude": [
693+
"mx:HAMCREST",
694+
"mx:JUNIT",
695+
],
696+
"javaProperties": {
697+
"org.graalvm.language.ruby.home": "<path:TRUFFLERUBY_GRAALVM_SUPPORT>"
698+
},
699+
"license": ["EPL-2.0"],
700+
"maven": False,
701+
},
702+
703+
"TRUFFLERUBY-TEST-INTERNAL": {
679704
"testDistribution": True,
680705
"dependencies": [
681-
"org.truffleruby.test",
706+
"org.truffleruby.test.internal",
682707
],
683708
"distDependencies": [
684709
"sdk:LAUNCHER_COMMON",
685710
"TRUFFLERUBY",
686-
"TRUFFLERUBY-SERVICES",
687711
],
688712
"exclude": [
689713
"mx:HAMCREST",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ private void printPreRunInformation(CommandLineOptions config) {
371371

372372
private String getImplementationNameFromEngine() {
373373
if (implementationName == null) {
374-
try (Engine engine = Engine.create()) {
374+
try (Engine engine = Engine.newBuilder().option("engine.WarnInterpreterOnly", "false").build()) {
375375
implementationName = engine.getImplementationName();
376376
}
377377
}

src/main/java/org/truffleruby/language/loader/EmbeddedScript.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private boolean isShebangLine(byte[] bytes, int lineStart) {
103103
return bytes.length - lineStart >= 2 && bytes[lineStart] == '#' && bytes[lineStart + 1] == '!';
104104
}
105105

106-
static boolean lineContainsRuby(byte[] bytes, int lineStart, int lineLength) {
106+
public static boolean lineContainsRuby(byte[] bytes, int lineStart, int lineLength) {
107107
if (lineLength < 4) {
108108
return false;
109109
}

0 commit comments

Comments
 (0)