diff options
Diffstat (limited to 'test/mkmf')
-rw-r--r-- | test/mkmf/base.rb | 38 | ||||
-rw-r--r-- | test/mkmf/test_find_executable.rb | 16 | ||||
-rw-r--r-- | test/mkmf/test_flags.rb | 35 |
3 files changed, 73 insertions, 16 deletions
diff --git a/test/mkmf/base.rb b/test/mkmf/base.rb index d4cf80376f..a9d3aec338 100644 --- a/test/mkmf/base.rb +++ b/test/mkmf/base.rb @@ -58,15 +58,53 @@ class TestMkmf < Test::Unit::TestCase end def setup + @rbconfig = rbconfig0 = RbConfig::CONFIG + @mkconfig = mkconfig0 = RbConfig::MAKEFILE_CONFIG + rbconfig = { + "hdrdir" => $hdrdir, + "srcdir" => $srcdir, + "topdir" => $topdir, + } + mkconfig = { + "hdrdir" => "$(top_srcdir)/include", + "srcdir" => "$(top_srcdir)/ext/#{$mdir}", + "topdir" => $topdir, + } + rbconfig0.each_pair {|key, val| rbconfig[key] ||= val.dup} + mkconfig0.each_pair {|key, val| mkconfig[key] ||= val.dup} + RbConfig.module_eval { + remove_const(:CONFIG) + const_set(:CONFIG, rbconfig) + remove_const(:MAKEFILE_CONFIG) + const_set(:MAKEFILE_CONFIG, mkconfig) + } + Object.class_eval { + remove_const(:CONFIG) + const_set(:CONFIG, mkconfig) + } @tmpdir = Dir.mktmpdir @curdir = Dir.pwd @mkmfobj = Object.new @stdout = Capture.new Dir.chdir(@tmpdir) @quiet, Logging.quiet = Logging.quiet, true + init_mkmf + $INCFLAGS[0, 0] = "-I. " end def teardown + rbconfig0 = @rbconfig + mkconfig0 = @mkconfig + RbConfig.module_eval { + remove_const(:CONFIG) + const_set(:CONFIG, rbconfig0) + remove_const(:MAKEFILE_CONFIG) + const_set(:MAKEFILE_CONFIG, mkconfig0) + } + Object.class_eval { + remove_const(:CONFIG) + const_set(:CONFIG, mkconfig0) + } Logging.quiet = @quiet Logging.log_close Dir.chdir(@curdir) diff --git a/test/mkmf/test_find_executable.rb b/test/mkmf/test_find_executable.rb index 132330bf7c..5ccec880fd 100644 --- a/test/mkmf/test_find_executable.rb +++ b/test/mkmf/test_find_executable.rb @@ -2,22 +2,6 @@ require_relative 'base' class TestMkmf class TestFindExecutable < TestMkmf - def test_valid_warnflags - val = $extmk - begin - makefile = mkmf do - $extmk = false - self.class::CONFIG['warnflags'] = "-Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=shorten-64-to-32" - self.class::CONFIG['GCC'] = 'yes' - configuration '.' - end - generated_flags = makefile.grep(/warnflags/).first[/^warnflags = .*$/] - assert_equal "warnflags = -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32", generated_flags - ensure - $extmk = val - end - end - def test_find_executable bug2669 = '[ruby-core:27912]' path, ENV["PATH"] = ENV["PATH"], path diff --git a/test/mkmf/test_flags.rb b/test/mkmf/test_flags.rb new file mode 100644 index 0000000000..3bb278071a --- /dev/null +++ b/test/mkmf/test_flags.rb @@ -0,0 +1,35 @@ +require_relative 'base' + +class TestMkmf + class TestFlags < TestMkmf + def test_valid_warnflags + val = $extmk + warnflags = $warnflags + makefile = mkmf do + $extmk = false + self.class::CONFIG['warnflags'] = %w"-Wextra + -Wno-unused-parameter -Wno-parentheses -Wno-long-long + -Wno-missing-field-initializers -Werror=pointer-arith + -Werror=write-strings -Werror=declaration-after-statement + -Werror=shorten-64-to-32 + -Werror-implicit-function-declaration + ".join(' ') + self.class::CONFIG['GCC'] = 'yes' + init_mkmf(self.class::CONFIG) + configuration '.' + end + generated_flags = makefile.grep(/warnflags/).first[/^warnflags = (.*)$/, 1].split + + assert_equal %w" + -Wextra -Wno-unused-parameter -Wno-parentheses + -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith + -Wwrite-strings -Wdeclaration-after-statement + -Wshorten-64-to-32 -Wimplicit-function-declaration + ", generated_flags + + ensure + $warnflags = warnflags + $extmk = val + end + end +end |