Sha256: 35c0b2e81ac63eb3ae63fc3709c2c00235f7979083018e45a5e83e0fd5bb92d4

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

require 'rake_compiler_dock'
require 'rbconfig'
require 'test/unit'
begin
  require 'test/unit/notify'
rescue LoadError
end

class TestEnvironmentVariables < Test::Unit::TestCase
  @@rcd_env = nil

  def setup
    @@rcd_env ||= begin
      args = "bash -c 'set'"
      idir = File.join(File.dirname(__FILE__), '../lib')
      cmd = "#{RbConfig::CONFIG['RUBY_INSTALL_NAME']} -I#{idir.inspect} bin/rake-compiler-dock #{args}"
      output = `#{cmd}`

      output.split("\n").inject({}) do |hash, line|
        if line =~ /\A(\w+)=(.*)\z/
          hash[$1] = $2.chomp
        end
        hash
      end
    end
  end

  def rcd_env
    @@rcd_env
  end

  def test_IMAGE
    assert_equal "larskanis/rake-compiler-dock-mri-x86-mingw32:#{RakeCompilerDock::IMAGE_VERSION}", rcd_env['RCD_IMAGE']
  end

  def test_RUBY_CC_VERSION
    df = File.read(File.expand_path("../../Dockerfile.mri.erb", __FILE__))
    df =~ /^ENV RUBY_CC_VERSION\s+(.*)\s+$/
    assert_equal $1, rcd_env['RUBY_CC_VERSION']
  end

  def test_HOST_RUBY_PLATFORM
    assert_equal RUBY_PLATFORM, rcd_env['RCD_HOST_RUBY_PLATFORM']
  end

  def test_HOST_RUBY_VERSION
    assert_equal RUBY_VERSION, rcd_env['RCD_HOST_RUBY_VERSION']
  end

  def test_PWD
    assert_equal Dir.pwd, rcd_env['PWD']
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rake-compiler-dock-1.1.0 test/test_environment_variables.rb
rake-compiler-dock-1.0.1 test/test_environment_variables.rb
rake-compiler-dock-1.0.0 test/test_environment_variables.rb