Skip to content

Commit

Permalink
Rename jruby-truffle-tool to truffleruby-tool, remove it from public …
Browse files Browse the repository at this point in the history
…bin directory
  • Loading branch information
pitr-ch committed Feb 9, 2017
1 parent 6c140b7 commit ec258ae
Show file tree
Hide file tree
Showing 21 changed files with 123 additions and 156 deletions.
9 changes: 0 additions & 9 deletions bin/jruby-truffle-tool

This file was deleted.

131 changes: 0 additions & 131 deletions lib/jruby-truffle-tool/README.md

This file was deleted.

100 changes: 100 additions & 0 deletions lib/truffleruby-tool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# TruffleRuby Tool

`truffleruby-tool` is a small command line utility designed to run and
test Ruby gems and applications on the TruffleRuby runtime. It manages
workarounds and wraps bundler install and execute.

## Setup

There is a `setup` subcommand to install dependencies and prepare workarounds.

- Go to a directory of a gem/application you would like to test.
- Run `truffleruby-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`) and executes other steps defined in the
configuration files or as command line options (see `truffleruby-tool
setup --help` to learn what additional setup steps are available, or see
the default configuration `config.rb`). After it finishes,
the `run` subcommand can be used.

## Running

After the environment is set the gem can be used to execute code, files, or
gem's executables on TruffleRuby in the prepared environment. Examples follows
(options after `--` are interpreted by Ruby, options before `--` are options
for this tool):

- `truffleruby-tool run -- file.rb` - executes file.rb
- `truffleruby-tool run -- -e '1+1'` - evaluates 1+1 expression
- `truffleruby-tool run -- -I test test/a_test_file_test.rb` - runs a test file
- `truffleruby-tool run -S rspec -- spec/a_spec_file_spec.rb` - runs a spec file
using the `rspec` executable of the rspec gem
- `truffleruby-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 (`.truffleruby-tool.yaml`) instead)

See `truffleruby-tool run --help` to see all available options.

## Clean up

To remove all files added during the setup phase, run `truffleruby-tool clean`,
it will only keep the `.truffleruby-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
`.truffleruby-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 `_`.

Configuration values are deep-merged in following order (potentially
overriding): default values, default gem configuration, local configuration,
command-line options. This tool contains default configurations for some gems
in the `config.rb` file, which are used if available. An example of
activesupport's configuration follows:


```yaml
---
:global:
# default ../jruby/bin/ruby won't work since activesupport is one more dir deeper
:jruby_truffle_path: '../../truffleruby/bin/truffleruby'
:graal_path: '../../graalvm-jdk1.8.0/bin/java'
:setup:
:file:
shims.rb: |
require 'minitest'
# mock load_plugins as it loads rubygems
def Minitest.load_plugins
end
bundler.rb: "module Bundler; def self.setup; end; end"
# mock method_source gem
method_source.rb: nil
# do not let bundler to install db gem group
:without:
- db
:run:
:require:
- shims
```
## Using the tool in CI
CI execution is defined in config.rb
then `truffleruby-tool ci activemodel` can be used to run tests of the given gem in CI.

## Example step-by-step

```sh
git clone [email protected]:ruby-concurrency/concurrent-ruby.git
cd concurrent-ruby
git checkout v0.9.1 # latest release
rbenv shell jruby-local # use your compiled JRuby
truffleruby-tool setup
truffleruby-tool run -S rspec -- spec --format progress # run all tests
# you should see only a few errors
```
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def search_up(*names)

EXECUTABLE = File.basename($PROGRAM_NAME)
BRANDING = EXECUTABLE.include?('jruby') ? 'JRuby+Truffle' : 'RubyTruffle'
LOCAL_CONFIG_FILE = '.jruby-truffle-tool.yaml'
LOCAL_CONFIG_FILE = '.truffleruby-tool.yaml'
ROOT = Pathname(__FILE__).dirname.parent.expand_path
TRUFFLERUBY_PATH = ROOT.join('../..').expand_path
TRUFFLERUBY_BIN = TRUFFLERUBY_PATH.join('bin', 'truffleruby')
Expand Down Expand Up @@ -268,7 +268,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-tool_bundle'],
truffle_bundle_path: ['--truffle-bundle-path NAME', 'Bundle path', STORE_NEW_VALUE, '.truffleruby-tool_bundle'],
graal_path: ['--graal-path PATH', 'Path to Graal', STORE_NEW_VALUE, (TRUFFLERUBY_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)',
Expand Down Expand Up @@ -688,7 +688,7 @@ def subcommand_run(rest)
{ 'GEM_HOME' => @options[:run][:offline_gem_path].to_s,
'GEM_PATH' => @options[:run][:offline_gem_path].to_s } :
{}).
merge({'NO_FORK' => 'true'})
merge({ 'NO_FORK' => 'true' })

env.each { |k, v| env[k] = v.to_s }

Expand Down Expand Up @@ -869,8 +869,8 @@ def jruby_path
TRUFFLERUBY_PATH
end

def jruby_truffle_path
jruby_path.join 'bin', 'jruby-truffle-tool'
def truffle_tool_path
jruby_path.join 'lib', 'truffleruby-tool', 'bin', 'truffleruby-tool'
end

def option(key)
Expand Down
3 changes: 2 additions & 1 deletion test/truffle/ecosystem/actionpack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
set -e
set -x

bin/jruby-truffle-tool --dir ../jruby-truffle-gem-test-pack/gem-testing ci --offline actionpack
bin/truffleruby lib/truffleruby-tool/bin/truffleruby-tool \
--dir ../jruby-truffle-gem-test-pack/gem-testing ci --offline actionpack
3 changes: 2 additions & 1 deletion test/truffle/ecosystem/actionview.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
set -e
set -x

bin/jruby-truffle-tool --dir ../jruby-truffle-gem-test-pack/gem-testing ci --offline actionview
bin/truffleruby lib/truffleruby-tool/bin/truffleruby-tool \
--dir ../jruby-truffle-gem-test-pack/gem-testing ci --offline actionview
3 changes: 2 additions & 1 deletion test/truffle/ecosystem/activemodel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
set -e
set -x

bin/jruby-truffle-tool --dir ../jruby-truffle-gem-test-pack/gem-testing ci --offline activemodel
bin/truffleruby lib/truffleruby-tool/bin/truffleruby-tool \
--dir ../jruby-truffle-gem-test-pack/gem-testing ci --offline activemodel
3 changes: 2 additions & 1 deletion test/truffle/ecosystem/activesupport.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
set -e
set -x

bin/jruby-truffle-tool --dir ../jruby-truffle-gem-test-pack/gem-testing ci --offline activesupport
bin/truffleruby lib/truffleruby-tool/bin/truffleruby-tool \
--dir ../jruby-truffle-gem-test-pack/gem-testing ci --offline activesupport
3 changes: 2 additions & 1 deletion test/truffle/ecosystem/algebrick.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
set -e
set -x

bin/jruby-truffle-tool --dir ../jruby-truffle-gem-test-pack/gem-testing ci --offline algebrick
bin/truffleruby lib/truffleruby-tool/bin/truffleruby-tool \
--dir ../jruby-truffle-gem-test-pack/gem-testing ci --offline algebrick
9 changes: 5 additions & 4 deletions test/truffle/ecosystem/rails-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ set -e
set -x

truffle_ruby=$(pwd)
JTR=${truffle_ruby}/bin/jruby-truffle-tool
JTR="${truffle_ruby}/bin/truffleruby ${truffle_ruby}/lib/truffleruby-tool/bin/truffleruby-tool"
rails_app="${truffle_ruby}/../jruby-truffle-gem-test-pack/gem-testing/rails-app"

cd ${truffle_ruby}/../jruby-truffle-gem-test-pack/gem-testing/rails-app
cd "${rails_app}"

if [ -n "$CI" -a -z "$HAS_REDIS" ]
then
Expand All @@ -21,9 +22,9 @@ else
fi

${JTR} setup --offline
${JTR} run --offline -- -S bundle exec ./bin/rails server &
${JTR} run --offline -- -S bundle exec bin/rails server &
serverpid=$!
url=http://localhost:3000
url="http://localhost:3000"

set +x
while ! curl -s "$url/people.json";
Expand Down
3 changes: 2 additions & 1 deletion test/truffle/ecosystem/railties.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
set -e
set -x

bin/jruby-truffle-tool --dir ../jruby-truffle-gem-test-pack/gem-testing ci --offline railties
bin/truffleruby lib/truffleruby-tool/bin/truffleruby-tool \
--dir ../jruby-truffle-gem-test-pack/gem-testing ci --offline railties
2 changes: 1 addition & 1 deletion test/truffle/gem-test-pack-checkout-revision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
set -e
set -x

revision=c5d7d7606459963de4b71b4c31134c3d4eb4314b
revision=a46c9157cf7a016e5b488587438e60f9cd0dd791

git -C ../jruby-truffle-gem-test-pack checkout ${revision}

0 comments on commit ec258ae

Please sign in to comment.