Skip to content

Commit f19a086

Browse files
authored
Merge pull request #93 from rake-compiler/fix-basic-tests
Fix basic image tests and add them to CI
2 parents 722260c + 77f843f commit f19a086

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ jobs:
7474
bundle exec rake clean clobber
7575
bundle exec rake gem:${PLATFORM}
7676
77+
- name: Basic tests on the generated image
78+
env:
79+
TEST_PLATFORM: ${{ matrix.platform }}
80+
run: |
81+
bundle exec rake test
82+
7783
- name: Upload binary gem
7884
uses: actions/upload-artifact@v3
7985
with:

test/test_environment_variables.rb

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88

99
class TestEnvironmentVariables
1010
module Common
11-
IMAGE_NAME = "larskanis/rake-compiler-dock-mri-x86-mingw32:#{RakeCompilerDock::IMAGE_VERSION}"
11+
TEST_PLATFORM = ENV["TEST_PLATFORM"] || "x64-mingw-ucrt"
12+
DOCKERHUB_USER = ENV['DOCKERHUB_USER'] || "larskanis"
13+
14+
IS_JRUBY = TEST_PLATFORM.to_s == "jruby"
15+
platform = IS_JRUBY ? "jruby" : "mri-#{TEST_PLATFORM}"
16+
TEST_IMAGE_NAME = "#{DOCKERHUB_USER}/rake-compiler-dock-#{platform}:#{RakeCompilerDock::IMAGE_VERSION}"
1217

1318
def rcd_env
1419
self.class.instance_variable_get("@rcd_env") || begin
@@ -23,24 +28,26 @@ def rcd_env
2328
end
2429
end
2530

26-
def test_RUBY_CC_VERSION
27-
df = File.read(File.expand_path("../../Dockerfile.mri.erb", __FILE__))
28-
df =~ /^ENV RUBY_CC_VERSION\s+(.*)\s+$/
29-
assert_equal $1, rcd_env['RUBY_CC_VERSION']
30-
end
31+
unless IS_JRUBY
32+
def test_RUBY_CC_VERSION
33+
df = File.read(File.expand_path("../../Dockerfile.mri.erb", __FILE__))
34+
df =~ /^ENV RUBY_CC_VERSION\s+(.*)\s+$/
35+
assert_equal $1, rcd_env['RUBY_CC_VERSION']
36+
end
3137

32-
def test_RAKE_EXTENSION_TASK_NO_NATIVE
33-
assert_equal "true", rcd_env['RAKE_EXTENSION_TASK_NO_NATIVE']
34-
end
38+
def test_RAKE_EXTENSION_TASK_NO_NATIVE
39+
assert_equal "true", rcd_env['RAKE_EXTENSION_TASK_NO_NATIVE']
40+
end
3541

36-
def test_symlink_rake_compiler
37-
cmd = invocation("if test -h $HOME/.rake-compiler ; then echo yes ; else echo no ; fi")
38-
assert_equal("yes", %x(#{cmd}).strip)
39-
end
42+
def test_symlink_rake_compiler
43+
cmd = invocation("if test -h $HOME/.rake-compiler ; then echo yes ; else echo no ; fi")
44+
assert_equal("yes", %x(#{cmd}).strip)
45+
end
4046

41-
def test_gem_directory
42-
cmd = invocation("if test -d $HOME/.gem ; then echo yes ; else echo no ; fi")
43-
assert_equal("yes", %x(#{cmd}).strip)
47+
def test_gem_directory
48+
cmd = invocation("if test -d $HOME/.gem ; then echo yes ; else echo no ; fi")
49+
assert_equal("yes", %x(#{cmd}).strip)
50+
end
4451
end
4552
end
4653

@@ -49,7 +56,7 @@ class UsingWrapper < Test::Unit::TestCase
4956

5057
def invocation(command)
5158
idir = File.join(File.dirname(__FILE__), '../lib')
52-
"#{RbConfig::CONFIG['RUBY_INSTALL_NAME']} -I#{idir.inspect} bin/rake-compiler-dock bash -c '#{command}'"
59+
"RCD_PLATFORM=#{TEST_PLATFORM} RCD_RUBYVM=#{IS_JRUBY ? 'jruby' : 'mri'} #{RbConfig::CONFIG['RUBY_INSTALL_NAME']} -I#{idir.inspect} bin/rake-compiler-dock bash -c '#{command}'"
5360
end
5461

5562
def test_HOST_RUBY_PLATFORM
@@ -61,7 +68,7 @@ def test_HOST_RUBY_VERSION
6168
end
6269

6370
def test_IMAGE
64-
assert_equal IMAGE_NAME, rcd_env['RCD_IMAGE']
71+
assert_equal TEST_IMAGE_NAME, rcd_env['RCD_IMAGE']
6572
end
6673

6774
def test_PWD
@@ -73,7 +80,7 @@ class AsIfContinuousIntegration < Test::Unit::TestCase
7380
include Common
7481

7582
def invocation(command)
76-
"docker run -it #{IMAGE_NAME} bash -c '#{command}'"
83+
"docker run --rm #{TEST_IMAGE_NAME} bash -c '#{command}'"
7784
end
7885
end
7986
end

test/test_parallel_docker_build.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ def test_common_files
6565
end
6666

6767
def read_df(fn)
68-
File.read("tmp/docker/#{fn}").each_line.map(&:lstrip).join
68+
File.read(File.join(@tmpdir, "/tmp/docker", fn)).each_line.map(&:lstrip).join
6969
end
7070
end

0 commit comments

Comments
 (0)