Skip to content

Commit 1353407

Browse files
committed
Split unit tests into embedding and internal tests
1 parent 711192c commit 1353407

27 files changed

+146
-67
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):

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

mx.truffleruby/mx_truffleruby.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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.test.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:

mx.truffleruby/suite.py

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,31 @@
320320
"license": ["EPL-2.0"],
321321
},
322322

323-
"org.truffleruby.test": {
324-
"dir": "src/test",
323+
"org.truffleruby.test.embedding": {
324+
"testProject": True,
325+
"dir": "src/test-embedding",
326+
"sourceDirs": ["java"],
327+
"requires": ["java.scripting"],
328+
"dependencies": [
329+
# Distributions
330+
"TRUFFLERUBY-SERVICES",
331+
# Libraries
332+
"mx:JUNIT",
333+
],
334+
"javaCompliance": "17+",
335+
"checkstyle": "org.truffleruby",
336+
"license": ["EPL-2.0"],
337+
},
338+
339+
"org.truffleruby.test.internal": {
340+
"testProject": True,
341+
"dir": "src/test-internal",
325342
"sourceDirs": ["java", "ruby"],
326-
"requires": ["java.scripting", "java.management", "jdk.management"],
343+
"requires": ["java.management", "jdk.management"],
327344
"dependencies": [
328345
# Distributions
329346
"sdk:LAUNCHER_COMMON",
330347
"TRUFFLERUBY",
331-
"TRUFFLERUBY-SERVICES",
332348
# Libraries
333349
"mx:JUNIT",
334350
"truffleruby:NETBEANS-LIB-PROFILER",
@@ -675,15 +691,35 @@
675691
},
676692
},
677693

678-
"TRUFFLERUBY-TEST": {
694+
"TRUFFLERUBY-TEST-EMBEDDING": {
679695
"testDistribution": True,
680696
"dependencies": [
681-
"org.truffleruby.test",
697+
"org.truffleruby.test.embedding",
698+
],
699+
"distDependencies": [
700+
"TRUFFLERUBY-SERVICES",
701+
# runtime-only dependencies
702+
"TRUFFLERUBY",
703+
],
704+
"exclude": [
705+
"mx:HAMCREST",
706+
"mx:JUNIT",
707+
],
708+
"javaProperties": {
709+
"org.graalvm.language.ruby.home": "<path:TRUFFLERUBY_GRAALVM_SUPPORT>"
710+
},
711+
"license": ["EPL-2.0"],
712+
"maven": False,
713+
},
714+
715+
"TRUFFLERUBY-TEST-INTERNAL": {
716+
"testDistribution": True,
717+
"dependencies": [
718+
"org.truffleruby.test.internal",
682719
],
683720
"distDependencies": [
684721
"sdk:LAUNCHER_COMMON",
685722
"TRUFFLERUBY",
686-
"TRUFFLERUBY-SERVICES",
687723
],
688724
"exclude": [
689725
"mx:HAMCREST",

src/test/java/org/truffleruby/test/ContextPermissionsTest.java renamed to src/test-embedding/java/org/truffleruby/test/embedding/ContextPermissionsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* GNU General Public License version 2, or
88
* GNU Lesser General Public License version 2.1.
99
*/
10-
package org.truffleruby.test;
10+
package org.truffleruby.test.embedding;
1111

1212
import org.graalvm.polyglot.Context;
1313
import org.graalvm.polyglot.Value;

src/test/java/org/truffleruby/test/JSR223InteropTest.java renamed to src/test-embedding/java/org/truffleruby/test/embedding/JSR223InteropTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
* GNU General Public License version 2, or
88
* GNU Lesser General Public License version 2.1.
99
*/
10-
package org.truffleruby.test;
10+
package org.truffleruby.test.embedding;
1111

1212
import static org.junit.Assert.assertEquals;
13+
import static org.junit.Assert.assertNotNull;
1314
import static org.junit.Assert.assertTrue;
1415
import static org.junit.Assert.fail;
1516

@@ -25,9 +26,8 @@
2526

2627
import org.junit.After;
2728
import org.junit.Test;
28-
import org.truffleruby.fixtures.FluidForce;
29+
import org.truffleruby.test.embedding.fixtures.FluidForce;
2930
import org.truffleruby.services.scriptengine.TruffleRubyScriptEngineFactory;
30-
import org.truffleruby.shared.TruffleRuby;
3131

3232
public class JSR223InteropTest {
3333

@@ -51,7 +51,7 @@ private static void close(ScriptEngine scriptEngine) {
5151

5252
@Test
5353
public void testVersion() {
54-
assertEquals(TruffleRuby.getEngineVersion(), new TruffleRubyScriptEngineFactory().getEngineVersion());
54+
assertNotNull(new TruffleRubyScriptEngineFactory().getEngineVersion());
5555
}
5656

5757
@Test

src/test/java/org/truffleruby/test/MiscTest.java renamed to src/test-embedding/java/org/truffleruby/test/embedding/MiscTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* GNU General Public License version 2, or
88
* GNU Lesser General Public License version 2.1.
99
*/
10-
package org.truffleruby.test;
10+
package org.truffleruby.test.embedding;
1111

1212
import static org.junit.Assert.assertEquals;
1313
import static org.junit.Assert.assertFalse;

src/test/java/org/truffleruby/test/PolyglotIOTest.java renamed to src/test-embedding/java/org/truffleruby/test/embedding/PolyglotIOTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* GNU General Public License version 2, or
88
* GNU Lesser General Public License version 2.1.
99
*/
10-
package org.truffleruby.test;
10+
package org.truffleruby.test.embedding;
1111

1212
import static org.junit.Assert.assertEquals;
1313

@@ -17,7 +17,6 @@
1717
import org.graalvm.polyglot.Context;
1818
import org.graalvm.polyglot.Source;
1919
import org.junit.Test;
20-
import org.truffleruby.shared.TruffleRuby;
2120

2221
public class PolyglotIOTest extends RubyTest {
2322

@@ -27,7 +26,7 @@ public void testPolyglotIn() {
2726
final ByteArrayInputStream in = new ByteArrayInputStream("abc".getBytes());
2827

2928
try (Context context = RubyTest.setupContext(Context.newBuilder()).out(out).in(in).build()) {
30-
context.eval(Source.create(TruffleRuby.LANGUAGE_ID, "puts STDIN.read(3)"));
29+
context.eval(Source.create("ruby", "puts STDIN.read(3)"));
3130
}
3231

3332
assertEquals("abc\n", out.toString());
@@ -38,7 +37,7 @@ public void testPolyglotOut() {
3837
final ByteArrayOutputStream out = new ByteArrayOutputStream();
3938

4039
try (Context context = RubyTest.setupContext(Context.newBuilder()).out(out).build()) {
41-
context.eval(Source.create(TruffleRuby.LANGUAGE_ID, "puts 'abc'"));
40+
context.eval(Source.create("ruby", "puts 'abc'"));
4241
}
4342

4443
assertEquals("abc\n", out.toString());
@@ -49,7 +48,7 @@ public void testPolyglotErr() {
4948
final ByteArrayOutputStream err = new ByteArrayOutputStream();
5049

5150
try (Context context = RubyTest.setupContext(Context.newBuilder()).err(err).build()) {
52-
context.eval(Source.create(TruffleRuby.LANGUAGE_ID, "STDERR.puts 'abc'"));
51+
context.eval(Source.create("ruby", "STDERR.puts 'abc'"));
5352
}
5453

5554
assertEquals("abc\n", err.toString());

src/test/java/org/truffleruby/test/PolyglotInteropTest.java renamed to src/test-embedding/java/org/truffleruby/test/embedding/PolyglotInteropTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* GNU General Public License version 2, or
88
* GNU Lesser General Public License version 2.1.
99
*/
10-
package org.truffleruby.test;
10+
package org.truffleruby.test.embedding;
1111

1212
import static org.junit.Assert.assertEquals;
1313
import static org.junit.Assert.assertFalse;
@@ -22,15 +22,14 @@
2222
import org.graalvm.polyglot.Source;
2323
import org.graalvm.polyglot.Value;
2424
import org.junit.Test;
25-
import org.truffleruby.fixtures.FluidForce;
26-
import org.truffleruby.shared.TruffleRuby;
25+
import org.truffleruby.test.embedding.fixtures.FluidForce;
2726

2827
public class PolyglotInteropTest {
2928

3029
@Test
3130
public void testCreateContext() {
3231
try (Context polyglot = Context.create()) {
33-
assertEquals(14, polyglot.eval(TruffleRuby.LANGUAGE_ID, "14").asInt());
32+
assertEquals(14, polyglot.eval("ruby", "14").asInt());
3433
}
3534
}
3635

0 commit comments

Comments
 (0)