diff options
| author | Jacob Helwig <jacob@puppetlabs.com> | 2011-03-08 11:23:11 -0800 |
|---|---|---|
| committer | Jacob Helwig <jacob@puppetlabs.com> | 2011-03-08 11:23:11 -0800 |
| commit | 469d2a26a467c50af9f9732d7f98e8a01ecc369f (patch) | |
| tree | cb5f4d7b64404105d7b43492d36437201cb13e08 | |
| parent | 154d2a26a1cd81395c370a586a264f6ed13b0fb3 (diff) | |
| parent | fd38ce08cdcd8b3357400787089c34b1b61d4551 (diff) | |
| download | facter-469d2a26a467c50af9f9732d7f98e8a01ecc369f.tar.gz facter-469d2a26a467c50af9f9732d7f98e8a01ecc369f.tar.xz facter-469d2a26a467c50af9f9732d7f98e8a01ecc369f.zip | |
Merge branch 'next'
* next:
Fixed #5950 - Solaris ipaddress incorrect after bonding failure
(#6615) fix missing stub calls in loader specs
(#5666) windows support for facter/id.rb
(#4925) - MS Windows doesn't do man pages
Fixed #6611 - Fixed broken HPVM test and rationalised test structure
(#6525) change semicolons to 'then' in case statement for ruby 1.9.2 compatibility
Fixes #6521 and other Ruby 1.9 issues
Fixed #6525 - Test failures on Ruby 1.9.x
(#5031) Remove redundant puts from RDoc.usage
| -rwxr-xr-x | install.rb | 28 | ||||
| -rw-r--r-- | lib/facter/application.rb | 2 | ||||
| -rw-r--r-- | lib/facter/id.rb | 2 | ||||
| -rw-r--r-- | lib/facter/ipaddress.rb | 2 | ||||
| -rw-r--r-- | lib/facter/lsb.rb | 8 | ||||
| -rw-r--r-- | lib/facter/util/virtual.rb | 4 | ||||
| -rw-r--r-- | lib/facter/util/vlans.rb | 4 | ||||
| -rwxr-xr-x | spec/unit/util/loader_spec.rb | 11 | ||||
| -rw-r--r-- | spec/unit/util/manufacturer_spec.rb | 4 | ||||
| -rw-r--r-- | spec/unit/virtual_spec.rb | 23 |
10 files changed, 48 insertions, 40 deletions
@@ -97,16 +97,20 @@ def do_libs(libs, strip = 'lib/') end def do_man(man, strip = 'man/') + if (InstallOptions.man == true) man.each do |mf| - omf = File.join(InstallOptions.man_dir, mf.gsub(/#{strip}/, '')) - om = File.dirname(omf) - FileUtils.makedirs(om, {:mode => 0755, :verbose => true}) - FileUtils.chmod(0755, om) - FileUtils.install(mf, omf, {:mode => 0644, :verbose => true}) - gzip = %x{which gzip} - gzip.chomp! - %x{#{gzip} -f #{omf}} + omf = File.join(InstallOptions.man_dir, mf.gsub(/#{strip}/, '')) + om = File.dirname(omf) + FileUtils.makedirs(om, {:mode => 0755, :verbose => true}) + FileUtils.chmod(0755, om) + FileUtils.install(mf, omf, {:mode => 0644, :verbose => true}) + gzip = %x{which gzip} + gzip.chomp! + %x{#{gzip} -f #{omf}} end + else + puts "Skipping Man Page Generation" + end end # Verify that all of the prereqs are installed @@ -121,6 +125,10 @@ def check_prereqs } end +def is_windows? + RUBY_PLATFORM.to_s.match(/mswin|win32|dos|cygwin|mingw/) +end + ## # Prepare the file installation. # @@ -128,7 +136,7 @@ def prepare_installation # Only try to do docs if we're sure they have rdoc if $haverdoc InstallOptions.rdoc = true - if RUBY_PLATFORM == "i386-mswin32" + if is_windows? InstallOptions.ri = false else InstallOptions.ri = true @@ -141,7 +149,7 @@ def prepare_installation if $haveman InstallOptions.man = true - if RUBY_PLATFORM == "i386-mswin32" + if is_windows? InstallOptions.man = false end else diff --git a/lib/facter/application.rb b/lib/facter/application.rb index 9d6bc34..6b351b1 100644 --- a/lib/facter/application.rb +++ b/lib/facter/application.rb @@ -85,7 +85,7 @@ module Facter begin require 'rdoc/ri/ri_paths' require 'rdoc/usage' - puts RDoc.usage + RDoc.usage # print usage and exit rescue LoadError $stderr.puts "No help available unless your RDoc has RDoc.usage" exit(1) diff --git a/lib/facter/id.rb b/lib/facter/id.rb index c2ab3b7..c2c3594 100644 --- a/lib/facter/id.rb +++ b/lib/facter/id.rb @@ -1,5 +1,5 @@ Facter.add(:id) do - confine :operatingsystem => %w{Linux Fedora RedHat CentOS SuSE SLES Debian Ubuntu Gentoo AIX OEL OVS GNU/kFreeBSD} + confine :operatingsystem => %w{Linux Fedora RedHat CentOS SuSE SLES Debian Ubuntu Gentoo AIX OEL OVS GNU/kFreeBSD windows} setcode "whoami" end diff --git a/lib/facter/ipaddress.rb b/lib/facter/ipaddress.rb index 08a5dc8..d563408 100644 --- a/lib/facter/ipaddress.rb +++ b/lib/facter/ipaddress.rb @@ -47,7 +47,7 @@ Facter.add(:ipaddress) do output.split(/^\S/).each { |str| if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ tmp = $1 - unless tmp =~ /^127\./ + unless tmp =~ /^127\./ or tmp == "0.0.0.0" ip = tmp break end diff --git a/lib/facter/lsb.rb b/lib/facter/lsb.rb index 4b98466..bf4b9db 100644 --- a/lib/facter/lsb.rb +++ b/lib/facter/lsb.rb @@ -22,13 +22,13 @@ Facter.add(fact) do confine :kernel => [ :linux, :"gnu/kfreebsd" ] setcode do - unless defined?(@@lsbdata) and defined?(@@lsbtime) and (Time.now.to_i - @@lsbtime.to_i < 5) + unless defined?(lsbdata) and defined?(lsbtime) and (Time.now.to_i - lsbtime.to_i < 5) type = nil - @@lsbtime = Time.now - @@lsbdata = Facter::Util::Resolution.exec('lsb_release -a 2>/dev/null') + lsbtime = Time.now + lsbdata = Facter::Util::Resolution.exec('lsb_release -a 2>/dev/null') end - if pattern.match(@@lsbdata) + if pattern.match(lsbdata) $1 else nil diff --git a/lib/facter/util/virtual.rb b/lib/facter/util/virtual.rb index 129448e..06b1b6d 100644 --- a/lib/facter/util/virtual.rb +++ b/lib/facter/util/virtual.rb @@ -60,8 +60,8 @@ module Facter::Util::Virtual def self.jail? path = case Facter.value(:kernel) - when "FreeBSD": "/sbin" - when "GNU/kFreeBSD": "/bin" + when "FreeBSD" then "/sbin" + when "GNU/kFreeBSD" then "/bin" end Facter::Util::Resolution.exec("#{path}/sysctl -n security.jail.jailed") == "1" end diff --git a/lib/facter/util/vlans.rb b/lib/facter/util/vlans.rb index 6d226ff..2b2a72f 100644 --- a/lib/facter/util/vlans.rb +++ b/lib/facter/util/vlans.rb @@ -12,7 +12,7 @@ module Facter::Util::Vlans def self.get_vlans vlans = Array.new if self.get_vlan_config - self.get_vlan_config.each do |line| + self.get_vlan_config.each_line do |line| if line =~ /^([0-9A-Za-z]+)\.([0-9]+) / vlans.insert(-1, $~[2]) if $~[2] end @@ -21,4 +21,4 @@ module Facter::Util::Vlans vlans.join(',') end -end +end diff --git a/spec/unit/util/loader_spec.rb b/spec/unit/util/loader_spec.rb index eed533a..90530e8 100755 --- a/spec/unit/util/loader_spec.rb +++ b/spec/unit/util/loader_spec.rb @@ -119,7 +119,10 @@ describe Facter::Util::Loader do @loader.stubs(:search_path).returns %w{/one/dir} Dir.stubs(:entries).with("/one/dir/testing").returns %w{foo.rb bar.rb} - %w{/one/dir/testing/foo.rb /one/dir/testing/bar.rb}.each { |f| File.stubs(:directory?).with(f).returns false } + %w{/one/dir/testing/foo.rb /one/dir/testing/bar.rb}.each do |f| + File.stubs(:directory?).with(f).returns false + Kernel.stubs(:load).with(f) + end @loader.load(:testing) @loader.loaded_files.should == %w{/one/dir/testing/bar.rb /one/dir/testing/foo.rb} @@ -202,7 +205,11 @@ describe Facter::Util::Loader do Dir.stubs(:entries).with("/one/dir").returns %w{foo.rb bar.rb} %w{/one/dir}.each { |f| File.stubs(:directory?).with(f).returns true } - %w{/one/dir/foo.rb /one/dir/bar.rb}.each { |f| File.stubs(:directory?).with(f).returns false } + + %w{/one/dir/foo.rb /one/dir/bar.rb}.each do |f| + File.stubs(:directory?).with(f).returns false + Kernel.expects(:load).with(f) + end @loader.load_all diff --git a/spec/unit/util/manufacturer_spec.rb b/spec/unit/util/manufacturer_spec.rb index 07473db..c3b372e 100644 --- a/spec/unit/util/manufacturer_spec.rb +++ b/spec/unit/util/manufacturer_spec.rb @@ -109,8 +109,8 @@ Handle 0x001F def find_product_name(os) output_file = case os - when "FreeBSD": File.dirname(__FILE__) + "/../data/freebsd_dmidecode" - when "SunOS" : File.dirname(__FILE__) + "/../data/opensolaris_smbios" + when "FreeBSD" then File.dirname(__FILE__) + "/../data/freebsd_dmidecode" + when "SunOS" then File.dirname(__FILE__) + "/../data/opensolaris_smbios" end output = File.new(output_file).read() diff --git a/spec/unit/virtual_spec.rb b/spec/unit/virtual_spec.rb index a152b40..5f63dab 100644 --- a/spec/unit/virtual_spec.rb +++ b/spec/unit/virtual_spec.rb @@ -6,9 +6,14 @@ require 'facter/util/macosx' describe "Virtual fact" do - after do - Facter.clear - end + before do + Facter::Util::Virtual.stubs(:zone?).returns(false) + Facter::Util::Virtual.stubs(:openvz?).returns(false) + Facter::Util::Virtual.stubs(:vserver?).returns(false) + Facter::Util::Virtual.stubs(:xen?).returns(false) + Facter::Util::Virtual.stubs(:kvm?).returns(false) + Facter::Util::Virtual.stubs(:hpvm?).returns(false) + end it "should be zone on Solaris when a zone" do Facter.fact(:kernel).stubs(:value).returns("SunOS") @@ -58,13 +63,6 @@ describe "Virtual fact" do end describe "on Linux" do - before do - Facter::Util::Virtual.stubs(:zone?).returns(false) - Facter::Util::Virtual.stubs(:openvz?).returns(false) - Facter::Util::Virtual.stubs(:vserver?).returns(false) - Facter::Util::Virtual.stubs(:xen?).returns(false) - Facter::Util::Virtual.stubs(:kvm?).returns(false) - end it "should be parallels with Parallels vendor id from lspci" do Facter.fact(:kernel).stubs(:value).returns("Linux") @@ -114,15 +112,10 @@ describe "Virtual fact" do Facter.fact(:virtual).value.should == "parallels" end end - end describe "is_virtual fact" do - after do - Facter.clear - end - it "should be virtual when running on xen" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("xenu") |
