Skip to content

Commit

Permalink
brats: fix jruby 9.4 tests (#605)
Browse files Browse the repository at this point in the history
- Turns out webrick is not part of the standard library from Ruby 3
onwards. So explicitly install it.
(https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/)
  • Loading branch information
arjun024 authored Dec 2, 2022
1 parent 4029706 commit d8a7697
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions fixtures/brats_jruby/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ gem 'nokogiri'
gem 'sinatra'
gem 'eventmachine'
gem 'bcrypt'
gem 'webrick'

gem 'jdbc-mysql'
gem 'jdbc-postgres'
30 changes: 17 additions & 13 deletions src/ruby/brats/brats_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,22 @@ func CopyBrats(rubyVersion string) *cutlass.App {
return cutlass.New(dir)
}

// jruby 9.4.X.X = ruby 3.1.X
// jruby 9.3.X.X = ruby 2.6.X
// jruby 9.2.X.X = ruby 2.5.X
// jruby 9.1.X.X = ruby 2.3.X
func rubyVersionFromJRubyVersion(jrubyVersion string) (string, error) {
jrubyVersionRegex := regexp.MustCompile(`^(9.\d+).\d+.\d+$`)
version := jrubyVersionRegex.FindStringSubmatch(jrubyVersion)
if version == nil {
return "", fmt.Errorf("JRuby version is not of expected format: expected 9.X.X.X, got %s", jrubyVersion)
}
switch version[1] {
case "9.4":
return "~>3.1", nil
case "9.3":
return "~>2.6", nil
case "9.2":
return "~>2.5", nil
case "9.1":
return "~>2.3", nil
default:
return "", fmt.Errorf("Unknown JRuby -> Ruby version mapping for JRuby version %s", jrubyVersion)
}
Expand Down Expand Up @@ -145,15 +145,16 @@ func createGemfileLockFile(jrubyVersion string, fixtureDir string) error {
racc (~> 1.4)
racc (1.6.0-java)
rack (2.2.4)
rack-protection (2.2.2)
rack-protection (2.2.3)
rack
ruby2_keywords (0.0.5)
sinatra (2.2.2)
sinatra (2.2.3)
mustermann (~> 2.0)
rack (~> 2.2)
rack-protection (= 2.2.2)
rack-protection (= 2.2.3)
tilt (~> 2.0)
tilt (2.0.11)
webrick (1.7.0)
PLATFORMS
universal-java-1.8
Expand All @@ -164,8 +165,9 @@ DEPENDENCIES
jdbc-mysql
jdbc-postgres
nokogiri
sinatra`)
case "9.3":
sinatra
webrick`)
case "9.3", "9.4":
buffer = []byte(`GEM
remote: https://rubygems.org/
specs:
Expand All @@ -175,19 +177,20 @@ DEPENDENCIES
jdbc-postgres (42.2.25)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
nokogiri (1.13.8-java)
nokogiri (1.13.9-java)
racc (~> 1.4)
racc (1.6.0-java)
rack (2.2.4)
rack-protection (3.0.2)
rack-protection (3.0.4)
rack
ruby2_keywords (0.0.5)
sinatra (3.0.2)
sinatra (3.0.4)
mustermann (~> 3.0)
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.0.2)
rack-protection (= 3.0.4)
tilt (~> 2.0)
tilt (2.0.11)
webrick (1.7.0)
PLATFORMS
universal-java-1.8
Expand All @@ -198,7 +201,8 @@ DEPENDENCIES
jdbc-mysql
jdbc-postgres
nokogiri
sinatra`)
sinatra
webrick`)
default:
return fmt.Errorf("Unknown JRuby version %s, could not write Gemfile.lock", jrubyVersion)
}
Expand Down

0 comments on commit d8a7697

Please sign in to comment.