summaryrefslogtreecommitdiff
path: root/spec/lib/puppet_spec
AgeCommit message (Collapse)AuthorFilesLines
2012-05-11Revert "maint: use relative paths to fixtures."Patrick Carlisle1-10/+3
This reverts commit 7ce9e17cf1077604accc1a5cfe90ad7b1bb99a55. The change to using Pathname in fixtures is not compatible with Windows.
2012-05-10maint: use relative paths to fixtures.Daniel Pittman1-3/+10
We used to return absolute paths to fixtures, rather than relative paths. This made the test output uglier than it needed to be; we may as well do the extra work to make them relative. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-04-20Added tests around enc usageAndrew Parker1-2/+2
Scoping for classes included by an ENC follow some rules that are not immediately obvious. These tests should nail down and clarify that behaviour
2012-04-18Store Rails logs on physical disk when testing.Daniel Pittman1-3/+3
On Unix, we stored the Rails log from our StoreConfigs scratch database in `/dev/null`, which is reasonable enough - we don't generally care for them, and that works. On Windows this is harder because their NUL device is magic, and it is hard to configure the Rails logs to actually go there. The system loves to interpret it as a random file relative to the current directory and do the wrong thing in various test scenarios. Ultimately, it doesn't matter if we write the logs to physical disk, and we already had a scratch directory for the physical database - so we can throw the logs there too. Just another reason to use a tmpfs to back /tmp, I guess. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-04-18Forcibly remove temporary files in tests.Daniel Pittman1-1/+1
We have some test helpers, and they allow us to create scratch files and directories that will be politely destroyed at the end of the run. We also have some tests that result in permissions on files being changed; we still want those destroyed, and turning on "force" mode for the delete operation gives us what we need with no real cost - we have plenty of other safety factors in place. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-04-16Re-apply "Merge remote-tracking branch 'upstream/2.7.x'"Andrew Parker1-0/+6
This reverts commit 6d399e087372b77566dd3737d4b444aca2e61050.
2012-04-16Revert "Merge remote-tracking branch 'upstream/2.7.x'"Andrew Parker1-6/+0
This reverts commit 7a430815424e053d6e6c5925eef711ca5edd8373, reversing changes made to 32172d5d8de35f5cdbc31bce327b3567e078bb83.
2012-04-16Merge remote-tracking branch 'upstream/2.7.x'Andrew Parker1-0/+6
* upstream/2.7.x: (22 commits) Removed duplication of compiling a catalog Cleaner test for create_resources doing nothing Fixing problem caused by activerecord Put back require 'puppet' in Puppet::Util (#13299) Fix error message when agent is disabled Update puppet.spec for rpm packaging Fixed old log test to match new autoflush behavior Make sure the log file writable Default autoflushing of log files to true Created test that shows enc warning problem (Maint) Fix order-dependent test failure (Maint) Don't assume eventlog gem is installed on Windows options[:ca_location] is a string not a symbol. Safer to pull Puppet::SSL::Host.ca_location since it is already set correctly. (#13204) Don't ignore missing PATH.augnew files (#13640) Only agents should use next_agent_run Increased test coverage of scoping rules Use more descriptive terms for the differing scopes Make new scoping look through inherited scopes Add tests for mixed inheritence/inclusion Remove dynamic option for lookupvar ... Conflicts: lib/puppet/defaults.rb lib/puppet/parser/scope.rb spec/unit/parser/functions/create_resources_spec.rb spec/unit/parser/scope_spec.rb spec/unit/resource/type_spec.rb test/util/log.rb
2012-04-16Removed duplication of compiling a catalogAndrew Parker1-0/+6
Created a PuppetSpec::Compiler module for helping out testing things that want to compile some code to a catalog
2012-03-27(#13439) refactor spec_helper for spec compatibility between 2.7 andcprice1-11/+4
master
2012-03-22(#7749) doc / tests cleanupcprice1-0/+13
2012-03-20(#7749) Improvements to handling settings, bootstrapping puppetcprice1-0/+10
Major changes include: * support multiple config files (/etc/puppet, ~/.puppet). we no longer use "run_mode" to determine the location of the config file. * remove all references to application run_mode/state from defaults * make the typing of settings a little more strict * create a new setting type for directories, to make us a little less vulnerable to the terrible matching algorithm in FileSetting
2012-02-27Merge pull request #497 from ↵Daniel Pittman2-2/+34
daniel-pittman/bug/2.7.x/active-record-test-failures-with-3.2.1 Bug/2.7.x/active record test failures with 3.2.1
2012-02-15Update module and environment with functionality for the module toolMatt Robinson1-0/+26
Being able to figure out what other modules depend on a module is useful for resolving contraints when installing and preventing uninstalls of modules that are still required. And being able to tell if a module has local changes is useful to prevent accidentally losing those changes when upgrading or uninstalling a module.
2012-02-14Clean up and unify scratch database setup logic.Daniel Pittman1-0/+30
Now that we have a pile of places all trying to do the same setup and exclusion for SQLite in their tests, it pays to push all that into a central location and make it uniformly available to all the tests. This provides a nice, global method that can be invoked by any test suite to configure the database, and then uses that everywhere that was doing scratch database setup. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-02-14Make PuppetSpec::Files methods available at module level.Daniel Pittman1-2/+4
Previously you could only access the `tmpfile` and `tmpdir` helpers by mixing the module in somewhere, despite them exclusively mutating global state. This became inconvenient when trying to centralize the database setup, so I moved them to module functions and made the helpers that mix in defer to the module level methods. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2011-11-11(#10614) Detect when trying to managing ACLs on a non-ACL volumeJosh Cooper1-7/+3
Previously, when managing owner, group, and/or mode on a file whose volume does not support ACLs, Puppet would raise an error when trying to get/set the ACL. This commit allows a file provider to optionally perform validation of the resource. On Windows, the provider ensures that if owner, group, and/or mode are being managed, but the underlying volume does not support ACLs, then we fail early with an appropriate error message. This is a noop for the POSIX file provider as no validation is required. File.expand_path uses the current working directory to generate absolute paths. This was causing failures when running the specs from a mapped network drive, e.g. HGFS, since the volume does not support ACLs. This commit changes these tests to use make_absolute method instead, and changes that method to always use the local 'C:\' volume. Paired-with: Nick Lewis <nick@puppetlabs.com>
2011-08-24(#8410) Use absolute_path? for Puppet::Parameter::Path validationNick Lewis1-1/+1
A Puppet::Parameter::Path's value is valid if it is fully qualified (or in the case of an array, if each of its elements is fully qualified). This class was previously using its own method to validate whether a path was fully qualified, which was different from the rules applied by absolute_path?. Now that we have a dedicated method for this, it is used here for consistency.
2011-08-19Consolidate test logic determining if a registered file is in the temp directoryJacob Helwig1-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> (cherry picked from commit 3aec02ba0e4bda8ba4e9fffbc6defaae4e4e2ba1)
2011-08-19Fix tests with "relative" paths on WindowsJosh Cooper1-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> (cherry picked from commit 462a95e3d077b1915a919399b846068816c84583) Conflicts: spec/unit/parser/functions/extlookup_spec.rb
2011-04-28maint: add a 'print' matcher to rspec, to inspect std{out,err}Daniel Pittman1-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>
2011-04-13maint: clean up the spec test headers in bulk.Daniel Pittman3-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.
2011-04-08maint: use FileUtil to remove files, not execDaniel Pittman1-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>
2011-03-23Merge branch '2.6.next' into nextMax Martin1-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
2011-03-15(#4884) Autorequire shared behaviors and method to silence warningsDaniel Pittman1-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
2011-03-03(#6582) Don't demand the checkout be named 'puppet'.Daniel Pittman1-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>
2011-03-03(#6582) move more helper code into methods, out of RSpec#configureDaniel Pittman1-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>
2011-03-03(#6582) add fixture helper methods to replace unit test code.Daniel Pittman1-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>
2010-09-23[#4771] Import of manifests with the same name only happens oncePaul Berry1-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.
2010-07-09Code smell: Two space indentationMarkus Roberts1-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
2010-02-17Adding tmpfile cleanup to testsLuke Kanies1-0/+10
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
2009-05-26Adding a Spec lib directory and moving tmpfile to itLuke Kanies1-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>