diff --git a/ChangeLog b/ChangeLog index 841160149f..6497a832c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Fri Dec 10 18:11:08 2010 Nobuyoshi Nakada + + * lib/mkmf.rb (Logging.log_close): separate from Logging.logfile. + + * test/mkmf/base.rb (TestMkmf::MKMFLOG): show mkmf.log at failures. + + * test/mkmf/base.rb (TestMkmf#teardown): close log file for each tests. + Fri Dec 10 11:36:43 2010 Kazuhiro NISHIYAMA * compile.c (enum): remove a comma at end of enumerator list. diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 3e02886f67..d289cefca7 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -264,6 +264,10 @@ module Logging def self::logfile file @logfile = file + log_close + end + + def self::log_close if @log and not @log.closed? @log.flush @log.close diff --git a/test/mkmf/base.rb b/test/mkmf/base.rb index 79f46ed202..4ceb35087a 100644 --- a/test/mkmf/base.rb +++ b/test/mkmf/base.rb @@ -9,6 +9,11 @@ $INCFLAGS << " -I." $extout_prefix = "$(extout)$(target_prefix)/" class TestMkmf < Test::Unit::TestCase + MKMFLOG = proc {File.read("mkmf.log") rescue ""} + class << MKMFLOG + alias to_s call + end + def setup @tmpdir = Dir.mktmpdir @curdir = Dir.pwd @@ -19,6 +24,7 @@ class TestMkmf < Test::Unit::TestCase def teardown Logging.quiet = @quiet + Logging.log_close Dir.chdir(@curdir) FileUtils.rm_rf(@tmpdir) end diff --git a/test/mkmf/test_convertible.rb b/test/mkmf/test_convertible.rb index 82189ff100..539998a3f4 100644 --- a/test/mkmf/test_convertible.rb +++ b/test/mkmf/test_convertible.rb @@ -6,7 +6,7 @@ class TestMkmf ["", ["signed ", ""], "unsigned "].each do |signed, prefix| %w[short int long].each do |type| assert_equal((prefix || signed)+type, - mkmf {convertible_int(signed+type)}) + mkmf {convertible_int(signed+type)}, MKMFLOG) end end end @@ -19,7 +19,7 @@ class TestMkmf } $defs.clear assert_equal((prefix || signed)+type, - mkmf {convertible_int("test1_t", "confdefs.h")}) + mkmf {convertible_int("test1_t", "confdefs.h")}, MKMFLOG) (u = signed[/^u/]) and u.upcase! assert_includes($defs, "-DTYPEOF_TEST1_T="+"#{prefix||signed}#{type}".quote) assert_includes($defs, "-DPRI_TEST1T_PREFIX=PRI_#{type.upcase}_PREFIX") diff --git a/test/mkmf/test_sizeof.rb b/test/mkmf/test_sizeof.rb index a44e609c06..4e3c77e8e3 100644 --- a/test/mkmf/test_sizeof.rb +++ b/test/mkmf/test_sizeof.rb @@ -4,7 +4,7 @@ class TestMkmf class TestSizeof < TestMkmf def test_sizeof_builtin %w[char short int long float double void*].each do |type| - assert_kind_of(Integer, mkmf {check_sizeof(type)}) + assert_kind_of(Integer, mkmf {check_sizeof(type)}, MKMFLOG) end end @@ -12,7 +12,7 @@ class TestMkmf open("confdefs.h", "w") {|f| f.puts "typedef struct {char x;} test1_t;" } - assert_equal(1, mkmf {check_sizeof("test1_t", "confdefs.h")}) + assert_equal(1, mkmf {check_sizeof("test1_t", "confdefs.h")}, MKMFLOG) end end end