Skip to content

Commit b797073

Browse files
committed
[GR-45621] Minor improvements for jt test :next command
PullRequest: truffleruby/3751
2 parents 10d90fd + 14813de commit b797073

File tree

6 files changed

+34
-12
lines changed

6 files changed

+34
-12
lines changed

doc/contributor/updating-ruby.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Update all of these:
160160

161161
For a new major version:
162162
* Update `TargetRubyVersion` in `.rubocop.yml`
163-
* Update the list of `:next` specs and change the "next version" in `spec/truffleruby.mspec`.
163+
* Update the list of `:next` specs.
164164
* Update the docs for next version specs in [workflow.md](workflow.md).
165165
* Update the versions in the `ruby/spec on CRuby` job of `.github/workflows/ci.yml`.
166166

doc/contributor/workflow.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ TruffleRuby currently targets Ruby 3.1. However, we welcome pull requests for
296296
Ruby 3.2 features as long as they don't conflict significantly with
297297
Ruby 3.1 semantics.
298298

299-
It is possible to run specs for Ruby 3.1 features by setting
299+
It is possible to run specs for Ruby 3.2 features by setting
300300
`PRETEND_RUBY_VERSION`:
301301

302302
```bash
@@ -306,8 +306,8 @@ PRETEND_RUBY_VERSION=3.2.0 jt test spec/ruby/.../some_spec.rb
306306
This also works for `jt tag`/`jt untag`.
307307

308308
When working on a feature from the next version of Ruby, add the spec file in
309-
the corresponding file list (`:next`) in `spec/truffleruby.mspec` so that the
310-
specs are run in CI too.
309+
the corresponding files list in `spec/truffleruby.next-specs` so that the specs
310+
are run in CI too.
311311

312312
## How to fix a failing MRI test
313313

spec/truffleruby.mspec

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,13 @@ class MSpecScript
101101
"spec/truffle/capi"
102102
]
103103

104-
# Use spec/ruby/core/nil/nil_spec.rb as a dummy file to avoid being empty
105-
set :next, %w[
106-
spec/ruby/core/nil/nil_spec.rb
107-
spec/ruby/core/hash/shift_spec.rb
108-
]
104+
# Use spec/truffleruby.next-specs to specify spec files to run for the next version.
105+
# Allow comments and empty lines.
106+
next_spec_files = File.readlines("spec/truffleruby.next-specs")
107+
.map(&:strip)
108+
.reject { |path| path.start_with?("#") || path.empty? }
109+
110+
set :next, next_spec_files
109111

110112
set :tags_patterns, [
111113
[%r(^(.*)/spec/ruby/(\w+)/(.+)_spec\.rb$), '\1/spec/tags/\2/\3_tags.txt'],
@@ -154,8 +156,13 @@ if MSpecScript.child_process?
154156
::VersionGuard.send :remove_const, :FULL_RUBY_VERSION
155157
::VersionGuard::FULL_RUBY_VERSION = SpecVersion.new(version)
156158
elsif ARGV.include? ":next"
159+
version = File.read(".ruby-version")
160+
161+
# get the next version, e.g. 3.1.2 -> 3.2.0
162+
next_version = version.split(".").tap { |ary| ary[1] = ary[1].next; ary[2] = '0' }.join(".")
163+
157164
::VersionGuard.send :remove_const, :FULL_RUBY_VERSION
158-
::VersionGuard::FULL_RUBY_VERSION = SpecVersion.new("3.2.0")
165+
::VersionGuard::FULL_RUBY_VERSION = SpecVersion.new(next_version)
159166
end
160167
end
161168

spec/truffleruby.next-specs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file contains a list of spec files that contain specs for already
2+
# implemented features of the next CRuby release.
3+
#
4+
# These specs should be run as a separate step with `jt test :next` command
5+
# until TruffleRuby supports this next CRuby version.
6+
#
7+
# Empty lines and comments are allowed.
8+
9+
# Use spec/ruby/core/nil/nil_spec.rb as a dummy file to avoid being empty (what causes mspec to error)
10+
spec/ruby/core/nil/nil_spec.rb
11+
12+
spec/ruby/core/hash/shift_spec.rb

src/main/java/org/truffleruby/language/arguments/ArgumentDescriptorUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.truffleruby.parser.ArgumentType;
2020

2121
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
22+
import org.truffleruby.parser.parser.ParserSupport;
2223

2324
public class ArgumentDescriptorUtils {
2425

@@ -48,7 +49,7 @@ private static RubyArray toArray(RubyLanguage language, RubyContext context, Arg
4849
store = new Object[]{ language.getSymbol(argType.symbolicName) };
4950
} else {
5051
// make sure to normalize parameter names to "_" if they start with "_$"
51-
if (name.startsWith("_$")) {
52+
if (name.startsWith(ParserSupport.UNDERSCORE_PREFIX)) {
5253
name = "_";
5354
}
5455

src/main/java/org/truffleruby/parser/parser/ParserSupport.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ public class ParserSupport {
160160
public static final String FORWARD_ARGS_BLOCK_VAR = Layouts.TEMP_PREFIX + "forward_block";
161161
public static final TruffleString FORWARD_ARGS_BLOCK_VAR_TSTRING = TStringUtils
162162
.usAsciiString(FORWARD_ARGS_BLOCK_VAR);
163+
/** A prefix for duplicated '_' local variables to build unique names */
164+
public static final String UNDERSCORE_PREFIX = "_$";
163165

164166
// Parser states:
165167
protected StaticScope currentScope;
@@ -1587,7 +1589,7 @@ public ArgumentParseNode arg_var(String string) {
15871589
if (name == "_") {
15881590
int count = 0;
15891591
while (current.exists(name) >= 0) {
1590-
name = ("_$" + count++).intern();
1592+
name = (UNDERSCORE_PREFIX + count++).intern(); // e.g. _$1, _$2, etc
15911593
}
15921594
}
15931595

0 commit comments

Comments
 (0)