Fixed error handling in Rake::ConfigureTask::FooConfigTest#lookup_flags.
[ruby-vorbistagger.git] / rake / configuretask.rb
index 1b24f7260fce6ab671088ada7c521d4efe0f6036..b673c84a8b45fa770a75b23fc999443a76b1d24a 100644 (file)
@@ -146,8 +146,6 @@ module Rake
                                                exec(bin)
                                        rescue SystemCallError
                                                exit 255
-                                       ensure
-                                               tf.close
                                        end
                                end
 
@@ -180,17 +178,23 @@ module Rake
                        def invoke
                                return false unless can_exec_command?
 
-                               [:version, :cflags, :libs].each do |f|
-                                       @result[f] = lookup_flags(f)
+                               begin
+                                       [:version, :cflags, :libs].each do |f|
+                                               @result[f] = lookup_flags(f)
+                                       end
+                               rescue Exception
+                                       @result.clear
                                end
 
-                               true
+                               !@result.empty?
                        end
 
                        protected
                        def lookup_flags(f)
                                tmp = `#{@command} --#{f}`.strip
-                               $?.exitstatus.zero? ? tmp : nil
+
+                               raise unless $?.exitstatus.zero?
+                               tmp
                        end
 
                        private
@@ -212,7 +216,9 @@ module Rake
 
                                tmp = `#{@command} --silence-errors --#{f} #{@name}`.
                                      strip.tr("\n", "/")
-                               $?.exitstatus.zero? ? tmp : nil
+
+                               raise unless $?.exitstatus.zero?
+                               tmp
                        end
                end