diff options
author | Luke Kanies <luke@madstop.com> | 2005-08-06 04:58:14 +0000 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2005-08-06 04:58:14 +0000 |
commit | a6a11487bf731585f29e4d49b91d8c0d1fffb714 (patch) | |
tree | 4eef00d1c7cfdffee50cafd8c07fee78672853a9 | |
parent | f3c1487c1183a97a45c8e63eef37251ca6360afb (diff) | |
download | puppet-a6a11487bf731585f29e4d49b91d8c0d1fffb714.tar.gz puppet-a6a11487bf731585f29e4d49b91d8c0d1fffb714.tar.xz puppet-a6a11487bf731585f29e4d49b91d8c0d1fffb714.zip |
all tests now pass on os x
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@502 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | lib/puppet/statechange.rb | 2 | ||||
-rw-r--r-- | lib/puppet/type/package.rb | 7 | ||||
-rw-r--r-- | lib/puppet/type/pfile.rb | 29 | ||||
-rw-r--r-- | lib/puppet/type/state.rb | 14 | ||||
-rw-r--r-- | test/other/tc_transactions.rb | 30 | ||||
-rwxr-xr-x | test/types/tc_exec.rb | 8 | ||||
-rw-r--r-- | test/types/tc_file.rb | 2 | ||||
-rw-r--r-- | test/types/tc_package.rb | 4 |
8 files changed, 81 insertions, 15 deletions
diff --git a/lib/puppet/statechange.rb b/lib/puppet/statechange.rb index 257558513..f5bd5323d 100644 --- a/lib/puppet/statechange.rb +++ b/lib/puppet/statechange.rb @@ -126,7 +126,7 @@ module Puppet #--------------------------------------------------------------- def to_s return "%s: %s changed %s to %s" % - [@state.parent, @state.name, @is, @should] + [@state.parent, @state.name, @state.is_to_s, @state.should_to_s] end #--------------------------------------------------------------- end diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb index 82bba1414..77c866c08 100644 --- a/lib/puppet/type/package.rb +++ b/lib/puppet/type/package.rb @@ -441,9 +441,10 @@ module Puppet @@default = :rpm end else - raise Puppet::Error.new( - "No default type for " + Puppet::Fact["operatingsystem"] - ) + @@default = nil + #raise Puppet::Error.new( + # "No default type for " + Puppet::Fact["operatingsystem"] + #) end end diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb index 3b8469458..c6f37724a 100644 --- a/lib/puppet/type/pfile.rb +++ b/lib/puppet/type/pfile.rb @@ -384,6 +384,15 @@ module Puppet @name = :mode @event = :inode_changed + # our modes are octal, so print them in decimal instead + def is_to_s + "%o" % @is + end + + def should_to_s + "%o" % @should + end + def should=(should) # this is pretty hackish, but i need to make sure the number is in # octal, yet the number can only be specified as a string right now @@ -493,15 +502,19 @@ module Puppet begin group = Etc.send(method,value) - # apparently os x is six shades of weird - os = Puppet::Fact["Operatingsystem"] - case os - when "Darwin": - gid = group.passwd - else - gid = group.gid - end + # at one time, os x was putting the gid into the passwd + # field of the group struct, but that appears to not + # be the case any more + #os = Puppet::Fact["Operatingsystem"] + #case os + #when "Darwin": + # #gid = group.passwd + # gid = group.gid + #else + #end + + gid = group.gid gname = group.name if gid.nil? diff --git a/lib/puppet/type/state.rb b/lib/puppet/type/state.rb index 38cd51fa9..6524e4aa0 100644 --- a/lib/puppet/type/state.rb +++ b/lib/puppet/type/state.rb @@ -119,6 +119,20 @@ class State < Puppet::Element #--------------------------------------------------------------- #--------------------------------------------------------------- + # because the @should and @is vars might be in weird formats, + # we need to set up a mechanism for pretty printing of the values + # default to just the values, but this way individual states can + # override these methods + def is_to_s + @is + end + + def should_to_s + @should + end + #--------------------------------------------------------------- + + #--------------------------------------------------------------- def to_s return "%s(%s)" % [@parent.name,self.name] end diff --git a/test/other/tc_transactions.rb b/test/other/tc_transactions.rb index fc849c04b..737622c26 100644 --- a/test/other/tc_transactions.rb +++ b/test/other/tc_transactions.rb @@ -25,6 +25,17 @@ class TestTransactions < Test::Unit::TestCase return events end + def ingroup(gid) + require 'etc' + begin + group = Etc.getgrgid(gid) + rescue => detail + puts "Could not retrieve info for group %s: %s" % [gid, detail] + end + + return @groups.include?(group.name) + end + def setup Puppet::Type.allclear @@tmpfiles = [] @@ -53,6 +64,24 @@ class TestTransactions < Test::Unit::TestCase def newfile(hash = {}) tmpfile = tempfile() File.open(tmpfile, "w") { |f| f.puts rand(100) } + + # XXX now, because os x apparently somehow allows me to make a file + # owned by a group i'm not a member of, i have to verify that + # the file i just created is owned by one of my groups + # grrr + unless ingroup(File.stat(tmpfile).gid) + Puppet.info "Somehow created file in non-member group %s; fixing" % + File.stat(tmpfile).gid + + require 'etc' + firstgr = @groups[0] + unless firstgr.is_a?(Integer) + str = Etc.getgrnam(firstgr) + firstgr = str.gid + end + File.chown(nil, firstgr, tmpfile) + end + @@tmpfiles.push tmpfile hash[:name] = tmpfile assert_nothing_raised() { @@ -88,6 +117,7 @@ class TestTransactions < Test::Unit::TestCase def test_filerollback transaction = nil file = newfile() + states = {} check = [:group,:mode] file[:check] = check diff --git a/test/types/tc_exec.rb b/test/types/tc_exec.rb index 387902e8d..f9f59de24 100755 --- a/test/types/tc_exec.rb +++ b/test/types/tc_exec.rb @@ -128,10 +128,14 @@ class TestExec < Test::Unit::TestCase def test_cwdsettings command = nil + dir = "/tmp" + wd = Dir.chdir(dir) { + Dir.getwd + } assert_nothing_raised { command = Puppet::Type::Exec.new( :command => "pwd", - :cwd => "/tmp", + :cwd => dir, :path => "/usr/bin:/bin:/usr/sbin:/sbin", :returns => 0 ) @@ -142,7 +146,7 @@ class TestExec < Test::Unit::TestCase assert_nothing_raised { command.sync } - assert_equal("/tmp\n",command.output) + assert_equal(wd,command.output.chomp) end def test_refreshonly diff --git a/test/types/tc_file.rb b/test/types/tc_file.rb index e90a6cd57..85f6723e1 100644 --- a/test/types/tc_file.rb +++ b/test/types/tc_file.rb @@ -151,7 +151,7 @@ class TestFile < Test::Unit::TestCase end end - def test_group + def test_zzgroup file = mktestfile() [%x{groups}.chomp.split(/ /), Process.groups].flatten.each { |group| assert_nothing_raised() { diff --git a/test/types/tc_package.rb b/test/types/tc_package.rb index 772ce30b0..54a020a9c 100644 --- a/test/types/tc_package.rb +++ b/test/types/tc_package.rb @@ -15,6 +15,9 @@ Puppet[:loglevel] = :debug if __FILE__ == $0 $platform = Facter["operatingsystem"].value +unless Puppet::Type::Package.defaulttype + puts "No default package type for %s; skipping package tests" % $platform +else class TestPackagingType < Test::Unit::TestCase def teardown Puppet::Type::Package.clear @@ -187,3 +190,4 @@ class TestPackages < Test::Unit::TestCase } end end +end |