summaryrefslogtreecommitdiff
path: root/spec/unit/parser/functions
AgeCommit message (Collapse)AuthorFilesLines
2012-07-15A scope always has a compiler.Daniel Pittman17-26/+52
The scope object contained some internal code to substitute an external environment when the compiler was not supplied. This was used only in testing, not in any production capacity. In light of that, we can eliminate the dynamic decision making inside the scope and simply demand that a compiler instance (or a fake equivalent) is always supplied. This reduces the complexity of the code and makes clearer the object relationships involved. (The small cost is a lot of testing that depended on this had to change to use a real compiler. Most of the change derives from that.) Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-07-11Merge commit 'ecc52ed' into 3.0rcPatrick Carlisle1-6/+6
* commit 'ecc52ed': (33 commits) (#11868) Use `Installer` automation interface to query package state Eliminate require calls at runtime. Fix broken TransBucket transformation tests. Fix broken ability to remove resources from the catalog. Fix type check when transforming catalog. Fix all trivial "should to must" errors in our tests. Enforce "must not should" on Puppet::Type instances in tests. Initialize resources strictly in backup specs Refactor file backup specs (maint) Add tags to .gitingore Use in memory sqlite database for unit tests (#14715) Use gtar with 'puppet module install' on Solaris Stub pkginfo when installing in openbsd spec (#14962) PMT doesn't support setting a relative modulepath (#15078) Document USR2 log rotation signal (#14909) Update createpackage.sh to resolve permissions issues (maint) Add --test to puppet run (maint) Add symlink stub to gentoo service provider spec Add comment to upstart provider explaining exclusion of 'wait-for-state' Upstart code cleanup, init provider improvement ... Conflicts: lib/puppet/face/module/install.rb lib/puppet/network/handler/fileserver.rb lib/puppet/parser/functions/fqdn_rand.rb lib/puppet/parser/type_loader.rb lib/puppet/ssl/base.rb lib/puppet/util.rb lib/puppet/util/autoload.rb man/man8/puppetmasterd.8 spec/lib/puppet_spec/database.rb spec/unit/face/module/install_spec.rb spec/unit/other/transbucket_spec.rb spec/unit/provider/augeas/augeas_spec.rb spec/unit/util/backups_spec.rb spec/unit/util_spec.rb
2012-07-10Fix all trivial "should to must" errors in our tests.Daniel Pittman1-6/+6
We had a bunch of places that used the wrong invocation to test something on a resource instance, revealed by the previous change. This fixes all the trivial instances - the places that are *correct* despite not actually being tested for a long while. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-07-02(maint) Standardize on /usr/bin/env ruby -S rspecJeff McCune18-18/+18
Without this patch some spec files are using `ruby -S rspec` and others are using `rspec`. We should standardize on a single form of the interpreter used for spec files. `ruby -S rspec` is the best choice because it correctly informs editors such as Vim with Syntastic that the file is a Ruby file rather than an Rspec file.
2012-04-18Accept paths with `~` for `generate` on Windows.Daniel Pittman1-0/+6
The `generate` function has a fairly strict definition of what is and isn't legal as a command name, in an effort to keep it reasonably sanitary. On Windows this included `.`, `-`, and any alpha-numeric characters, but not the `~` character. This blew up when faced with an "8.3" generated path - something that we legitimately should accept since it can reduce problems around spaces in path names. This changes generate to accept that, and adds a specific test to verify that it continues to work as expected. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-04-18Make a path absolute on Windows as well as Unix.Daniel Pittman1-1/+1
When this test was changed the path became relative on Windows, because it doesn't have a drive letter. This fixes that with `make_absolute`. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-04-16Fixed problems caused by 2.7.x mergeAndrew Parker1-1/+1
Several things had changed on master that caused the automatic merge to not catch problems.
2012-04-16Re-apply "Merge remote-tracking branch 'upstream/2.7.x'"Andrew Parker1-84/+116
This reverts commit 6d399e087372b77566dd3737d4b444aca2e61050.
2012-04-16Revert "Merge remote-tracking branch 'upstream/2.7.x'"Andrew Parker1-116/+84
This reverts commit 7a430815424e053d6e6c5925eef711ca5edd8373, reversing changes made to 32172d5d8de35f5cdbc31bce327b3567e078bb83.
2012-04-16Merge remote-tracking branch 'upstream/2.7.x'Andrew Parker1-84/+116
* 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-4/+2
Created a PuppetSpec::Compiler module for helping out testing things that want to compile some code to a catalog
2012-04-16Cleaner test for create_resources doing nothingAndrew Parker1-2/+3
Better expresses that a create_resources with an empty hash is the same as doing nothing in the catalog at all
2012-04-13Fixing problem caused by activerecordAndrew Parker1-84/+117
ActiveRecord installed a parent() method that seems to have wreaked havoc on the inheritance traversing code in the variable lookup code. This uses a new method that achieves the same end, but doesn't rely as much on the duck typing (responds to :parent) of the resource. In addition tests have been added for node inheritance to ensure that that inheritance heirarchy is followed as we expect. Also tests that tried to fake out things and now have incorrect assumptions have been changed to make fewer assumptions about how the system works.
2012-04-11(Maint) Allow '+' to appear in generate function commandsJosh Cooper1-0/+6
Previously, the posix regex for validating generate function commands did not allow '+', however, this character appears in `Tempfile`s on Mac. This commit relaxes the regex to allow for '+' and adds a test for it. The '-' character was already allowed. Reviewed-by: Daniel Pittman <daniel@rimspace.net>
2012-04-10Merge branch '2.7.x'Patrick Carlisle1-10/+2
* 2.7.x: (maint) Remove unnecessary step from puppet module build help (#13659) Convert fact values to string when searching database (#13649) Restrict module name matching (#13643) Make the use of FileUtils.rm_rf secure (#13642) Move search notice message (#13639) Don't send errors directly to stderr (#13638) Add SemVer#pre function (#3581) Stop forking around: Add fork helper method (#13397) fix gem provider ensure=>latest bug (#12101) Make Puppet::Util::absolute_path? usable in autoloader (#12101) Add shared context for specs to imitate windows or posix Conflicts: lib/puppet/util.rb spec/unit/util_spec.rb
2012-04-09Merge pull request #611 from pcarlisle/ticket/2.7.x/12101-reapply-autoloadDaniel Pittman1-10/+2
Ticket/2.7.x/12101 reapply autoload
2012-04-09Merge branch '2.7.x'Patrick Carlisle1-0/+14
* 2.7.x: (#9167) Do not send email when nothing changes [#13686] Fix directoryservices ShadowHashData code Fixup tests to work on CentOS 5 fix bug in Util#symbolizehash! (#13567) Fix create_resources name parameter bug (#13636) Update Module Face copyright date (#13737) Swap build_tree and format_tree method names (#9167) Do not send email when nothing changes Add Module Tool Make core changes needed for the puppet module tool (#13367) Patch SemVer to permit ranges including pre-release components. Monkey patch FileUtils.mv in Ruby 1.8.5 (#1076) Show warning if an empty group is specified Maint: Remove unused mock objects in user spec Maint: Use real objects in user spec Maint: Add a real provider class to user spec Maint: Remove unused variable in user spec Conflicts: lib/puppet/util/monkey_patches.rb spec/unit/type/resources_spec.rb spec/unit/type/user_spec.rb
2012-04-06Merge pull request #535 from ↵Chris Price1-0/+12
eshamow/tickets/master/7801_include_should_accept_arrays (#7801) Modify include function to accept arrays
2012-04-05(#7801) Modify include function to accept arraysEric Shamow1-0/+12
When an array of classes is passed to the :include function, it currently attempts to wrap the array in another array, and then pass the entire array through as a single argument, causing an error. This commit calls flatten against the array before sending it through, following the pattern of :realize, and enabling arrays to be passed as well as comma-separated or individual class values.
2012-04-05(#13567) Fix create_resources name parameter bugReid Vandewiele1-0/+14
Previously, the create_resources function would inconsistently override name parameters provided by the user, setting the name parameter equal to the resource title. This commit modifies create_resources such that when provided, user-supplied name parameters are used correctly and consistently. Add name parameter tests for create_resources.
2012-03-30Port old `test/language` tests into rspec...Daniel Pittman6-1/+176
In Ruby 1.9 the Test::Unit library was replaced by MiniTest. This changes some "esoteric" parts of the code, sadly including the parts of the library we depend on to confine certain tests to only some systems. Instead of investing heavily in rebuilding that facility over the new MiniTest library it makes sense to just check for and either destroy or port the old tests to the new rspec harness. This is our desired future - that only one test framework exist - and we might as well take full advantage of this opportunity to clean up our legacy code. It also drops tests that duplicate testing already present in the spec suite. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-03-30Remove the "fails_on_ruby_1.9.2" tag from tests...Daniel Pittman1-1/+1
Now we have passing tests on Ruby 1.9, we can make all those tags go away and enable the full suite. Now anything that fails should be treated like a real failure, which is reasonable since this is a real and supported platform. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-03-30Whitespace and formatting cleanup on shellquote spec.Daniel Pittman1-39/+25
The formatting in the spec file was very odd, with extraneous and random whitespace around arguments, odd line breaks, and so forth. It also used a whole pile of temporary variables that it didn't need to. This cleans that up, without making any functional changes to the code. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-03-30Calling map on string now fails, rather than yielding the string.Daniel Pittman2-13/+11
In Ruby 1.8 `"foo".map` would yield "foo" once, while in Ruby 1.9 it is not defined as a method. Various parts of our testing code stub other methods and return strings where arrays of strings are appropriate; this historically worked because of that 1.8 shim, and no longer does. The same is true of `String#each`, which fails in the same way. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-03-28(#12101) Add shared context for specs to imitate windows or posixPatrick Carlisle1-10/+2
Add "windows" and "posix" shared contexts to rspec. If you give :as_platform => :posix or :as_platform => :windows as argument to a describe block, it will automatically stub the relevant facts and path behavior to imitate windows or posix.
2012-03-09Merge remote-tracking branch 'origin/2.7.x'Daniel Pittman1-13/+16
Conflicts: spec/unit/parser/functions/create_resources_spec.rb spec/unit/resource_spec.rb Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-03-08Clean up the "foo" name in create_resources_spec.Daniel Pittman1-13/+16
Using a common meta-name like "foo" in testing runs a risk that global state will lead down the path to things going wrong. In this case, it clashed with a type created elsewhere that lingered... Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-01-24Revert "(#12101) Add shared context for specs to imitate windows or posix"Patrick Carlisle1-2/+10
This reverts commit edc544d73bc8f9f7de07de4b30e344d1f4db3178. This doesn't work with rspec < 2.6.0 and it's breaking continuous integration.
2012-01-24(#12101) Add shared context for specs to imitate windows or posixPatrick Carlisle1-10/+2
Add "windows" and "posix" shared contexts to rspec. If you give :as_platform => :posix or :as_platform => :windows as argument to a describe block, it will automatically stub the relevant facts and path behavior to imitate windows or posix.
2012-01-23Merge branch '2.7.x'Daniel Pittman1-18/+60
Conflicts: acceptance/tests/ticket_3360_allow_duplicate_csr_with_option_set.rb Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-01-20(#11930) Add validation of Windows paths in the generate functionJosh Cooper1-18/+60
The generate function did not handle Windows style paths when validating that it was fully qualified or that it only contained alphanumerics, file separators, or dashes, as Windows paths can also contain '\', as well as ':', but only when it is part of the drive specifier.
2011-12-16Merge branch '2.7.x'Nick Lewis1-4/+21
2011-12-07(#9768) Add a defaults argument to create_resourcesMatthias Pigulla1-2/+19
Make it possible to supply defaults when calling create_resources using an optional hash argument. Signed-off-by: Andre Nathan <andre@digirati.com.br> Signed-off-by: Patrick Carlisle <patrick@puppetlabs.com>
2011-12-06(#6830) Fix create_resources spec for ruby 1.9Patrick Carlisle1-2/+2
These tests broke because of changed behavior in Array#to_s, which exposed a bug if add_class is passed an array instead of *args.
2011-08-19Maint: Fix miscellaneous testsJosh Cooper1-1/+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> (cherry picked from commit 0e4ae653c0628cb0df9ccace98bca4bc7478fb7c)
2011-08-19Fix tests with "relative" paths on WindowsJosh Cooper1-3/+6
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-07-19Maint: Fix miscellaneous testsJosh Cooper1-1/+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>
2011-07-19Fix tests with "relative" paths on WindowsJosh Cooper1-3/+6
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>
2011-07-15Fixing a failing test because of mismatched error stringLuke Kanies1-1/+1
Signed-off-by: Luke Kanies <luke@puppetlabs.com> Reviewed-by: Nick Lewis <nick@puppetlabs.com>
2011-07-15Adding []/[]= support to ScopeLuke Kanies2-15/+7
The interface to scope is much clearer this way anyway, but this is needed to integrate Puppet with Hiera[1]. It just provides hash-like behavior to Scope, which Hiera and others can now easily rely on. I also went through all of the code that used Scope#lookupvar and Scope#setvar and changed it if possible, and at the same time cleaned up a lot of tests that were unnecessarily stubbing (and thus making it difficult to tell if I had actually broken anything). 1 - https://github.com/ripienaar/hiera Signed-off-by: Luke Kanies <luke@puppetlabs.com> Reviewed-by: Nick Lewis <nick@puppetlabs.com>
2011-05-17(#7507) Add ability to filter Ruby 1.9 spec failuresMatt Robinson4-7/+7
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>
2011-04-13maint: clean up the spec test headers in bulk.Daniel Pittman15-30/+15
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-12Fix for #5063 -- explicitly scope internal variable lookupsMarkus Roberts2-15/+15
When we lookup a global variable / fact from code we should explicitly look in the global scope.
2011-04-08maint: just require 'spec_helper', thanks rspec2Daniel Pittman16-16/+16
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>
2011-04-06(5200) -- replace containers with sentinalsMarkus Roberts1-17/+19
This commit removes the last remaining use of topsort (in SimpleGraph#splice!) by fixing #5200 in a way that is compatible with graph fontiers. Instead of replacing containers with many-to-many relationships, we now replace them with a pair of sentinals (whits) that bracket them. Thus a graph consisting of two containers, each containing ten resources, and a dependency between the containers, which would have gone from 21 edges to 100 edges will instead have only 43, and a graph consisting of two containers (e.g. stages) each containing a similar graph, which would have gone from 45 edges to 400 will only go to 95. This change had minor consequences on many parts of the system and required lots of small changes for consistancy, but the core of it is in Catelog#splice! (which replaces SimpleGraph#splice!) and Transaction#eval_generate. Everything else is just adjustments to the fact that some one-step edges are now two-step edges and tests, event propagation, etc. need to reflect that. Paired-with: Jesse Wolfe
2011-03-29Merge branch 'feature/2.6.next/5909' of https://github.com/bodepd/puppet ↵Jesse Wolfe1-0/+135
into next
2011-03-16(#6722) load all functions before testing...Daniel Pittman15-4/+47
We historically had a state-dependency across tests in the parser function support area; the first test caused the function to be loaded, and other tests would then fail as a consequence of that. We now autoload all functions at the top of each test suite, allowing us to correctly and sensibly test on them as we should. This theoretically prevents us from testing the autoloader implicitly in these tests, but that should be tested independently. Paired-With: Nick Lewis <nick@puppetlabs.com>
2011-03-16(5909) Function to dyncamically generate resources.Dan Bode1-0/+135
This function allows you to dynamically generate resources, passing them as a hash to the create_resources function. This was originally written to be used together with an ENC. Resources can be programitally generated as yaml and passed to a class. classes: webserver::instances: instances: instance1: foo: bar instance2: foo: blah Then puppet code can consume the hash parameters and convert then into resources class webserver::instances ( $instances = {} ) { create_resources('webserver::instance', $instances) } Now I can dynamically determine how webserver instances are deployed to nodes by updating the YAML files.
2010-12-06maint: Use expand_path when requiring spec_helper or puppettestMatt Robinson15-15/+15
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
2010-08-03[#4370] Fixes extlookup precedence getting overwritten between runsMatt Robinson1-3/+13
We found the gsub! in extlookup was actually modifying the value for extlookup_precedence, so the next node to call it just got the interpolated value from the first run. We did two things in the code to prevent this: 1. We returned a dup of the ast string object so that modifying it wouldn’t change puppet’s state. We didn’t do this for all possible return values because we depend on using the original ast array object to do array concatenation 2. We fixed extlookup to not do a destructive gsub Reviewed by: Jesse Wolfe