Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build on JRuby again #1383

Merged
merged 14 commits into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ jobs:
- build
- test

build-jruby-9_2:
docker:
- image: circleci/jruby:9.2.8.0

working_directory: ~/repo
steps:
- build
- test

build-ruby-latest:
docker:
- image: circleci/ruby:latest
Expand Down Expand Up @@ -162,6 +171,7 @@ workflows:
- build-ruby-2_5
- build-ruby-2_6
- build-ruby-latest
- build-jruby-9_2
- build_monorepo
- validate-cck:
requires:
Expand Down
7 changes: 1 addition & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,5 @@ elsif !ENV['CUCUMBER_USE_RELEASED_GEMS']
end

gem 'cucumber-expressions', path: ENV['CUCUMBER_EXPRESSIONS_RUBY'] if ENV['CUCUMBER_EXPRESSIONS_RUBY']

gem 'gherkin', path: ENV['GHERKIN_RUBY'] if ENV['GHERKIN_RUBY']

gem 'cucumber-messages', path: ENV['CUCUMBER_MESSAGES_RUBY'] if ENV['CUCUMBER_MESSAGES_RUBY']

# Use an older protobuf on JRuby
gem 'google-protobuf', '~> 3.2.0.2' if RUBY_PLATFORM == 'java'
gem 'gherkin', path: ENV['GHERKIN_RUBY'] if ENV['GHERKIN_RUBY']
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ your team.

Where to get more info:

* The main website: https://cucumber.io/
* The main website: https://cucumber.io/
* Documentation: https://cucumber.io/docs
* Ruby API Documentation: http://www.rubydoc.info/github/cucumber/cucumber-ruby/
* Support forum: https://groups.google.com/group/cukes
Expand All @@ -28,7 +28,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for info on contributing to Cucumber.
* Ruby 2.5
* Ruby 2.4
* Ruby 2.3
* JRuby 9.1
* JRuby 9.2 (with [some limitations](https://github.com/cucumber/cucumber-ruby/blob/master/docs/jruby-limitations.md))

## Code of Conduct

Expand Down
40 changes: 40 additions & 0 deletions docs/jruby-limitations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Cucumber and JRuby limitations

`cucumber` can be executed on `JRuby` (tested with `9.2`), although some of the features
are not available on this platform.

## Defining steps with native languages

There are currently three languages (Russian, Ukrainian and Uzbek) for which the step definition
can not be written in native language.
That means, for example, that you can not write the following code:

```ruby
Допустим('я ввожу число {int}') do |число|
calc.push число
end
```

Instead, you have to write:
```ruby
Given('я ввожу число {int}') do |number|
calc.push number
end
```

Of course, you can still write your feature files in a native language, for example, the following
feature file can be executed on JRuby:

```gherkin
# language: ru
Функционал: Сложение чисел
Чтобы не складывать в уме
Все, у кого с этим туго
Хотят автоматическое сложение целых чисел

Сценарий: Сложение двух целых чисел
Допустим я ввожу число 50
И затем ввожу число 70
Если я нажимаю "+"
То результатом должно быть число 120
```
42 changes: 29 additions & 13 deletions examples/i18n/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,45 @@ task :cucumber do
Dir["#{dir}/*"].sort.each do |f|
next unless File.directory?(f)
lang = f[dir.length + 1..-1]
if examples_working?(lang)
Dir.chdir(f) do
puts "DIR: #{f}"
rake('cucumber')
end
else
STDERR.puts %{
!!!!!
!!!!!
!!!!! SKIPPING #{lang} (The examples are out of date - please help update them)
!!!!!
!!!!!
}
message = examples_disabled?(lang)
unless message.nil?
STDERR.puts(message)
next
end

Dir.chdir(f) do
puts "DIR: #{f}"
rake('cucumber')
end
end
end

task default: :cucumber

def examples_disabled?(lang)
return make_warning("SKIPPING #{lang} (The examples are out of date - please help update them)") unless examples_working?(lang)
return make_warning("SKIPPING #{lang}: examples have been disabled for JRuby.") if jruby_disabled_examples?(lang)
end

def jruby_disabled_examples?(lang)
return unless RUBY_PLATFORM == 'java'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rubocop will flag this. Linespace after guard clause.

%w[ru uk uz].include?(lang)
end

def examples_working?(lang)
!%w[ar].index(lang)
end

def make_warning(msg)
%(
!!!!!
!!!!!
!!!!! #{msg}
!!!!!
!!!!!
)
end

def rake(args)
ruby($PROGRAM_NAME, args)
end
2 changes: 1 addition & 1 deletion features/docs/defining_steps/nested_steps.feature
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Feature: Nested Steps
Liouville
"""

@spawn @todo-windows
@spawn @todo-windows @todo-jruby @wip-jruby
Scenario: Backtrace doesn't skip nested steps
Given a step definition that looks like this:
"""ruby
Expand Down
3 changes: 2 additions & 1 deletion gem_tasks/examples.rake
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# frozen_string_literal: true

desc 'Run all exmples'
desc 'Run all examples'
task :examples do
Dir['examples/*'].each do |example_dir|
next if !File.directory?(example_dir) || %w[examples/tcl].index(example_dir)

puts "Running #{example_dir}"
Dir.chdir(example_dir) do
raise "No Rakefile in #{Dir.pwd}" unless File.file?('Rakefile')
Expand Down
4 changes: 2 additions & 2 deletions spec/cucumber/formatter/backtrace_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ module Formatter
_anything__test/unit__anything_
_anything__Xgem/ruby__anything_
_anything__.rbenv/versions/2.3/bin/bundle__anything_]
trace << "_anything__#{RbConfig::CONFIG['rubyarchdir']}__anything_"
trace << "_anything__#{RbConfig::CONFIG['rubylibdir']}__anything_"
trace << "_anything__#{RbConfig::CONFIG['rubyarchdir']}__anything_" if RbConfig::CONFIG['rubyarchdir']
trace << "_anything__#{RbConfig::CONFIG['rubylibdir']}__anything_" if RbConfig::CONFIG['rubylibdir']

@exception = Exception.new
@exception.set_backtrace(trace)
Expand Down