Skip to content

Commit bd034d6

Browse files
committed
[GR-14684] Add bootstraptest and basictest
PullRequest: truffleruby/736
2 parents 248f6ba + 788115f commit bd034d6

38 files changed

+9920
-6
lines changed

ci.jsonnet

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ local part_definitions = {
406406
] + jt(["lint"]) + self.after_build,
407407
},
408408

409+
test_basictest: { run+: jt(["test", "basictest"]) },
409410
test_mri: { run+: jt(["test", "mri", "--no-sulong", "--", "-j4"]) },
410411
test_integration: { run+: jt(["test", "integration"]) },
411412
test_gems: { run+: jt(["test", "gems"]) },
@@ -536,7 +537,7 @@ local composition_environment = utils.add_inclusion_tracking(part_definitions, "
536537
{
537538
local linux_gate = $.platform.linux + $.cap.gate + $.jdk.labsjdk8 + $.use.common + $.use.build + { timelimit: "01:00:00" },
538539

539-
"ruby-test-specs-linux": linux_gate + $.run.test_unit_tck_specs + { timelimit: "35:00" },
540+
"ruby-test-specs-linux": linux_gate + $.run.test_unit_tck_specs + $.run.test_basictest + { timelimit: "35:00" },
540541
"ruby-test-fast-linux": linux_gate + $.run.test_fast + { timelimit: "30:00" }, # To catch missing slow tags
541542
"ruby-test-mri-linux": linux_gate + $.run.test_mri + { timelimit: "30:00" },
542543
"ruby-test-integration": linux_gate + $.run.test_integration,
@@ -552,7 +553,7 @@ local composition_environment = utils.add_inclusion_tracking(part_definitions, "
552553
{
553554
local darwin_gate = $.platform.darwin + $.cap.gate + $.jdk.labsjdk8 + $.use.common + $.use.build + { timelimit: "01:00:00" },
554555

555-
"ruby-test-specs-darwin": darwin_gate + $.run.test_unit_tck_specs + { timelimit: "45:00" },
556+
"ruby-test-specs-darwin": darwin_gate + $.run.test_unit_tck_specs + $.run.test_basictest + { timelimit: "45:00" },
556557
"ruby-test-mri-darwin": darwin_gate + $.run.test_mri,
557558
"ruby-test-cexts-darwin": darwin_gate + $.use.gem_test_pack + $.run.test_cexts,
558559
} +

doc/contributor/testing.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ We talk about several types of tests in TruffleRuby:
88
* TCK (`TCK`)
99
* Specs (`SPECS`)
1010
* MRI tests (`MRI`)
11+
* MRI basictest (`BASIC`)
12+
* MRI bootstraptest (`BOOT`)
1113
* C extension tests (`CEXT`)
1214
* Bundler tests (`BUN`)
1315
* Compiler tests (`COMP`)
@@ -64,6 +66,23 @@ MRI tests are in `test/mri`.
6466

6567
Run MRI tests with `jt test mri`.
6668

69+
### MRI basictest
70+
71+
MRI's basictest is a smaller set of tests for some basic control structures
72+
and language features. It is in `test/basictest`.
73+
74+
Run basictest with `jt test basictest`.
75+
76+
### MRI bootstraptest
77+
78+
MRI's bootstraptest is a smaller set of tests for functionality they require
79+
to bootstrap their implementation, including some tests against regressions
80+
and corner cases. It is in `test/bootstraptest`.
81+
82+
Run bootstraptest with `jt test bootstraptest`. It's not
83+
tractable to run bootstraptest with the JVM, as it starts a new Ruby process
84+
for each test. Run it with a native build instead.
85+
6786
### C extension tests
6887

6988
C extension tests are a basic test of compiling, loading and running C
@@ -187,8 +206,8 @@ and configurations that aren't tested, due to limited resources.
187206

188207
* `UNIT` with `INT` on `J8` on Linux.
189208
* `UNIT` with `INT` on `J8` on macOS.
190-
* `SPEC` with `INT` on `J8` on Linux.
191-
* `SPEC` with `INT` on `J8` on macOS.
209+
* `BASICTEST`, `SPEC` with `INT` on `J8` on Linux.
210+
* `BASICTEST`, `SPEC` with `INT` on `J8` on macOS.
192211
* `SPEC(FAST)` with `INT` on `J11` on Linux.
193212
* `TCK` with `INT` on `J8` on Linux.
194213
* `MRI` with `INT` on `J8` on Linux.

src/main/java/org/truffleruby/core/CoreLibrary.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,10 @@ public DynamicObject getKernelModule() {
10881088
return kernelModule;
10891089
}
10901090

1091+
public DynamicObject getErrnoModule() {
1092+
return errnoModule;
1093+
}
1094+
10911095
public GlobalVariables getGlobalVariables() {
10921096
return globalVariables;
10931097
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public String getWorkingDirectory() {
154154
final Pointer buffer = GetThreadBufferNode.getBuffer(context, bufferSize);
155155
final long address = nfi.asPointer((TruffleObject) getcwd.call(buffer.getAddress(), bufferSize));
156156
if (address == 0) {
157-
throw new UnsupportedOperationException("getcwd() failed");
157+
context.send(context.getCoreLibrary().getErrnoModule(), "handle");
158158
}
159159
final byte[] bytes = buffer.readZeroTerminatedByteArray(context, 0);
160160
final Encoding localeEncoding = context.getEncodingManager().getLocaleEncoding();

src/main/ruby/core/kernel.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ def trace_var(name, cmd = nil, &block)
559559
end
560560
module_function :trace_var
561561

562-
def untrace_var(name, cmd)
562+
def untrace_var(name, cmd=undefined)
563563
# Truffle: not yet implemented
564564
end
565565
module_function :untrace_var

test/basictest/runner.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#! ./miniruby
2+
3+
exit if defined?(CROSS_COMPILING) and CROSS_COMPILING
4+
ruby = ENV["RUBY"]
5+
unless ruby
6+
if RUBY_ENGINE == 'truffleruby'
7+
require 'rbconfig'
8+
ruby = RbConfig.ruby
9+
else
10+
load './rbconfig.rb'
11+
ruby = "./#{RbConfig::CONFIG['ruby_install_name']}#{RbConfig::CONFIG['EXEEXT']}"
12+
end
13+
end
14+
unless File.exist? ruby
15+
print "#{ruby} is not found.\n"
16+
print "Try `make' first, then `make test', please.\n"
17+
exit false
18+
end
19+
ARGV[0] and opt = ARGV[0][/\A--run-opt=(.*)/, 1] and ARGV.shift
20+
21+
$stderr.reopen($stdout)
22+
error = ''
23+
24+
srcdir = File.expand_path('..', File.dirname(__FILE__))
25+
if env = ENV["RUBYOPT"]
26+
ENV["RUBYOPT"] = env + " -W1"
27+
end
28+
`#{ruby} #{opt} -W1 #{srcdir}/basictest/test.rb #{ARGV.join(' ')}`.each_line do |line|
29+
if line =~ /^end of test/
30+
print "\ntest succeeded\n"
31+
exit true
32+
end
33+
error << line if %r:^(basictest/test.rb|not): =~ line
34+
end
35+
puts
36+
print error
37+
print "test failed\n"
38+
exit false

0 commit comments

Comments
 (0)