rake-compiler-dock 1.1.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/workflows/ci.yml +240 -0
  4. data/.gitignore +11 -1
  5. data/Dockerfile.jruby +6 -5
  6. data/Dockerfile.mri.erb +91 -45
  7. data/History.md +34 -1
  8. data/README.md +92 -36
  9. data/Rakefile +39 -12
  10. data/build/math_h.patch +189 -0
  11. data/build/parallel_docker_build.rb +7 -3
  12. data/build/patches/{ruby-2.5.8 → ruby-2.5.9}/no_sendfile.patch +0 -0
  13. data/build/patches/{ruby-3.0.0 → ruby-3.1.0}/no_sendfile.patch +0 -0
  14. data/build/patches2/{rake-compiler-1.1.1 → rake-compiler-1.1.6}/0004-Enable-build-of-static-libruby.patch +3 -4
  15. data/build/rcd-env.sh +6 -0
  16. data/build/runas +1 -9
  17. data/lib/rake_compiler_dock/starter.rb +3 -2
  18. data/lib/rake_compiler_dock/version.rb +2 -2
  19. data/mingw64-ucrt/Dockerfile +62 -0
  20. data/mingw64-ucrt/binutils-mingw-w64-ignore-check-errors.patch +13 -0
  21. data/mingw64-ucrt/gcc-mingw-w64-only-c-c++.patch +13 -0
  22. data/mingw64-ucrt/mingw-w64-enable-ucrt.patch +22 -0
  23. data/rake-compiler-dock.gemspec +2 -2
  24. data/test/env/Dockerfile.alpine +17 -0
  25. data/test/env/Dockerfile.centos +22 -0
  26. data/test/env/Dockerfile.debian +24 -0
  27. data/test/rcd_test/Gemfile +11 -0
  28. data/test/rcd_test/Rakefile +76 -0
  29. data/test/rcd_test/ext/java/RcdTestExtService.java +19 -0
  30. data/test/rcd_test/ext/java/RubyRcdTest.java +16 -0
  31. data/test/rcd_test/ext/mri/extconf.rb +29 -0
  32. data/test/rcd_test/ext/mri/rcd_test_ext.c +51 -0
  33. data/test/rcd_test/ext/mri/rcd_test_ext.h +6 -0
  34. data/test/rcd_test/lib/rcd_test.rb +6 -0
  35. data/test/rcd_test/rcd_test.gemspec +27 -0
  36. data/test/rcd_test/test/test_basic.rb +31 -0
  37. data/test/test_environment_variables.rb +56 -31
  38. data/test/test_parallel_docker_build.rb +19 -6
  39. data.tar.gz.sig +0 -0
  40. metadata +75 -37
  41. metadata.gz.sig +2 -2
  42. data/build/patches2/hoe-3.20.0/0001-Load-encrypted-private-key-using-ENV-GEM_PRIVATE_KEY.patch +0 -32
  43. data/build/patches2/rake-compiler-1.1.1/0001-Fix-determining-of-ruby-versions-in-rake-native-gem.patch +0 -44
  44. data/build/patches2/rake-compiler-1.1.1/0003-Allow-building-of-cross-rubies-in-parallel.patch +0 -214
  45. data/build/patches2/rake-compiler-1.1.1/0005-Don-t-mask-out-build-env-vars-for-cross-ruby.patch +0 -30
  46. data/build/patches2/rake-compiler-1.1.1/0006-Use-RAKE_EXTENSION_TASK_NO_NATIVE-env-var-as-the-def.patch +0 -26
  47. data/build/patches2/ruby-2.7.0/ruby2_keywords.patch +0 -15
  48. data/build/patches2/ruby-3.0.0/ruby2_keywords.patch +0 -15
@@ -0,0 +1,13 @@
1
+ diff --git a/debian/rules b/debian/rules
2
+ index 4401493..62c8fe4 100755
3
+ --- a/debian/rules
4
+ +++ b/debian/rules
5
+ @@ -91,7 +91,7 @@ override_dh_auto_test-arch:
6
+ unset CFLAGS CPPFLAGS LDFLAGS; \
7
+ env > $(build_dir)/env; \
8
+ for target in $(targets); do \
9
+ - dh_auto_test -B$(build_dir)/$$target; \
10
+ + dh_auto_test -B$(build_dir)/$$target || true; \
11
+ done
12
+
13
+ override_dh_auto_install-arch:
@@ -0,0 +1,13 @@
1
+ diff --git a/debian/rules b/debian/rules
2
+ index 9e7e40c..fa9a8a2 100755
3
+ --- a/debian/rules
4
+ +++ b/debian/rules
5
+ @@ -58,7 +58,7 @@ ifneq ($(filter stage1,$(DEB_BUILD_PROFILES)),)
6
+ INSTALL_TARGET := install-gcc
7
+ else
8
+ # Build the full GCC.
9
+ - languages := c,c++,fortran,objc,obj-c++,ada
10
+ + languages := c,c++
11
+ BUILD_TARGET :=
12
+ INSTALL_TARGET := install install-lto-plugin
13
+ endif
@@ -0,0 +1,22 @@
1
+ diff --git a/debian/rules b/debian/rules
2
+ index 9fb970c..5473839 100755
3
+ --- a/debian/rules
4
+ +++ b/debian/rules
5
+ @@ -94,7 +94,7 @@ build-arch-stamp: $(patsubst %,$(host)~$(host)~tools-%-install-stamp,$(HOST_TOOL
6
+ %~headers-configure-stamp: autoreconf-stamp
7
+ mkdir -p $(call buildfolder,$*~headers) && \
8
+ cd $(call buildfolder,$*~headers) && \
9
+ - $(call sourcefolder,$*~headers)/configure --prefix=/usr/$(call ruletarget,$*~headers) --host=$(call rulehost,$*~headers) --enable-sdk=all --enable-secure-api
10
+ + $(call sourcefolder,$*~headers)/configure --prefix=/usr/$(call ruletarget,$*~headers) --host=$(call rulehost,$*~headers) --enable-sdk=all --with-default-msvcrt=ucrt
11
+ touch $*-headers-configure-stamp
12
+
13
+ # Override CRT configuration to avoid multilib builds
14
+ @@ -108,7 +108,7 @@ target64crt := $(target64)~$(target64)~crt
15
+ $(target64crt)-configure-stamp: $(target64)~$(target64)~headers-install-stamp autoreconf-stamp
16
+ mkdir -p $(call buildfolder,$(target64crt)) && \
17
+ cd $(call buildfolder,$(target64crt)) && \
18
+ - $(call sourcefolder,$(target64crt))/configure --prefix=/usr/$(call ruletarget,$(target64crt)) --host=$(call rulehost,$(target64crt)) --target=$(call ruletarget,$(target64crt)) --disable-lib32 --enable-lib64 CPPFLAGS="$(CPPFLAGS) -I$(top_dir)/debian/tmp/usr/$(call ruletarget,$(target64crt))/include"
19
+ + $(call sourcefolder,$(target64crt))/configure --prefix=/usr/$(call ruletarget,$(target64crt)) --host=$(call rulehost,$(target64crt)) --target=$(call ruletarget,$(target64crt)) --disable-lib32 --enable-lib64 --with-default-msvcrt=ucrt CPPFLAGS="$(CPPFLAGS) -I$(top_dir)/debian/tmp/usr/$(call ruletarget,$(target64crt))/include"
20
+ touch $@
21
+
22
+ build-indep-stamp: $(foreach target,$(targets),$(patsubst %,$(target)~$(target)~%-install-stamp,$(TARGET_PROJECTS))) $(patsubst %,$(target32)~$(target32)~%-install-stamp,$(TARGET32_PROJECTS))
@@ -22,7 +22,7 @@ Use rake-compiler-dock to enter an interactive shell session or add a task to yo
22
22
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
23
  spec.require_paths = ["lib"]
24
24
 
25
- spec.add_development_dependency "bundler", "~> 1.7"
26
- spec.add_development_dependency "rake", "~> 12.0"
25
+ spec.add_development_dependency "bundler", ">= 1.7", "< 3.0"
26
+ spec.add_development_dependency "rake", ">= 12"
27
27
  spec.add_development_dependency "test-unit", "~> 3.0"
28
28
  end
@@ -0,0 +1,17 @@
1
+ ARG from_image
2
+ FROM ${from_image}
3
+
4
+ RUN uname -a
5
+ RUN apk add ruby ruby-etc ruby-rake git
6
+
7
+ RUN ruby --version
8
+ RUN gem env
9
+ RUN gem inst bundler
10
+
11
+ WORKDIR /build
12
+
13
+ CMD ruby -e "puts Gem::Platform.local.to_s" && \
14
+ gem install --local *.gem --verbose --no-document && \
15
+ cd test/rcd_test/ && \
16
+ bundle install && \
17
+ rake test
@@ -0,0 +1,22 @@
1
+ ARG from_image
2
+ FROM ${from_image}
3
+
4
+ RUN uname -a
5
+
6
+ # Change download address of Centos-8 which is EOL
7
+ RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
8
+ RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
9
+
10
+ RUN yum install -y ruby git
11
+
12
+ RUN ruby --version
13
+ RUN gem env
14
+ RUN gem inst bundler
15
+
16
+ WORKDIR /build
17
+
18
+ CMD ruby -e "puts Gem::Platform.local.to_s" && \
19
+ gem install --local *.gem --verbose --no-document && \
20
+ cd test/rcd_test/ && \
21
+ bundle install && \
22
+ rake test
@@ -0,0 +1,24 @@
1
+ ARG from_image
2
+ FROM ${from_image}
3
+
4
+ # To prevent installed tzdata deb package to show interactive dialog.
5
+ ENV DEBIAN_FRONTEND noninteractive
6
+
7
+ RUN uname -a
8
+ RUN apt-get update -qq && \
9
+ apt-get install -yq \
10
+ -o Dpkg::Options::='--force-confnew' \
11
+ ruby \
12
+ git
13
+
14
+ RUN ruby --version
15
+ RUN gem env
16
+ RUN gem inst bundler
17
+
18
+ WORKDIR /build
19
+
20
+ CMD ruby -e "puts Gem::Platform.local.to_s" && \
21
+ gem install --local *.gem --verbose --no-document && \
22
+ cd test/rcd_test/ && \
23
+ bundle install && \
24
+ rake test
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in rcd_test.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+ gem "rake-compiler"
10
+ gem "rake-compiler-dock"
11
+ gem "minitest", "~> 5.0"
@@ -0,0 +1,76 @@
1
+ require "bundler/gem_tasks"
2
+ require "rubygems/package_task"
3
+ require "rake/testtask"
4
+
5
+ rcd_test_spec = Bundler.load_gemspec("rcd_test.gemspec")
6
+
7
+ if RUBY_ENGINE == "jruby"
8
+ require "rake/javaextensiontask"
9
+
10
+ Rake::JavaExtensionTask.new("rcd_test_ext", rcd_test_spec) do |ext|
11
+ ext.ext_dir = 'ext/java'
12
+ ext.lib_dir = 'lib/rcd_test'
13
+ end
14
+ else
15
+ require "rake/extensiontask"
16
+
17
+ exttask = Rake::ExtensionTask.new('rcd_test_ext', rcd_test_spec) do |ext|
18
+ ext.ext_dir = 'ext/mri'
19
+ ext.lib_dir = 'lib/rcd_test'
20
+ ext.cross_compile = true
21
+ ext.cross_platform = %w[x86-mingw32 x64-mingw-ucrt x64-mingw32 x86-linux x86_64-linux aarch64-linux arm-linux x86_64-darwin arm64-darwin]
22
+ end
23
+ end
24
+
25
+ namespace "gem" do
26
+ if exttask
27
+ task 'prepare' do
28
+ require 'rake_compiler_dock'
29
+ require 'io/console'
30
+ sh "bundle package --all"
31
+ sh "mkdir -p tmp/gem"
32
+ sh "cp ~/.gem/gem-*.pem tmp/gem/ || true"
33
+ unless ENV['CI']
34
+ ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = STDIN.getpass("Enter passphrase of gem signature key: ")
35
+ end
36
+ end
37
+
38
+ exttask.cross_platform.each do |plat|
39
+ desc "Build all native binary gems"
40
+ multitask 'native' => plat
41
+
42
+ desc "Build the native gem for #{plat}"
43
+ task plat => 'prepare' do
44
+ config = "-- #{ENV['RCD_TEST_CONFIG']}"
45
+ # Set mountdir of the directory where .git resides, so that git ls-files in the gemspec works
46
+ RakeCompilerDock.sh <<-EOT, platform: plat, mountdir: Dir.pwd + "/../.."
47
+ (cp tmp/gem/gem-*.pem ~/.gem/ || true) &&
48
+ bundle --local &&
49
+ rake native:#{plat} pkg/#{exttask.gem_spec.full_name}-#{plat}.gem #{config}
50
+ EOT
51
+ end
52
+ end
53
+ end
54
+
55
+ desc "Build a jruby gem"
56
+ task "jruby" do
57
+ require 'rake_compiler_dock'
58
+ sh "bundle package --all"
59
+ RakeCompilerDock.sh <<-EOT, rubyvm: "jruby", platform: "jruby", mountdir: Dir.pwd + "/../.."
60
+ mvn archetype:generate -DartifactId=test -DarchetypeVersion=1.4 -DinteractiveMode=false -DgroupId=test -Dpackage=test &&
61
+ bundle --local &&
62
+ bundle exec rake java gem
63
+ EOT
64
+ end
65
+ end
66
+
67
+ Rake::TestTask.new(:test) do |t|
68
+ t.libs << "test"
69
+ t.libs << "lib"
70
+ t.test_files = FileList["test/**/test_*.rb"]
71
+ end
72
+
73
+ task default: [:clobber, :compile, :test]
74
+ task gem: :build
75
+
76
+ CLEAN.add("{ext,lib}/**/*.{o,so}", "pkg", "tmp")
@@ -0,0 +1,19 @@
1
+ package rcd_test;
2
+
3
+ import org.jruby.Ruby;
4
+ import org.jruby.RubyClass;
5
+ import org.jruby.RubyModule;
6
+ import org.jruby.runtime.ObjectAllocator;
7
+ import org.jruby.runtime.builtin.IRubyObject;
8
+ import org.jruby.runtime.load.BasicLibraryService;
9
+
10
+ import java.io.IOException;
11
+
12
+ public class RcdTestExtService implements BasicLibraryService {
13
+ @Override
14
+ public boolean basicLoad(final Ruby ruby) throws IOException {
15
+ RubyModule rb_mRcdTest = ruby.defineModule("RcdTest");
16
+ rb_mRcdTest.defineAnnotatedMethods(RubyRcdTest.class);
17
+ return true;
18
+ }
19
+ }
@@ -0,0 +1,16 @@
1
+ package rcd_test;
2
+
3
+ import org.jruby.Ruby;
4
+ import org.jruby.anno.JRubyMethod;
5
+ import org.jruby.runtime.builtin.IRubyObject;
6
+ import org.jruby.anno.JRubyModule;
7
+ import org.jruby.runtime.ThreadContext;
8
+
9
+ @JRubyModule(name = "RcdTest")
10
+ public class RubyRcdTest {
11
+ @JRubyMethod(name = "do_something", module = true, meta = true)
12
+ public static IRubyObject buildSelfString(ThreadContext context, IRubyObject recv) {
13
+ Ruby runtime = context.getRuntime();
14
+ return runtime.newString("something has been done");
15
+ }
16
+ }
@@ -0,0 +1,29 @@
1
+ if RUBY_ENGINE == "jruby"
2
+ File.open("Makefile", "w") do |mf|
3
+ mf.puts "# Dummy makefile for JRuby"
4
+ mf.puts "all install::\n"
5
+ end
6
+ else
7
+ require "mkmf"
8
+
9
+ include RbConfig
10
+
11
+ puts "-"*70
12
+ puts "CONFIG['arch']: #{CONFIG['arch'].inspect}"
13
+ puts "CONFIG['sitearch']: #{CONFIG['sitearch'].inspect}"
14
+ puts "CONFIG['RUBY_SO_NAME']: #{CONFIG['RUBY_SO_NAME'].inspect}"
15
+ puts "RUBY_PLATFORM: #{RUBY_PLATFORM.inspect}"
16
+ puts "Gem::Platform.local.to_s: #{Gem::Platform.local.to_s.inspect}"
17
+ puts "-"*70
18
+
19
+ have_func('rb_thread_call_without_gvl', 'ruby/thread.h') ||
20
+ raise("rb_thread_call_without_gvl() not found")
21
+
22
+ if arg_config("--link-static", false)
23
+ # https://github.com/rake-compiler/rake-compiler-dock/issues/69
24
+ puts "Linking with '-static' flag"
25
+ $LDFLAGS << ' -static'
26
+ end
27
+
28
+ create_makefile("rcd_test/rcd_test_ext")
29
+ end
@@ -0,0 +1,51 @@
1
+ #include "rcd_test_ext.h"
2
+
3
+ #ifndef __has_builtin
4
+ #define __has_builtin(x) 0
5
+ #endif
6
+
7
+ VALUE rb_mRcdTest;
8
+
9
+ static VALUE
10
+ rcdt_isinf_eh(VALUE self, VALUE rb_float) {
11
+ Check_Type(rb_float, T_FLOAT);
12
+
13
+ return isinf(RFLOAT_VALUE(rb_float)) ? Qtrue : Qfalse;
14
+ }
15
+
16
+ static VALUE
17
+ rcdt_isnan_eh(VALUE self, VALUE rb_float) {
18
+ Check_Type(rb_float, T_FLOAT);
19
+
20
+ return isnan(RFLOAT_VALUE(rb_float)) ? Qtrue : Qfalse;
21
+ }
22
+
23
+ static VALUE
24
+ rcdt_do_something(VALUE self)
25
+ {
26
+ return rb_str_new_cstr("something has been done");
27
+ }
28
+
29
+ static VALUE
30
+ rcdt_darwin_builtin_available_eh(VALUE self)
31
+ {
32
+ #if __has_builtin(__builtin_available)
33
+ // This version must be higher than MACOSX_DEPLOYMENT_TARGET to prevent clang from optimizing it away
34
+ if (__builtin_available(macOS 10.14, *)) {
35
+ return Qtrue;
36
+ }
37
+ return Qfalse;
38
+ #else
39
+ rb_raise(rb_eRuntimeError, "__builtin_available is not defined");
40
+ #endif
41
+ }
42
+
43
+ void
44
+ Init_rcd_test_ext(void)
45
+ {
46
+ rb_mRcdTest = rb_define_module("RcdTest");
47
+ rb_define_singleton_method(rb_mRcdTest, "do_something", rcdt_do_something, 0);
48
+ rb_define_singleton_method(rb_mRcdTest, "darwin_builtin_available?", rcdt_darwin_builtin_available_eh, 0);
49
+ rb_define_singleton_method(rb_mRcdTest, "isinf?", rcdt_isinf_eh, 1);
50
+ rb_define_singleton_method(rb_mRcdTest, "isnan?", rcdt_isnan_eh, 1);
51
+ }
@@ -0,0 +1,6 @@
1
+ #ifndef RCD_TEST_EXT_H
2
+ #define RCD_TEST_EXT_H 1
3
+
4
+ #include "ruby.h"
5
+
6
+ #endif /* RCD_TEST_EXT_H */
@@ -0,0 +1,6 @@
1
+ begin
2
+ RUBY_VERSION =~ /(\d+\.\d+)/
3
+ require "rcd_test/#{$1}/rcd_test_ext"
4
+ rescue LoadError
5
+ require 'rcd_test/rcd_test_ext'
6
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "rcd_test"
5
+ spec.version = "1.0.0"
6
+ spec.authors = ["Lars Kanis"]
7
+ spec.email = ["lars@greiz-reinsdorf.de"]
8
+
9
+ spec.summary = "C extension for testing rake-compiler-dock"
10
+ spec.description = "This gem has no real use other than testing builds of binary gems."
11
+ spec.homepage = "https://github.com/rake-compiler/rake-compiler-dock"
12
+ spec.required_ruby_version = ">= 2.0.0"
13
+ spec.license = "MIT"
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+ spec.extensions = ["ext/mri/extconf.rb"]
24
+
25
+ # Uncomment to register a new dependency of your gem
26
+ # spec.add_dependency "example-gem", "~> 1.0"
27
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "minitest/autorun"
4
+ require "rcd_test"
5
+
6
+ class TestBasic < Minitest::Test
7
+
8
+ def test_do_something
9
+ assert_equal "something has been done", RcdTest.do_something
10
+ end
11
+
12
+ def test_check_darwin_compiler_rt_symbol_resolution
13
+ skip("jruby should not run libc-specific tests") if RUBY_ENGINE == "jruby"
14
+
15
+ if RUBY_PLATFORM.include?("darwin")
16
+ assert(RcdTest.darwin_builtin_available?)
17
+ else
18
+ e = assert_raises(RuntimeError) { RcdTest.darwin_builtin_available? }
19
+ assert_equal("__builtin_available is not defined", e.message)
20
+ end
21
+ end
22
+
23
+ def test_floating_point_classification_macros
24
+ skip("jruby should not run libc-specific tests") if RUBY_ENGINE == "jruby"
25
+ refute(RcdTest.isinf?(42.0))
26
+ assert(RcdTest.isinf?(Float::INFINITY))
27
+ refute(RcdTest.isnan?(42.0))
28
+ assert(RcdTest.isnan?(Float::NAN))
29
+ end
30
+
31
+ end
@@ -6,49 +6,74 @@ begin
6
6
  rescue LoadError
7
7
  end
8
8
 
9
- class TestEnvironmentVariables < Test::Unit::TestCase
10
- @@rcd_env = nil
9
+ class TestEnvironmentVariables
10
+ module Common
11
+ IMAGE_NAME = "larskanis/rake-compiler-dock-mri-x86-mingw32:#{RakeCompilerDock::IMAGE_VERSION}"
11
12
 
12
- def setup
13
- @@rcd_env ||= begin
14
- args = "bash -c 'set'"
15
- idir = File.join(File.dirname(__FILE__), '../lib')
16
- cmd = "#{RbConfig::CONFIG['RUBY_INSTALL_NAME']} -I#{idir.inspect} bin/rake-compiler-dock #{args}"
17
- output = `#{cmd}`
13
+ def rcd_env
14
+ self.class.instance_variable_get("@rcd_env") || begin
15
+ command = "env"
16
+ output = %x(#{invocation(command)})
18
17
 
19
- output.split("\n").inject({}) do |hash, line|
20
- if line =~ /\A(\w+)=(.*)\z/
21
- hash[$1] = $2.chomp
18
+ env = output.split("\n").each_with_object({}) do |line, hash|
19
+ hash[Regexp.last_match(1)] = Regexp.last_match(2).chomp if line =~ /\A(\w+)=(.*)\z/
22
20
  end
23
- hash
21
+
22
+ self.class.instance_variable_set("@rcd_env", env)
24
23
  end
25
24
  end
26
- end
27
25
 
28
- def rcd_env
29
- @@rcd_env
30
- end
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
31
 
32
- def test_IMAGE
33
- assert_equal "larskanis/rake-compiler-dock-mri-x86-mingw32:#{RakeCompilerDock::IMAGE_VERSION}", rcd_env['RCD_IMAGE']
34
- end
32
+ def test_RAKE_EXTENSION_TASK_NO_NATIVE
33
+ assert_equal "true", rcd_env['RAKE_EXTENSION_TASK_NO_NATIVE']
34
+ end
35
35
 
36
- def test_RUBY_CC_VERSION
37
- df = File.read(File.expand_path("../../Dockerfile.mri.erb", __FILE__))
38
- df =~ /^ENV RUBY_CC_VERSION\s+(.*)\s+$/
39
- assert_equal $1, rcd_env['RUBY_CC_VERSION']
40
- end
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
41
40
 
42
- def test_HOST_RUBY_PLATFORM
43
- assert_equal RUBY_PLATFORM, rcd_env['RCD_HOST_RUBY_PLATFORM']
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)
44
+ end
44
45
  end
45
46
 
46
- def test_HOST_RUBY_VERSION
47
- assert_equal RUBY_VERSION, rcd_env['RCD_HOST_RUBY_VERSION']
48
- end
47
+ class UsingWrapper < Test::Unit::TestCase
48
+ include Common
49
+
50
+ def invocation(command)
51
+ idir = File.join(File.dirname(__FILE__), '../lib')
52
+ "#{RbConfig::CONFIG['RUBY_INSTALL_NAME']} -I#{idir.inspect} bin/rake-compiler-dock bash -c '#{command}'"
53
+ end
54
+
55
+ def test_HOST_RUBY_PLATFORM
56
+ assert_equal RUBY_PLATFORM, rcd_env['RCD_HOST_RUBY_PLATFORM']
57
+ end
58
+
59
+ def test_HOST_RUBY_VERSION
60
+ assert_equal RUBY_VERSION, rcd_env['RCD_HOST_RUBY_VERSION']
61
+ end
49
62
 
50
- def test_PWD
51
- assert_equal Dir.pwd, rcd_env['PWD']
63
+ def test_IMAGE
64
+ assert_equal IMAGE_NAME, rcd_env['RCD_IMAGE']
65
+ end
66
+
67
+ def test_PWD
68
+ assert_equal Dir.pwd, rcd_env['PWD']
69
+ end
52
70
  end
53
71
 
72
+ class AsIfContinuousIntegration < Test::Unit::TestCase
73
+ include Common
74
+
75
+ def invocation(command)
76
+ "docker run -it #{IMAGE_NAME} bash -c '#{command}'"
77
+ end
78
+ end
54
79
  end
@@ -1,36 +1,47 @@
1
1
  require 'test/unit'
2
2
  require_relative "../build/parallel_docker_build"
3
+ require "tmpdir"
3
4
 
4
5
  class TestParallelDockerBuild < Test::Unit::TestCase
5
6
  def setup
6
- File.write "File0", <<-EOT
7
+ @tmpdir ||= Dir.mktmpdir
8
+
9
+ Dir.chdir(@tmpdir) do
10
+ File.write "File0", <<-EOT
7
11
  FROM a
8
12
  RUN a
9
13
  RUN d
10
14
  EOT
11
- File.write "File1", <<-EOT
15
+ File.write "File1", <<-EOT
12
16
  FROM a
13
17
  RUN a
14
18
  RUN d
15
19
  RUN f \\
16
20
  g
17
21
  EOT
18
- File.write "File2", <<-EOT
22
+ File.write "File2", <<-EOT
19
23
  FROM a
20
24
  RUN b
21
25
  RUN c
22
26
  RUN d
23
27
  EOT
24
- File.write "File3", <<-EOT
28
+ File.write "File3", <<-EOT
25
29
  FROM a
26
30
  RUN b
27
31
  RUN c
28
32
  RUN d
29
33
  EOT
34
+ end
35
+ end
36
+
37
+ def teardown
38
+ FileUtils.rm_rf @tmpdir
30
39
  end
31
40
 
32
41
  def test_tasks
33
- RakeCompilerDock::ParallelDockerBuild.new(%w[ File0 File1 File2 File3 ], task_prefix: "y")
42
+ Dir.chdir(@tmpdir) do
43
+ RakeCompilerDock::ParallelDockerBuild.new(%w[ File0 File1 File2 File3 ], task_prefix: "y")
44
+ end
34
45
 
35
46
  assert_operator Rake::Task["File0"].prerequisites, :include?, "yFile0File1"
36
47
  assert_operator Rake::Task["File1"].prerequisites, :include?, "yFile1"
@@ -43,7 +54,9 @@ class TestParallelDockerBuild < Test::Unit::TestCase
43
54
  end
44
55
 
45
56
  def test_common_files
46
- RakeCompilerDock::ParallelDockerBuild.new(%w[ File0 File1 File2 File3 ], task_prefix: "y")
57
+ Dir.chdir(@tmpdir) do
58
+ RakeCompilerDock::ParallelDockerBuild.new(%w[ File0 File1 File2 File3 ], task_prefix: "y")
59
+ end
47
60
 
48
61
  assert_equal "FROM a\nRUN a\nRUN d\nRUN f \\\ng\n", read_df("yFile1")
49
62
  assert_equal "FROM a\nRUN a\nRUN d\n", read_df("yFile0File1")
data.tar.gz.sig CHANGED
Binary file