summaryrefslogtreecommitdiffstats
path: root/spec/integration/util
Commit message (Collapse)AuthorAgeFilesLines
* Disable spec tests for unsupported functionality on WindowsJosh Cooper2011-07-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ruby does not support creating symlinks on Windows (though Windows does support them), and since the tidy spec test is designed to reproduce a specific bug (as opposed to testing symlink functionality on Windows) it has been disabled. Ruby on Windows also does not support File.chmod, so the inspect spec test has been disabled. The general issue of File.chmod on Windows is something I know needs to be investigated. Also disabled the cron spec test as this functionality will not be supported on Windows (instead there will be task manager support). Re-enable the autoload spec tests as those now pass on Windows (this is probably due to the cacher changes recently made). The inventory ssl spec is not supported on Windows and so is disabled. However, while researching the failure, it was due to Time.now.strftime("%Z") returning "Pacific Daylight Time" on Windows, instead of "PDT" like it does on other platforms. As a result, the split method was sometimes splitting in the wrong place. As far as I can tell, the inventory code is only called from the CA (to keep track of serial numbers for certs that it has issued). But it's something to watch out for on Windows when calling strftime. Webrick, fileserver and CA functionality are not supported on Windows so these spec tests are disabled. Also fix path issue with catalog spec. Also several spec tests were creating tempfiles manually and calling system("rm -rf ..."), these have been replaced with PuppetSpec::Files.tmpdir. Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
* Maint: Fix miscellaneous testsJosh Cooper2011-07-191-2/+2
| | | | | | | | | | | | | | | | | | | | Several tests were broken due to pecularities of Windows and Ruby on Windows: * Ruby on windows does not differentiate between group and other file permissions. * All open file handles must be closed before the file can be deleted * Sometimes the current working directory (Dir.getwd) is reported as C:/foo and other times as C:\\foo, which confuses the spec tests. * Ruby's sprintf formats floating point values differently on Windows vs Unix. The Windows exponent has an extra leading zero. * Needed to stub execution of security command with the SMF service provider. Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
* Maint: Tagged spec tests that are known to fail on WindowsJosh Cooper2011-07-191-1/+1
| | | | | | | | | | | | Many spec tests fail on Windows because there are no default providers implemented for Windows yet. Several others are failing due to Puppet::Util::Cacher not working correctly, so for now the tests that are known to fail are marked with :fails_on_windows => true. To skip these tests, you can run: rspec --tag ~fails_on_windows spec Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
* (#7507) Add exclude filter for ruby 1.9 spec failuresJosh Cooper2011-05-201-2/+2
| | | | | | | Exclude spec test for multiple writer processes as this fails intermittently on ruby 1.9. Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
* (#7507) Add more filters for Ruby 1.9 spec failuresPieter van de Bruggen2011-05-171-1/+1
| | | Paired-With: Matt Robinson
* (#7507) Add ability to filter Ruby 1.9 spec failuresMatt Robinson2011-05-171-1/+1
| | | | | | | | | | | | | | | By running: rspec spec --tag ~@fails_on_ruby_1.9.2 We can now just run the specs that pass under Ruby 1.9. Obviously in the long term we want to have all the specs passing, but until then we need notification when we regress. From now on new code will be required to pass under Ruby 1.9, and Jenkins will give us email notification if it doesn't or if we break something that was already working. Reviewed-by: Daniel Pittman <daniel@puppetlabs.com>
* maint: clean up the spec test headers in bulk.Daniel Pittman2011-04-135-10/+5
| | | | | | | 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: just require 'spec_helper', thanks rspec2Daniel Pittman2011-04-085-5/+5
| | | | | | | | | | | rspec2 automatically sets a bunch of load-path stuff we were by hand, so we can just stop. As a side-effect we can now avoid a whole pile of stupid things to try and include the spec_helper.rb file... ...and then we can stop protecting spec_helper from evaluating twice, since we now require it with a consistent name. Yay. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
* maint: Change code for finding spec_helper to work with Ruby 1.9Matt Robinson2011-03-224-4/+4
| | | | | | | | | | | | | | | | | Running the specs under Ruby 1.9 didn't work using the lambda to recurse down directories to find the spec_helper. Standardizing the way to find spec_helper like the rest of specs seemed like the way to go. Here's the command line perl I used to make the change: perl -p -i -e "s/Dir.chdir.*lambda.*spec_helper.*$/require File.expand_path(File.dirname(__FILE__) + '\/..\/..\/spec_helper')/" `find spec -name "*_spec.rb"` Then I fixed the number of dots for files that weren't two levels from the spec dir and whose tests failed. Reviewed-by: Nick Lewis <nick@puppetlabs.com>
* maint: Use expand_path when requiring spec_helper or puppettestMatt Robinson2010-12-061-1/+1
| | | | | | | | | Doing a require to a relative path can cause files to be required more than once when they're required from different relative paths. If you expand the path fully, this won't happen. Ruby 1.9 also requires that you use expand_path when doing these requires. Paired-with: Jesse Wolfe
* Fix #4923 - close process race when truncating existing fileBrice Figureau2010-11-101-11/+31
| | | | | | | | | | | | | | | | | | | | | Using File.open(file, "w") calls open(2) with O_CREAT|O_TRUNC which means when the file exists it is immediately truncated. But the file is not locked yet, so another process can either write or read to the file, leading to file corruption. The fix is to truncate only when the file is exclusively locked. This can be done on some operating system with O_EXLOCK open(2) flag. I chose the more portable option of: * open * flock * truncate * write * close It might also be good to flush and fsync the file after writing it, otherwise in case of crash an incomplete file can stay on disk. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Code smell: Two space indentationMarkus Roberts2010-07-095-219/+219
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Code smell: English names for special globals rather than line-noiseMarkus Roberts2010-07-092-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replaced 36 occurances of [$][?] with $CHILD_STATUS 3 Examples: The code: print "%s finished with exit code %s\n" % [host, $?.exitstatus] becomes: print "%s finished with exit code %s\n" % [host, $CHILD_STATUS.exitstatus] The code: $stderr.puts "Could not find host for PID %s with status %s" % [pid, $?.exitstatus] becomes: $stderr.puts "Could not find host for PID %s with status %s" % [pid, $CHILD_STATUS.exitstatus] The code: unless $? == 0 becomes: unless $CHILD_STATUS == 0 * Replaced 3 occurances of [$][$] with $PID 3 Examples: The code: Process.kill(:HUP, $$) if restart_requested? becomes: Process.kill(:HUP, $PID) if restart_requested? The code: if pid == $$ becomes: if pid == $PID The code: host[:name] = "!invalid.hostname.$$$" becomes: host[:name] = "!invalid.hostname.$PID$" * Replaced 7 occurances of [$]& with $MATCH 3 Examples: The code: work.slice!(0, $&.length) becomes: work.slice!(0, $MATCH.length) The code: if $& becomes: if $MATCH The code: if $& becomes: if $MATCH * Replaced 28 occurances of [$]:(?!:) with $LOAD_PATH 3 Examples: The code: sitelibdir = $:.find { |x| x =~ /site_ruby/ } becomes: sitelibdir = $LOAD_PATH.find { |x| x =~ /site_ruby/ } The code: $:.unshift "lib" becomes: $LOAD_PATH.unshift "lib" The code: $:.shift becomes: $LOAD_PATH.shift * Replaced 3 occurances of [$]! with $ERROR_INFO 3 Examples: The code: $LOG.fatal("Problem reading #{filepath}: #{$!}") becomes: $LOG.fatal("Problem reading #{filepath}: #{$ERROR_INFO}") The code: $stderr.puts "Couldn't build man pages: " + $! becomes: $stderr.puts "Couldn't build man pages: " + $ERROR_INFO The code: $stderr.puts $!.message becomes: $stderr.puts $ERROR_INFO.message * Replaced 3 occurances of ^(.*)[$]" with \1$LOADED_FEATURES 3 Examples: The code: unless $".index 'racc/parser.rb' becomes: unless $LOADED_FEATURES.index 'racc/parser.rb' The code: $".push 'racc/parser.rb' becomes: $LOADED_FEATURES.push 'racc/parser.rb' The code: $".should be_include("tmp/myfile.rb") becomes: $LOADED_FEATURES.should be_include("tmp/myfile.rb")
* [#3994-part 2] rename integration tests to *_spec.rbMarkus Roberts2010-06-285-0/+0
| | | | | | | | | Some spec files like active_record.rb had names that would confuse the load path and get loaded instead of the intended implentation when the spec was run from the same directory as the file. Author: Matt Robinson <matt@puppetlabs.com> Date: Fri Jun 11 15:29:33 2010 -0700
* Changing the interface of Puppet::ResourceLuke Kanies2010-02-171-1/+0
| | | | | | | | We need the ability to set the namespace and environment at initialization so the resource can look up qualified types. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Renaming Parser::ResourceType to Resource::TypeLuke Kanies2010-02-171-2/+2
| | | | | | | | | | Basically, these classes (ResourceType and ResourceTypeCollection) don't really belong in Parser, so I'm moving them to the Resource namespace. This will be where anything RAL-related goes from now on, and as we migrate functionality out of Puppet::Type, it should go here. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Renaming LoadedCode to ResourceTypeCollectionLuke Kanies2010-02-171-1/+1
| | | | Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Bug #3401 Spec failed due to missing manditory setting in mockJesse Wolfe2010-03-221-2/+6
| | | | | Puppet::Util::Settings#use now requires the :noop setting to exist, and this test was not providing one in its mocked default structure.
* Fixed test error message.James Turnbull2010-01-281-1/+1
|
* Adapt to method name change since 8971d8Brice Figureau2010-01-181-0/+17
| | | | | | | | | When the definition/hostclass/node AST types were removed, the parentclass method was renamed to 'parent'. This patch fixes the incorrect rdoc usage (and some deeper integration test so that it won't happen again). Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fixing #2596 - Node, Class, Definition are not ASTLuke Kanies2009-12-091-2/+2
| | | | | | | | | | | | | | | | | This commit extracts these three classes into a single ResourceType class in the Parser heirarchy, now completely independent of the AST heirarchy. Most of the other changes are just changing the interface to the new class, which is greatly simplified over the previous classes. This opens up the possibility of drastically simplifying a lot of this other code, too -- in particular, replacing the reference to the parser with a reference to the (soon to be renamed) LoadedCode class. Signed-off-by: Luke Kanies <luke@madstop.com>
* Covers the RDoc Puppet Parser with specsBrice Figureau2009-10-241-0/+42
| | | | | | | | This doesn't cover all the code, only the part that interacts with Puppet internals which is what matters when Puppet changes. This patch also contains an integration test. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fixing #2574 - autoloading finds plugins in modulesLuke Kanies2009-09-011-0/+18
| | | | | | | | We had some stupid errors that were preventing this from happening; this fixes them and adds an integration test. Signed-off-by: Luke Kanies <luke@madstop.com>
* Removed misguided case sensitivity testsMarkus Roberts2009-08-181-12/+0
| | | | | | | | Removed two failing tests added in the process of reproducing #2493 because they enforced case-insensitivity in excess of that provided by 0.24.8 and thus contrary to user expectations. Signed-off-by: Markus Roberts <Markus@reality.com>
* Fixes #2493Markus Roberts2009-08-142-33/+50
| | | | | | | | | | | | Added downcasing into find_or_load (which replaced fqfind) to get back the old behaviour. Adjusted tests so that they would catch the problem & confirmed that they fail without the downcasing. Added tests to confirm the existance of #2493; improved existing autoload tests (removed inter-test interactions) and noted (with a TODO) that there was dead code in the feature loading test; added analogus case sensitivity tests where apropriate.
* Migrating Feature tests to specLuke Kanies2009-08-021-0/+54
| | | | | | | | | | This was to fix a failing test/unit test. Test coverage is now a bit better, more maintainable, and I refactored the code just slightly to make it a bit cleaner. Signed-off-by: Luke Kanies <luke@madstop.com>
* Ruby no longer clobbers puppet autoloadingLuke Kanies2009-07-161-0/+91
| | | | | | | | | We basically just make sure that we tell Ruby about files we've loaded, so you can 'require' these files and doing so will essentially no-op, rather than clobbering the already-loaded code. Signed-off-by: Luke Kanies <luke@madstop.com>
* Adding a Spec lib directory and moving tmpfile to itLuke Kanies2009-05-261-6/+3
| | | | | | | | | | | | | | 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>
* Fix failing test: file.close! and file.path ordering fixBrice Figureau2009-05-151-1/+2
| | | | | | | | | | | On ruby 1.8.7 file.close! nils the internal file path. So the following pattern: file = temp file.close! file = file.path doesn't work. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Merge commit 'masterzen/tickets/1834'Luke Kanies2008-12-301-1/+2
|\
| * Fix #1834 part1 - Fix tempfile failing testsBrice Figureau2008-12-201-1/+2
| | | | | | | | Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* | Merge branch '0.24.x'James Turnbull2008-12-271-0/+36
|\ \ | |/ |/| | | | | Conflicts: CHANGELOG
| * Not using a temporary file when locking files for writing.Luke Kanies2008-12-151-3/+3
| | | | | | | | | | | | | | | | | | | | The temporary file was not actually useful, because we could never really get atomic renames, for annoying, complicated reasons. This hopefully finally fixes #1812. Signed-off-by: Luke Kanies <luke@madstop.com>
| * Modifying the corruption-checking test.Luke Kanies2008-12-151-3/+3
| | | | | | | | | | | | | | | | | | It is now more likely to fail if there's a problem, since the yaml should be corrupt, causing a yaml failure. Also removing the equivalent test from the Storage module. Signed-off-by: Luke Kanies <luke@madstop.com>
| * Preparing to fix #1812 - Moving locking code to a moduleLuke Kanies2008-12-121-0/+36
| | | | | | | This moves the locking code out of Puppet::Util into a separate module, to make the code cleaner. Signed-off-by: Luke Kanies <luke@madstop.com>
* Refactoring the Settings class to use Puppet::ResourceLuke Kanies2008-12-181-0/+29
It also now uses the Catalog instead of the recursive TransObject stuff. Signed-off-by: Luke Kanies <luke@madstop.com>