• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/ruby
2
3# Test that Kokoro is using the expected version of ruby.
4
5require 'test/unit'
6
7class RubyVersionTest < Test::Unit::TestCase
8
9  def test_ruby_version
10    return if RUBY_PLATFORM == "java"
11    if not ENV["KOKORO_RUBY_VERSION"]
12      STDERR.puts("No kokoro ruby version found, skipping check")
13      return
14    end
15
16    actual = RUBY_VERSION
17    expected = ENV["KOKORO_RUBY_VERSION"].delete_prefix("ruby-")
18    assert actual.start_with?(expected), "Version #{actual} found, expecting #{expected}"
19  end
20
21  def test_jruby_version
22    return if RUBY_PLATFORM != "java"
23    if not ENV["KOKORO_RUBY_VERSION"]
24      STDERR.puts("No kokoro ruby version found, skipping check")
25      return
26    end
27
28    expected = ENV["KOKORO_RUBY_VERSION"].delete_prefix("jruby-")
29    actual = JRUBY_VERSION
30    assert actual.start_with?(expected), "Version #{actual} found, expecting #{expected}"
31  end
32
33end
34