diff options
author | luke <luke@1f5c1d6a-bddf-0310-8f58-fc49e503516a> | 2006-01-03 19:05:32 +0000 |
---|---|---|
committer | luke <luke@1f5c1d6a-bddf-0310-8f58-fc49e503516a> | 2006-01-03 19:05:32 +0000 |
commit | 1dc02f90b5f607894f347c1c9d5b50d8672b9121 (patch) | |
tree | a629047fb1e29e296032a54e6cde927f32857e94 | |
parent | b542ec55360018bdcc776b9edd6c6fabffd9622d (diff) | |
download | facter-1dc02f90b5f607894f347c1c9d5b50d8672b9121.tar.gz facter-1dc02f90b5f607894f347c1c9d5b50d8672b9121.tar.xz facter-1dc02f90b5f607894f347c1c9d5b50d8672b9121.zip |
adding extra "return nil" statements, and hopefully fixing the test for cygwin
git-svn-id: http://reductivelabs.com/svn/facter/trunk@69 1f5c1d6a-bddf-0310-8f58-fc49e503516a
-rw-r--r-- | Rakefile | 2 | ||||
-rw-r--r-- | lib/facter.rb | 13 | ||||
-rwxr-xr-x | tests/tc_facterbin.rb | 15 |
3 files changed, 10 insertions, 20 deletions
@@ -274,7 +274,7 @@ task :tag => [:prerelease] do if ENV['RELTEST'] announce "Release Task Testing, skipping SVN tagging" else - sh %{svn copy trunk/ tags/#{reltag}} + sh %{svn copy ../trunk/ ../tags/#{reltag}} end end diff --git a/lib/facter.rb b/lib/facter.rb index 6aafbb7..dec05a3 100644 --- a/lib/facter.rb +++ b/lib/facter.rb @@ -495,8 +495,7 @@ FACTERVERSION = '1.0.2' } Facter["Domain"].add { |obj| obj.code = proc { - domain = Resolution.exec('domainname') - return nil unless domain + domain = Resolution.exec('domainname') or return nil # make sure it's a real domain if domain =~ /.+\..+/ domain @@ -535,7 +534,7 @@ FACTERVERSION = '1.0.2' Facter["Hostname"].add { |obj| obj.code = proc { hostname = nil - name = Resolution.exec('hostname') + name = Resolution.exec('hostname') or return nil if name =~ /^([\w-]+)\.(.+)$/ hostname = $1 # the Domain class uses this @@ -552,7 +551,7 @@ FACTERVERSION = '1.0.2' require 'resolv' begin - hostname = Facter["hostname"].value + hostname = Facter["hostname"].value or return nil ip = Resolv.getaddress(hostname) unless ip == "127.0.0.1" ip @@ -566,11 +565,11 @@ FACTERVERSION = '1.0.2' } Facter["IPHostNumber"].add { |obj| obj.code = proc { - hostname = Facter["hostname"].value + hostname = Facter["hostname"].value or return nil # we need Hostname to exist for this to work - list = Resolution.exec("host #{hostname}").chomp.split(/\s/) + list = Resolution.exec("host #{hostname}").chomp.split(/\s/) or + return nil - return nil unless list if defined? list[-1] and list[-1] =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ list[-1] end diff --git a/tests/tc_facterbin.rb b/tests/tc_facterbin.rb index 4bdfdd8..07e820b 100755 --- a/tests/tc_facterbin.rb +++ b/tests/tc_facterbin.rb @@ -1,15 +1,13 @@ #! /usr/bin/env ruby # $Id: $ -if __FILE__ == $0 - $:.unshift '../lib' - $facterbase = ".." -end +$:.unshift '../lib' +$facterbase = ".." require 'facter' require 'test/unit' # add the bin directory to our search path -ENV["PATH"] += ":" + File.join($facterbase, "bin") +ENV["PATH"] = File.join($facterbase, "bin") + ":" + ENV["PATH"] # and then the library directories libdirs = $:.find_all { |dir| @@ -18,18 +16,11 @@ libdirs = $:.find_all { |dir| ENV["RUBYLIB"] = libdirs.join(":") class TestFacterBin < Test::Unit::TestCase - def setup - end - - def teardown - end - def test_version output = nil assert_nothing_raised { output = %x{facter --version 2>&1}.chomp } - print output assert(output == Facter.version) end end |