Skip to content

Commit 9d77ca1

Browse files
committed
Set the home correctly for all unit tests
1 parent 3adf74a commit 9d77ca1

File tree

5 files changed

+8
-29
lines changed

5 files changed

+8
-29
lines changed

ci.jsonnet

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,8 @@ local part_definitions = {
348348

349349
run: {
350350
test_unit_tck_specs: {
351-
run+: [
352-
["mx", "unittest", "org.truffleruby"],
353-
["mx", "tck"],
354-
] + jt(["test", "specs"] + self["$.run.specs"].test_spec_options),
351+
run+: jt(["test", "unit"]) + jt(["test", "tck"]) +
352+
jt(["test", "specs"] + self["$.run.specs"].test_spec_options),
355353
# + jt(["test", "specs", ":next"]) disabled as it's currently empty and MSpec doesn't support empty sets of files
356354
},
357355

src/test/java/org/truffleruby/ContextPermissionsTest.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ public void testNoPermissions() throws Throwable {
2929

3030
@Test
3131
public void testNativeNoThreads() throws Throwable {
32-
// TODO (eregon, 4 Feb 2019): This should run on GraalVM, not development jars
33-
String home = System.getProperty("user.dir") + "/mxbuild/truffleruby-jvm/jre/languages/ruby";
34-
try (Context context = Context.newBuilder("ruby").allowNativeAccess(true).allowExperimentalOptions(true).option("ruby.home", home).build()) {
32+
try (Context context = Context.newBuilder("ruby").allowNativeAccess(true).build()) {
3533
Assert.assertEquals(3, context.eval("ruby", "1 + 2").asInt());
3634

3735
Assert.assertEquals(true, context.eval("ruby", "File.directory?('.')").asBoolean());
@@ -40,13 +38,9 @@ public void testNativeNoThreads() throws Throwable {
4038

4139
@Test
4240
public void testRequireGem() {
43-
// TODO (eregon, 4 Feb 2019): This should run on GraalVM, not development jars
44-
String home = System.getProperty("user.dir") + "/mxbuild/truffleruby-jvm/jre/languages/ruby";
4541
try (Context context = Context.newBuilder("ruby")
4642
.allowIO(true)
4743
.allowNativeAccess(true)
48-
.allowExperimentalOptions(true)
49-
.option("ruby.home", home)
5044
.build()) {
5145
// NOTE: rake is a bundled gem, so it needs RubyGems to be required
5246
Assert.assertEquals("Rake", context.eval("ruby", "require 'rake'; Rake.to_s").asString());

src/test/java/org/truffleruby/PolyglotInteropTest.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.junit.Test;
1616
import org.truffleruby.fixtures.FluidForce;
1717
import org.truffleruby.shared.TruffleRuby;
18-
import org.truffleruby.shared.options.OptionsCatalog;
1918

2019
import java.util.List;
2120
import java.util.function.BiFunction;
@@ -30,7 +29,6 @@ public class PolyglotInteropTest {
3029
@Test
3130
public void testCreateContext() {
3231
try (Context polyglot = Context.newBuilder()
33-
.option(OptionsCatalog.HOME.getName(), System.getProperty("user.dir"))
3432
.allowAllAccess(true)
3533
.build()) {
3634
assertEquals(14, polyglot.eval(TruffleRuby.LANGUAGE_ID, "14").asInt());
@@ -41,7 +39,6 @@ public void testCreateContext() {
4139
public void testCreateContextNoAccess() {
4240
try (Context polyglot = Context.newBuilder()
4341
.allowExperimentalOptions(true)
44-
.option(OptionsCatalog.HOME.getName(), System.getProperty("user.dir"))
4542
.option(OptionsCatalog.NATIVE_PLATFORM.getName(), Boolean.FALSE.toString())
4643
.build()) {
4744
assertEquals(14, polyglot.eval(TruffleRuby.LANGUAGE_ID, "14").asInt());
@@ -51,7 +48,6 @@ public void testCreateContextNoAccess() {
5148
@Test
5249
public void testParameters() {
5350
try (Context polyglot = Context.newBuilder()
54-
.option(OptionsCatalog.HOME.getName(), System.getProperty("user.dir"))
5551
.allowAllAccess(true)
5652
.build()) {
5753
assertEquals(16, polyglot.eval("ruby", "lambda { |a, b| a + b }").execute(14, 2).asInt());
@@ -61,7 +57,6 @@ public void testParameters() {
6157
@Test
6258
public void testCallingMethods() {
6359
try (Context polyglot = Context.newBuilder()
64-
.option(OptionsCatalog.HOME.getName(), System.getProperty("user.dir"))
6560
.allowAllAccess(true)
6661
.build()) {
6762
assertEquals(0.909, polyglot.eval("ruby", "Math").getMember("sin").execute(2).asDouble(), 0.01);
@@ -71,7 +66,6 @@ public void testCallingMethods() {
7166
@Test
7267
public void testPassingBlocks() {
7368
try (Context polyglot = Context.newBuilder()
74-
.option(OptionsCatalog.HOME.getName(), System.getProperty("user.dir"))
7569
.allowAllAccess(true)
7670
.build()) {
7771
final int[] counter = new int[]{0};
@@ -86,7 +80,6 @@ public void testPassingBlocks() {
8680
@Test
8781
public void testCreatingObjects() {
8882
try (Context polyglot = Context.newBuilder()
89-
.option(OptionsCatalog.HOME.getName(), System.getProperty("user.dir"))
9083
.allowAllAccess(true)
9184
.build()) {
9285
assertEquals(2021, polyglot.eval("ruby", "Time").newInstance(2021, 3, 18).getMember("year").execute().asInt());
@@ -96,7 +89,6 @@ public void testCreatingObjects() {
9689
@Test
9790
public void testAccessingArrays() {
9891
try (Context polyglot = Context.newBuilder()
99-
.option(OptionsCatalog.HOME.getName(), System.getProperty("user.dir"))
10092
.allowAllAccess(true)
10193
.build()) {
10294
assertEquals(4, polyglot.eval("ruby", "[3, 4, 5]").getArrayElement(1).asInt());
@@ -107,7 +99,6 @@ public void testAccessingArrays() {
10799
@Test
108100
public void testAccessingHashes() {
109101
try (Context polyglot = Context.newBuilder()
110-
.option(OptionsCatalog.HOME.getName(), System.getProperty("user.dir"))
111102
.allowAllAccess(true)
112103
.build()) {
113104
final Value access = polyglot.eval("ruby", "->(hash, key) { hash[key] }");
@@ -119,7 +110,6 @@ public void testAccessingHashes() {
119110
@Test
120111
public void testImplementInterface() {
121112
try (Context polyglot = Context.newBuilder()
122-
.option(OptionsCatalog.HOME.getName(), System.getProperty("user.dir"))
123113
.allowAllAccess(true)
124114
.build()) {
125115
final FluidForce fluidForce = polyglot.eval("ruby", FluidForce.RUBY_SOURCE).as(FluidForce.class);
@@ -131,7 +121,6 @@ public void testImplementInterface() {
131121
@Test
132122
public void testImplementLambda() {
133123
try (Context polyglot = Context.newBuilder()
134-
.option(OptionsCatalog.HOME.getName(), System.getProperty("user.dir"))
135124
.allowAllAccess(true)
136125
.build()) {
137126
final BiFunction adder = polyglot.eval("ruby", "lambda { |a, b| a + b }").as(BiFunction.class);
@@ -142,7 +131,6 @@ public void testImplementLambda() {
142131
@Test
143132
public void testParseOnceRunMany() {
144133
try (Context polyglot = Context.newBuilder()
145-
.option(OptionsCatalog.HOME.getName(), System.getProperty("user.dir"))
146134
.allowAllAccess(true)
147135
.build()) {
148136
final Value parsedOnce = polyglot.eval("ruby", "lambda { 14 }");
@@ -153,7 +141,6 @@ public void testParseOnceRunMany() {
153141
@Test
154142
public void testLocalVariablesNotSharedBetweenNonInteractiveEval() {
155143
try (Context polyglot = Context.newBuilder()
156-
.option(OptionsCatalog.HOME.getName(), System.getProperty("user.dir"))
157144
.allowAllAccess(true)
158145
.build()) {
159146
polyglot.eval("ruby", "a = 14");
@@ -164,7 +151,6 @@ public void testLocalVariablesNotSharedBetweenNonInteractiveEval() {
164151
@Test
165152
public void testLocalVariablesSharedBetweenInteractiveEval() {
166153
try (Context polyglot = Context.newBuilder()
167-
.option(OptionsCatalog.HOME.getName(), System.getProperty("user.dir"))
168154
.allowAllAccess(true)
169155
.build()) {
170156
polyglot.eval(Source.newBuilder("ruby", "a = 14", "test").interactive(true).buildLiteral());
@@ -177,7 +163,6 @@ public void testLocalVariablesSharedBetweenInteractiveEval() {
177163
@Test
178164
public void testLocalVariablesSharedBetweenInteractiveEvalChangesParsing() {
179165
try (Context polyglot = Context.newBuilder()
180-
.option(OptionsCatalog.HOME.getName(), System.getProperty("user.dir"))
181166
.allowAllAccess(true)
182167
.build()) {
183168
polyglot.eval(Source.newBuilder("ruby", "def foo; 12; end", "test").interactive(true).buildLiteral());
@@ -190,7 +175,6 @@ public void testLocalVariablesSharedBetweenInteractiveEvalChangesParsing() {
190175
@Test
191176
public void testLocalVariablesAreNotSharedBetweenInteractiveAndNonInteractive() {
192177
try (Context polyglot = Context.newBuilder()
193-
.option(OptionsCatalog.HOME.getName(), System.getProperty("user.dir"))
194178
.allowAllAccess(true)
195179
.build()) {
196180
polyglot.eval(Source.newBuilder("ruby", "a = 14", "test").interactive(false).buildLiteral());

src/test/java/org/truffleruby/RubyTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public static Context.Builder setupContext(Context.Builder builder) {
5757
return builder
5858
.allowAllAccess(true)
5959
.option(OptionsCatalog.EXCEPTIONS_TRANSLATE_ASSERT.getName(), Boolean.FALSE.toString())
60-
.option(OptionsCatalog.HOME.getName(), System.getProperty("user.dir"))
6160
.option(OptionsCatalog.BASICOPS_INLINE.getName(), Boolean.FALSE.toString());
6261
}
6362

tool/jt.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,11 @@ def test(*args)
814814
when 'mri' then test_mri(*rest)
815815
when 'unit', 'unittest'
816816
tests = rest.empty? ? ['org.truffleruby'] : rest
817-
mx 'unittest', *tests
817+
# TODO (eregon, 4 Feb 2019): This should run on GraalVM, not development jars
818+
# The home needs to be set, otherwise TruffleFile does not allow access to files in the TruffleRuby home,
819+
# because it cannot find the correct home.
820+
home = "-Druby.home=#{TRUFFLERUBY_DIR}/mxbuild/truffleruby-jvm/jre/languages/ruby"
821+
mx 'unittest', home, *tests
818822
when 'tck' then mx 'tck'
819823
else
820824
if File.expand_path(path, TRUFFLERUBY_DIR).start_with?("#{TRUFFLERUBY_DIR}/test")

0 commit comments

Comments
 (0)