Signed-off-by: Luke Kanies <[email protected]>
---
spec/lib/puppet_spec/files.rb | 10 +++++++
spec/spec_helper.rb | 14 +++++++++
test/executables/puppetmodule.rb | 55 --------------------------------------
3 files changed, 24 insertions(+), 55 deletions(-)
delete mode 100755 test/executables/puppetmodule.rb
diff --git a/spec/lib/puppet_spec/files.rb b/spec/lib/puppet_spec/files.rb
index 542ad6e..aad3740 100644
--- a/spec/lib/puppet_spec/files.rb
+++ b/spec/lib/puppet_spec/files.rb
@@ -1,9 +1,19 @@
+require 'fileutils'
+
# A support module for testing files.
module PuppetSpec::Files
def tmpfile(name)
source = Tempfile.new(name)
path = source.path
source.close!
+ $tmpfiles ||= []
+ $tmpfiles << path
path
end
+
+ def tmpdir(name)
+ file = tmpfile(name)
+ FileUtils.mkdir_p(file)
+ file
+ end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 0a603cd..e3dd6b9 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -39,6 +39,20 @@ Spec::Runner.configure do |config|
config.prepend_after :each do
Puppet.settings.clear
Puppet::Node::Environment.clear
+
+ if defined?($tmpfiles)
+ $tmpfiles.each do |file|
+ unless file.include?("/tmp") or file.include?("/var/folders")
+ puts "Not deleting tmpfile #{file} outside of /tmp or
/var/folders"
+ next
+ end
+ if FileTest.exist?(file)
+ system("chmod -R 755 #{file}")
+ system("rm -rf #{file}")
+ end
+ end
+ $tmpfiles.clear
+ end
end
end
diff --git a/test/executables/puppetmodule.rb b/test/executables/puppetmodule.rb
deleted file mode 100755
index ce28796..0000000
--- a/test/executables/puppetmodule.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../lib/puppettest'
-
-require 'puppettest'
-
-class TestPuppetModule < Test::Unit::TestCase
- include PuppetTest::ExeTest
-
-
- def setup
- super
- @module = File.join(basedir, "ext", "module_puppet")
- end
-
- def test_existence
- assert(FileTest.exists?(@module), "Module does not exist")
- end
-
- def test_execution
- file = tempfile()
-
- createdfile = tempfile()
-
- File.open(file, "w") { |f|
- f.puts "class yaytest { file { \"#{createdfile}\": ensure => file
} }"
- }
-
- output = nil
- cmd = @module
- cmd += " --verbose"
- #cmd += " --fqdn %s" % fqdn
- cmd += " --confdir %s" % Puppet[:confdir]
- cmd += " --vardir %s" % Puppet[:vardir]
- if Puppet[:debug]
- cmd += " --logdest %s" % "console"
- cmd += " --debug"
- cmd += " --trace"
- else
- cmd += " --logdest %s" % "/dev/null"
- end
-
- ENV["CFALLCLASSES"] = "yaytest:all"
- libsetup
-
- out = nil
- assert_nothing_raised {
- out = %x{#{cmd + " " + file} 2>&1}
- }
- assert($? == 0, "Puppet module exited with code %s: %s" % [$?.to_i,
out])
-
- assert(FileTest.exists?(createdfile), "Failed to create config'ed
file")
- end
-end
-
--
1.6.1
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.