summaryrefslogtreecommitdiffstats
path: root/spec/lib/puppet_spec
Commit message (Collapse)AuthorAgeFilesLines
* Consolidate test logic determining if a registered file is in the temp directoryJacob Helwig2011-08-021-10/+8
| | | | | | | | | | | | | | | | | | | | | | | Previously, we were always using string comparisons, and hard-coded paths to temp locations on non-Windows platforms. This was problematic for a few reasons. We had to maintain a list of temp locations for the various platforms, and the string comparisons were unreliable on Windows, since paths have two string representations (the "short" name containing a ~ followed by a number, and the "full" name). By getting the current temp location using Dir.tempdir (the same mechanism our temp creation code uses), we no longer need to maintain the list of temp locations. Also, rather than doing string comparisons on file paths, we can use a combination of Pathname#ascend, and File.identical? to determine if the path registered as a temp file for deletion was actually created in the temp location. With this refactoring, the same code now works for both Windows, and non-Windows platforms. Reviewed-by: Nick Lewis <nick@puppetlabs.com>
* Fix tests with "relative" paths on WindowsJosh Cooper2011-07-191-0/+10
| | | | | | | | | | | | | Absolute paths on Unix, e.g. /foo/bar, are not absolute on Windows, which breaks many test cases. This commit adds a method to PuppetSpec::Files.make_absolute that makes the path absolute in test cases. On Unix (Puppet.features.posix?) it is a no-op. On Windows, (Puppet.features.microsoft_windows?) the drive from the current working directory is prepended. Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
* maint: add a 'print' matcher to rspec, to inspect std{out,err}Daniel Pittman2011-04-281-0/+87
| | | | | | | | | | | | You can now write expectations along the lines of: expect { ... }.to print /whatever/ This will do the expected thing, which is to require that we print something matching that regular expression during the block. The output itself is suppressed during operation of the matcher. Paired-With: Max Martin <max@puppetlabs.com>
* maint: clean up the spec test headers in bulk.Daniel Pittman2011-04-133-0/+0
| | | | | | | We now use a shebang of: #!/usr/bin/env rspec This enables the direct execution of spec tests again, which was lost earlier during the transition to more directly using the rspec2 runtime environment.
* maint: use FileUtil to remove files, not execDaniel Pittman2011-04-081-23/+33
| | | | | | | | | We used to shell out to chmod and rm to clean up temporary files; this lead to the cleanup method here being one of the largest consumers of walltime. Replacing that with FileUtil calls is as, or more, secure, and performs sufficiently well that we can just delegate. Reviewed-By: Matt Robinson <matt@puppetlabs.com>
* Merge branch '2.6.next' into nextMax Martin2011-03-231-0/+9
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 2.6.next: Fixed #6562 - Minor kick documentation fix (#6658) Propagate ENC connection errors to the agent (#4884) Remove typo from spec test (#4884) Modify tests to pass on non-OS X systems (#4884) Revise new exec tests, add a few more (#4884) Add an shell provider for execs (#4884) Fix Test::Unit exec tests (#4884) Break the exec type out to have a posix provider (#4884) Add consistent path validation and behavior (#4884) Add expand_path to requiring the spec_helper (#4884) Autorequire shared behaviors and method to silence warnings (#4884) Fix whitespace (#4884) Get rid of open3 require since it wasn't being used (#5814) Improved cron type specs (#5814) cron_spec shouldn't depend on cron provider Manually Resolved Conflicts: lib/puppet/util/command_line/puppetrun spec/spec_helper.rb spec/unit/type/exec_spec.rb spec/unit/type_spec.rb test/ral/type/exec.rb
| * (#4884) Autorequire shared behaviors and method to silence warningsDaniel Pittman2011-03-151-0/+9
| | | | | | | | | | | | | | with_verbose_disabled allows you to run tests that muck with constans without getting spammy warnings. Reviewed-by: Max Martin and Matt Robinson
* | (#6582) Don't demand the checkout be named 'puppet'.Daniel Pittman2011-03-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | As part of implementing the fixture support I hard-coded the assumption that the git checkout was a directory named 'puppet'; this broke on our CI server, and would break for anyone else who didn't follow that default. This commit eliminates that assumption and depends only on the appropriate part of the input filename. Reviewed-By: Paul Berry <paul@puppetlabs.com>
* | (#6582) move more helper code into methods, out of RSpec#configureDaniel Pittman2011-03-031-0/+23
| | | | | | | | | | | | | | | | We move the tempfile cleanup support off into the module that uses it, which removes some of the dependency on magic globals from configure. It still exists, but is hidden in the same module that uses it, which helps. Reviewed-By: Nick Lewis <nick@puppetlabs.com>
* | (#6582) add fixture helper methods to replace unit test code.Daniel Pittman2011-03-031-0/+28
|/ | | | | | | | | | | | | We validate that fixtures exist, when requested, or that they match something when they use a glob. This catches internal errors where we don't match any fixtures with a glob; this can reveal problems that would otherwise avoid all assertions and result in internal failures. The code is hidden out in a module, included in the main RSpec namespace. This doesn't clean up the API any, but it isolates the code more effectively and keeps the configuration file cleaner. Reviewed-By: Nick Lewis <nick@puppetlabs.com>
* [#4771] Import of manifests with the same name only happens oncePaul Berry2010-09-231-0/+1
| | | | | | | | | | | | | | | The function import_if_possible, which was supposed to be responsible for making sure that no two threads tried to import the same file at the same time, was not making this decision based on the full pathname of the file, since it was being invoked before pathnames were resolved. As a result, if we attempted to import two distinct files with the same name at the same time (either in two threads or in a single thread due to recursion), one of the files would not always get imported. Fixed this problem by moving the thread-safety logic to happen after filenames are resolved to absolute paths. This made it possible to simplify the thread-safety logic significantly.
* Code smell: Two space indentationMarkus Roberts2010-07-091-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replaced 106806 occurances of ^( +)(.*$) with The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people who learned ruby in the 1900s) uses two-space indentation. 3 Examples: The code: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") becomes: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") The code: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object becomes: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object The code: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end becomes: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end
* Adding tmpfile cleanup to testsLuke Kanies2010-02-171-0/+10
| | | | Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Adding a Spec lib directory and moving tmpfile to itLuke Kanies2009-05-261-0/+9
We had a common pattern for creating a temporary file during integration tests, and this just makes that common pattern explicit by moving it to a module in the newly-created lib directory in the spec directory. We definitely don't want to go overboard in using libraries in our tests, but sometimes it gets a bit excessive to completely avoid them. Signed-off-by: Luke Kanies <luke@madstop.com>