Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5d248b358534
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 640e8545d51c
Choose a head ref
  • 5 commits
  • 16 files changed
  • 1 contributor

Commits on Oct 11, 2016

  1. 1
    Copy the full SHA
    1a72c8f View commit details
  2. 2
    Copy the full SHA
    a006b11 View commit details
  3. Copy the full SHA
    4a05531 View commit details
  4. Copy the full SHA
    9916191 View commit details
  5. Copy the full SHA
    640e854 View commit details
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -84,7 +84,6 @@ tool/nailgun/ng
reference.txt
rubyspec_temp
.polyglot.pom.rb
tool/truffle/jruby_truffle_runner/jruby+truffle_runner-*.gem
test/truffle/cexts/**/Makefile

# binaries
1 change: 0 additions & 1 deletion bin/jruby+truffle.bat

This file was deleted.

2 changes: 1 addition & 1 deletion bin/jruby+truffle → bin/jruby-truffle-tool
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

exec `dirname $BASH_SOURCE[0]`/jruby `dirname $BASH_SOURCE[0]`/../lib/ruby/truffle/jruby+truffle/bin/jruby+truffle "$@"
exec `dirname $BASH_SOURCE[0]`/jruby `dirname $BASH_SOURCE[0]`/../lib/ruby/truffle/jruby-truffle-tool/bin/jruby-truffle-tool "$@"
6 changes: 0 additions & 6 deletions lib/ruby/truffle/jruby+truffle/bin/jruby+truffle

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# JRuby+Truffle Runner

`jruby+truffle` is a small command line utility designed to run and
`jruby-truffle-tool` is a small command line utility designed to run and
test Ruby gems and applications on the JRuby+Truffle Ruby runtime. It uses another
Ruby implementation to prepare the environment and executes files and tests
on JRuby+Truffle. It is a temporary tool to make working with JRuby+Truffle
@@ -11,20 +11,20 @@ easy until it fully supports `rubygems` and `bundler`
The command line tool is part of the JRuby distribution. It is available in
JRuby's `bin` directory.

Just run `jruby+truffle --help` to see the available subcommands.
Just run `jruby-truffle-tool --help` to see the available subcommands.

## Setup

There is a `setup` subcommand to create the environment for JRuby+Truffle.

- Go to a directory of a gem/application you would like to test.
- Run `jruby+truffle setup`
- Run `jruby-truffle-tool setup`

It uses the default configuration (part of the tool) if one is available for a
given gem (it looks for a `gemspec` in current directory). It installs all
required gems (based on the `Gemfile`) to a local bundle directory (default path:
`.jruby+truffle_bundle`), and executes other steps defined in the configuration
files or as command line options (see `jruby+truffle
`.jruby-truffle-tool_bundle`), and executes other steps defined in the configuration
files or as command line options (see `jruby-truffle-tool
setup --help` to learn what additional setup steps are available, or see one of
the default configuration files found in `gem_configurations` directory). After
it finishes, the `run` subcommand can be used.
@@ -36,27 +36,27 @@ gem's executables on JRuby+Truffle in the prepared environment. Examples follows
(options after `--` are interpreted by Ruby, options before `--` are options
for this tool):

- `jruby+truffle run -- file.rb` - executes file.rb
- `jruby+truffle run -- -e '1+1'` - evaluates 1+1 expression
- `jruby+truffle run -- -I test test/a_test_file_test.rb` - runs a test file
- `jruby+truffle run -S rspec -- spec/a_spec_file_spec.rb` - runs a spec file
- `jruby-truffle-tool run -- file.rb` - executes file.rb
- `jruby-truffle-tool run -- -e '1+1'` - evaluates 1+1 expression
- `jruby-truffle-tool run -- -I test test/a_test_file_test.rb` - runs a test file
- `jruby-truffle-tool run -S rspec -- spec/a_spec_file_spec.rb` - runs a spec file
using the `rspec` executable of the rspec gem
- `jruby+truffle run --require mocks -- file.rb` - executes file.rb, but
- `jruby-truffle-tool run --require mocks -- file.rb` - executes file.rb, but
requires mocks first. (mocks can be made to load always by putting the
option to configuration file (`.jruby+truffle.yaml`) instead)
option to configuration file (`.jruby-truffle-tool.yaml`) instead)

See `jruby+truffle run --help` to see all available options.
See `jruby-truffle-tool run --help` to see all available options.

## Clean up

To remove all files added during the setup phase, run `jruby+truffle clean`,
it will only keep the `.jruby+truffle.yaml` configuration file for future re-setup.
To remove all files added during the setup phase, run `jruby-truffle-tool clean`,
it will only keep the `.jruby-truffle-tool.yaml` configuration file for future re-setup.

## Pre-configuration

Options which are always required or are part of the setup step can
pre-configured in the default configuration (included in the tool) or in the local
`.jruby+truffle.yaml` configuration file to avoid repeating options on the command
`.jruby-truffle-tool.yaml` configuration file to avoid repeating options on the command
line. The configuration file has a 2-level deep tree structure. The first level is
the name of the command (or `:global`) and the second level is the name of the option
which is same as its long variant with `-` replaced by `_`.
@@ -103,11 +103,11 @@ Assuming there are stored commands for a given gem like below:
- :test
:setup:
- "git clone git@github.com:lucasocon/openweather.git"
- "jruby+truffle --dir openweather setup"
:test: "jruby+truffle --dir openweather run --require-pattern 'test/*_test.rb' -I test -- -e nil"
- "jruby-truffle-tool --dir openweather setup"
:test: "jruby-truffle-tool --dir openweather run --require-pattern 'test/*_test.rb' -I test -- -e nil"
```
then `jruby+truffle --config openweather stored ci` can be used to run tests of the given gem in CI.
then `jruby-truffle-tool --config openweather stored ci` can be used to run tests of the given gem in CI.

## Example step-by-step

@@ -125,7 +125,7 @@ git clone git@github.com:ruby-concurrency/concurrent-ruby.git
cd concurrent-ruby
git checkout v0.9.1 # latest release
rbenv shell jruby-local # use your compiled JRuby
jruby+truffle setup
jruby+truffle run -S rspec -- spec --format progress # run all tests
jruby-truffle-tool setup
jruby-truffle-tool run -S rspec -- spec --format progress # run all tests
# you should see only a few errors
```
6 changes: 6 additions & 0 deletions lib/ruby/truffle/jruby-truffle-tool/bin/jruby-truffle-tool
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby

require_relative '../lib/truffle/tool.rb'

runner = Truffle::Tool.new ARGV
exit runner.run
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'pp'
require 'yaml'

include Truffle::Runner::ConfigUtils
include Truffle::Runner::OptionBlocks
include Truffle::Tool::ConfigUtils
include Truffle::Tool::OptionBlocks

stubs = {
activesupport_isolation: dedent(<<-RUBY),
@@ -178,7 +178,7 @@ def exclusions_for(name)
{ setup: { file: { 'excluded-tests.rb' => format(dedent(<<-RUBY), exclusion_file(name)) } } }
failures = %s
require 'truffle/exclude_rspec_examples'
Truffle.exclude_rspec_examples failures
Truffle::Tool.exclude_rspec_examples failures
RUBY
end

@@ -190,32 +190,32 @@ def exclusions_for(name)
run: { environment: { 'N' => 1 },
require: %w(rubygems date bigdecimal pathname openssl-stubs) }

Truffle::Runner.add_config :activesupport,
deep_merge(
rails_common,
stubs.fetch(:activesupport_isolation),
replacements.fetch(:method_source))

Truffle::Runner.add_config :activemodel,
deep_merge(
rails_common,
stubs.fetch(:activesupport_isolation),
stubs.fetch(:bcrypt))

Truffle::Runner.add_config :actionpack,
deep_merge(
rails_common,
stubs.fetch(:html_sanitizer),
exclusions_for(:actionpack))

Truffle::Runner.add_config :railties,
deep_merge(rails_common,
stubs.fetch(:activesupport_isolation),
exclusions_for(:railties),
run: { require: %w[bundler.rb] })

Truffle::Runner.add_config :'concurrent-ruby',
setup: { file: { "stub-processor_number.rb" => dedent(<<-RUBY) } },
Truffle::Tool.add_config :activesupport,
deep_merge(
rails_common,
stubs.fetch(:activesupport_isolation),
replacements.fetch(:method_source))

Truffle::Tool.add_config :activemodel,
deep_merge(
rails_common,
stubs.fetch(:activesupport_isolation),
stubs.fetch(:bcrypt))

Truffle::Tool.add_config :actionpack,
deep_merge(
rails_common,
stubs.fetch(:html_sanitizer),
exclusions_for(:actionpack))

Truffle::Tool.add_config :railties,
deep_merge(rails_common,
stubs.fetch(:activesupport_isolation),
exclusions_for(:railties),
run: { require: %w[bundler.rb] })

Truffle::Tool.add_config :'concurrent-ruby',
setup: { file: { "stub-processor_number.rb" => dedent(<<-RUBY) } },
# stub methods calling #system
require 'concurrent'
module Concurrent
@@ -230,20 +230,20 @@ def compute_physical_processor_count
end
end
end
RUBY
run: { require: %w(stub-processor_number) }
RUBY
run: { require: %w(stub-processor_number) }

Truffle::Runner.add_config :monkey_patch,
replacements.fetch(:bundler)
Truffle::Tool.add_config :monkey_patch,
replacements.fetch(:bundler)

Truffle::Runner.add_config :openweather,
replacements.fetch(:'bundler/gem_tasks')
Truffle::Tool.add_config :openweather,
replacements.fetch(:'bundler/gem_tasks')

Truffle::Runner.add_config :psd,
replacements.fetch(:nokogiri)
Truffle::Tool.add_config :psd,
replacements.fetch(:nokogiri)


class Truffle::Runner::CIEnvironment
class Truffle::Tool::CIEnvironment
def rails_ci(has_exclusions: false, skip_test_files: [])
options = {}
options[:debug] = ['-d', '--[no-]debug', 'Run tests with remote debugging enabled.', STORE_NEW_VALUE, false]
@@ -263,22 +263,22 @@ def rails_ci(has_exclusions: false, skip_test_files: [])
end
end

Truffle::Runner.add_ci_definition :actionpack do
Truffle::Tool.add_ci_definition :actionpack do
subdir 'actionpack'
rails_ci has_exclusions: true
end

Truffle::Runner.add_ci_definition :activemodel do
Truffle::Tool.add_ci_definition :activemodel do
subdir 'activemodel'
rails_ci
end

Truffle::Runner.add_ci_definition :activesupport do
Truffle::Tool.add_ci_definition :activesupport do
subdir 'activesupport'
rails_ci
end

Truffle::Runner.add_ci_definition :railties do
Truffle::Tool.add_ci_definition :railties do
subdir 'railties'
rails_ci has_exclusions: true,
skip_test_files: %w[
@@ -328,7 +328,7 @@ def rails_ci(has_exclusions: false, skip_test_files: [])
test/commands/console_test]
end

Truffle::Runner.add_ci_definition :algebrick do
Truffle::Tool.add_ci_definition :algebrick do

has_to_succeed setup

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Truffle
module Truffle::Tool

def self.exclude_rspec_examples(exclusions)
exclusions.each do |mod_name, tests|
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ def pretty_print(q)
end

module Truffle
class Runner
class Tool
module CmdUtils
def execute_cmd(cmd, dir: nil, raise: true, print: false)
result = nil
@@ -170,7 +170,7 @@ def dedent(string)

module Logging
def log(message)
puts 'jtr: ' + message
puts 'jtt: ' + message
end
end

@@ -182,7 +182,7 @@ def log(message)

EXECUTABLE = File.basename($PROGRAM_NAME)
BRANDING = EXECUTABLE.include?('jruby') ? 'JRuby+Truffle' : 'RubyTruffle'
LOCAL_CONFIG_FILE = '.jruby+truffle.yaml'
LOCAL_CONFIG_FILE = '.jruby-truffle-tool.yaml'
ROOT = Pathname(__FILE__).dirname.parent.parent.expand_path
JRUBY_PATH = ROOT.join('../../../..').expand_path
JRUBY_BIN = JRUBY_PATH.join('bin', 'jruby')
@@ -229,7 +229,7 @@ module OptionBlocks
debug_port: ['--debug-port PORT', 'Debug port', STORE_NEW_VALUE, '51819'],
debug_option: ['--debug-option OPTION', 'Debug JVM option', STORE_NEW_VALUE,
'-J-agentlib:jdwp=transport=dt_socket,server=y,address=%d,suspend=y'],
truffle_bundle_path: ['--truffle-bundle-path NAME', 'Bundle path', STORE_NEW_VALUE, '.jruby+truffle_bundle'],
truffle_bundle_path: ['--truffle-bundle-path NAME', 'Bundle path', STORE_NEW_VALUE, '.jruby-truffle-tool_bundle'],
graal_path: ['--graal-path PATH', 'Path to Graal', STORE_NEW_VALUE, (JRUBY_PATH + '../GraalVM-0.10/jre/bin/javao').to_s],
mock_load_path: ['--mock-load-path PATH',
'Path of mocks & monkey-patches (prepended in $:, relative to --truffle_bundle_path)',
@@ -450,7 +450,7 @@ def build_option_parser(parser_options, options_hash)

def load_gem_configuration
if @gem_name
if (hash = Runner.config_for(@gem_name))
if (hash = Tool.config_for(@gem_name))
apply_hash_to_configuration hash
log "loading configuration for #{@gem_name}"
log "configuration is:\n#{hash.pretty_inspect}" if verbose?
@@ -802,7 +802,7 @@ def initialize(working_dir, gem_name, runner, rest, definition: nil)
end

def do_definition(name)
definition = Runner.ci_for name.to_sym
definition = Tool.ci_for name.to_sym
return false unless definition

log "Using CI definition: #{name}"
@@ -820,8 +820,8 @@ def do_definition(name)
def declare_options(parse_options: true, **parser_options)
raise 'cannot declare options after they were parsed' if @option_parsed

Runner.build_option_parser(parser_options, @options, option_parser: @option_parser)
@options.merge! Runner.default_option_values(parser_options)
Tool.build_option_parser(parser_options, @options, option_parser: @option_parser)
@options.merge! Tool.default_option_values(parser_options)

if !@option_parsed && parse_options
@option_parsed = true
@@ -844,7 +844,7 @@ def jruby_path
end

def jruby_truffle_path
jruby_path.join 'bin', 'jruby+truffle'
jruby_path.join 'bin', 'jruby-truffle-tool'
end

def option(key)
@@ -876,9 +876,9 @@ def git_tags

def setup(*options)
Dir.chdir(testing_dir) do
Runner.new(['setup', *options].compact,
dig_deep(@runner.options, global: :verbose, ci: [:offline, :offline_gem_path]).
tap { |h| h.update setup: h.delete(:ci) }).run
Tool.new(['setup', *options].compact,
dig_deep(@runner.options, global: :verbose, ci: [:offline, :offline_gem_path]).
tap { |h| h.update setup: h.delete(:ci) }).run
end
end

@@ -893,8 +893,8 @@ def has_to_succeed(result)
def run(options)
raise ArgumentError unless options.is_a? Array
Dir.chdir(testing_dir) do
Runner.new(['run', *options].compact,
dig_deep(@runner.options, global: :verbose)).run
Tool.new(['run', *options].compact,
dig_deep(@runner.options, global: :verbose)).run
end
end

3 changes: 2 additions & 1 deletion test/truffle/ecosystem/gem-testing.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash

set -e
set -x

bin/jruby+truffle --dir ../jruby-truffle-gem-test-pack/gem-testing ci --offline --batch test/truffle/ecosystem/batch.yaml
bin/jruby-truffle-tool --dir ../jruby-truffle-gem-test-pack/gem-testing ci --offline --batch test/truffle/ecosystem/batch.yaml
9 changes: 4 additions & 5 deletions test/truffle/ecosystem/rails-app.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env bash

set -e
set -x

cd ../jruby-truffle-gem-test-pack/gem-testing/rails-app

JRUBY_BIN=../../../jruby/bin
JRUBY=$JRUBY_BIN/jruby
JTR=$JRUBY_BIN/jruby+truffle
JTR=$JRUBY_BIN/jruby-truffle-tool

if [ -n "$CI" -a -z "$HAS_REDIS" ]
then
@@ -27,15 +28,16 @@ else
serverpid=$!
url=http://localhost:3000

set +x
while ! curl -s "$url/people.json";
do
echo -n .
sleep 1
done
set -x

echo Server is up

set -x
curl -s -X "DELETE" "$url/people/destroy_all.json"
test "$(curl -s "$url/people.json")" = '[]'
curl -s --data 'name=Anybody&email=ab@example.com' "$url/people.json"
@@ -45,7 +47,4 @@ else
kill %1
kill $(cat tmp/pids/server.pid)

set +x
set +e

fi
2 changes: 1 addition & 1 deletion test/truffle/gem-test-pack-checkout-revision.sh
Original file line number Diff line number Diff line change
@@ -3,6 +3,6 @@
set -e
set -x

revision=8a041d63982822462681305ff634a40429f7cd58
revision=05b5d105d2ae58fb32a9d0a77550d176a0489991

git -C ../jruby-truffle-gem-test-pack checkout ${revision}
5 changes: 2 additions & 3 deletions tool/jt.rb
Original file line number Diff line number Diff line change
@@ -458,10 +458,9 @@ def help
jt test spec/ruby/language/while_spec.rb run specs in this file
jt test compiler run compiler tests (uses the same logic as --graal to find Graal)
jt test integration runs all integration tests
jt test integration TESTS runs the given integration tests
jt test integration [TESTS] runs the given integration tests
jt test gems tests using gems
jt test ecosystem [--offline] tests using the wider ecosystem such as bundler, Rails, etc
(when --offline it will not use rubygems.org)
jt test ecosystem [TESTS] tests using the wider ecosystem such as bundler, Rails, etc
jt test cexts [--no-libxml --no-openssl --no-argon2] run C extension tests
(implies --graal, where Graal needs to include Sulong, set SULONG_HOME to a built checkout of Sulong, and set GEM_HOME)
jt test report :language build a report on language specs
17 changes: 13 additions & 4 deletions truffle/src/main/java/org/jruby/truffle/parser/BodyTranslator.java
Original file line number Diff line number Diff line change
@@ -2546,8 +2546,9 @@ public RubyNode visitOpAsgnAndNode(OpAsgnAndParseNode node) {
public RubyNode visitOpAsgnNode(OpAsgnParseNode node) {
final ISourcePosition pos = node.getPosition();

if (node.getOperatorName().equals("||")) {
// Why does this ||= come through as a visitOpAsgnNode and not a visitOpAsgnOrNode?
final boolean isOrOperator = node.getOperatorName().equals("||");
if (isOrOperator || node.getOperatorName().equals("&&")) {
// Why does this ||= or &&= come through as a visitOpAsgnNode and not a visitOpAsgnOrNode?

final String temp = environment.allocateLocalTemp("opassign");
final ParseNode writeReceiverToTemp = new LocalAsgnParseNode(pos, temp, 0, node.getReceiverNode());
@@ -2563,8 +2564,16 @@ public RubyNode visitOpAsgnNode(OpAsgnParseNode node) {
RubyNode lhs = readMethod.accept(this);
RubyNode rhs = writeMethod.accept(this);

final RubyNode ret = new DefinedWrapperNode(context, fullSourceSection, context.getCoreStrings().ASSIGNMENT,
sequence(context, source, sourceSection, Arrays.asList(writeReceiverToTemp.accept(this), new OrNode(lhs, rhs))));
final RubyNode controlNode = isOrOperator ? new OrNode(lhs, rhs) : new AndNode(lhs, rhs);
final RubyNode ret = new DefinedWrapperNode(
context,
fullSourceSection,
context.getCoreStrings().ASSIGNMENT,
sequence(
context,
source,
sourceSection,
Arrays.asList(writeReceiverToTemp.accept(this), controlNode)));

return addNewlineIfNeeded(node, ret);
}