Skip to content

Commit 190ffb0

Browse files
Merge pull request #1383 from cucumber/enable-jruby-ci-again
Build on JRuby again
2 parents d9d023d + 4c83414 commit 190ffb0

File tree

8 files changed

+87
-25
lines changed

8 files changed

+87
-25
lines changed

.circleci/config.yml

+10
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ jobs:
7777
- build
7878
- test
7979

80+
build-jruby-9_2:
81+
docker:
82+
- image: circleci/jruby:9.2.8.0
83+
84+
working_directory: ~/repo
85+
steps:
86+
- build
87+
- test
88+
8089
build-ruby-latest:
8190
docker:
8291
- image: circleci/ruby:latest
@@ -162,6 +171,7 @@ workflows:
162171
- build-ruby-2_5
163172
- build-ruby-2_6
164173
- build-ruby-latest
174+
- build-jruby-9_2
165175
- build_monorepo
166176
- validate-cck:
167177
requires:

Gemfile

+1-6
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,5 @@ elsif !ENV['CUCUMBER_USE_RELEASED_GEMS']
1717
end
1818

1919
gem 'cucumber-expressions', path: ENV['CUCUMBER_EXPRESSIONS_RUBY'] if ENV['CUCUMBER_EXPRESSIONS_RUBY']
20-
21-
gem 'gherkin', path: ENV['GHERKIN_RUBY'] if ENV['GHERKIN_RUBY']
22-
2320
gem 'cucumber-messages', path: ENV['CUCUMBER_MESSAGES_RUBY'] if ENV['CUCUMBER_MESSAGES_RUBY']
24-
25-
# Use an older protobuf on JRuby
26-
gem 'google-protobuf', '~> 3.2.0.2' if RUBY_PLATFORM == 'java'
21+
gem 'gherkin', path: ENV['GHERKIN_RUBY'] if ENV['GHERKIN_RUBY']

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ your team.
1515

1616
Where to get more info:
1717

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

3333
## Code of Conduct
3434

docs/jruby-limitations.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Cucumber and JRuby limitations
2+
3+
`cucumber` can be executed on `JRuby` (tested with `9.2`), although some of the features
4+
are not available on this platform.
5+
6+
## Defining steps with native languages
7+
8+
There are currently three languages (Russian, Ukrainian and Uzbek) for which the step definition
9+
can not be written in native language.
10+
That means, for example, that you can not write the following code:
11+
12+
```ruby
13+
Допустим('я ввожу число {int}') do |число|
14+
calc.push число
15+
end
16+
```
17+
18+
Instead, you have to write:
19+
```ruby
20+
Given('я ввожу число {int}') do |number|
21+
calc.push number
22+
end
23+
```
24+
25+
Of course, you can still write your feature files in a native language, for example, the following
26+
feature file can be executed on JRuby:
27+
28+
```gherkin
29+
# language: ru
30+
Функционал: Сложение чисел
31+
Чтобы не складывать в уме
32+
Все, у кого с этим туго
33+
Хотят автоматическое сложение целых чисел
34+
35+
Сценарий: Сложение двух целых чисел
36+
Допустим я ввожу число 50
37+
И затем ввожу число 70
38+
Если я нажимаю "+"
39+
То результатом должно быть число 120
40+
```

examples/i18n/Rakefile

+29-13
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,45 @@ task :cucumber do
44
Dir["#{dir}/*"].sort.each do |f|
55
next unless File.directory?(f)
66
lang = f[dir.length + 1..-1]
7-
if examples_working?(lang)
8-
Dir.chdir(f) do
9-
puts "DIR: #{f}"
10-
rake('cucumber')
11-
end
12-
else
13-
STDERR.puts %{
14-
!!!!!
15-
!!!!!
16-
!!!!! SKIPPING #{lang} (The examples are out of date - please help update them)
17-
!!!!!
18-
!!!!!
19-
}
7+
message = examples_disabled?(lang)
8+
unless message.nil?
9+
STDERR.puts(message)
10+
next
11+
end
12+
13+
Dir.chdir(f) do
14+
puts "DIR: #{f}"
15+
rake('cucumber')
2016
end
2117
end
2218
end
2319

2420
task default: :cucumber
2521

22+
def examples_disabled?(lang)
23+
return make_warning("SKIPPING #{lang} (The examples are out of date - please help update them)") unless examples_working?(lang)
24+
return make_warning("SKIPPING #{lang}: examples have been disabled for JRuby.") if jruby_disabled_examples?(lang)
25+
end
26+
27+
def jruby_disabled_examples?(lang)
28+
return unless RUBY_PLATFORM == 'java'
29+
%w[ru uk uz].include?(lang)
30+
end
31+
2632
def examples_working?(lang)
2733
!%w[ar].index(lang)
2834
end
2935

36+
def make_warning(msg)
37+
%(
38+
!!!!!
39+
!!!!!
40+
!!!!! #{msg}
41+
!!!!!
42+
!!!!!
43+
)
44+
end
45+
3046
def rake(args)
3147
ruby($PROGRAM_NAME, args)
3248
end

features/docs/defining_steps/nested_steps.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Feature: Nested Steps
107107
Liouville
108108
"""
109109

110-
@spawn @todo-windows
110+
@spawn @todo-windows @todo-jruby @wip-jruby
111111
Scenario: Backtrace doesn't skip nested steps
112112
Given a step definition that looks like this:
113113
"""ruby

gem_tasks/examples.rake

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# frozen_string_literal: true
22

3-
desc 'Run all exmples'
3+
desc 'Run all examples'
44
task :examples do
55
Dir['examples/*'].each do |example_dir|
66
next if !File.directory?(example_dir) || %w[examples/tcl].index(example_dir)
7+
78
puts "Running #{example_dir}"
89
Dir.chdir(example_dir) do
910
raise "No Rakefile in #{Dir.pwd}" unless File.file?('Rakefile')

spec/cucumber/formatter/backtrace_filter_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ module Formatter
1515
_anything__test/unit__anything_
1616
_anything__Xgem/ruby__anything_
1717
_anything__.rbenv/versions/2.3/bin/bundle__anything_]
18-
trace << "_anything__#{RbConfig::CONFIG['rubyarchdir']}__anything_"
19-
trace << "_anything__#{RbConfig::CONFIG['rubylibdir']}__anything_"
18+
trace << "_anything__#{RbConfig::CONFIG['rubyarchdir']}__anything_" if RbConfig::CONFIG['rubyarchdir']
19+
trace << "_anything__#{RbConfig::CONFIG['rubylibdir']}__anything_" if RbConfig::CONFIG['rubylibdir']
2020

2121
@exception = Exception.new
2222
@exception.set_backtrace(trace)

0 commit comments

Comments
 (0)