Jeff McCune [Thu, 19 Jul 2012 23:14:37 +0000 (16:14 -0700)]
(Maint) use PuppetlabsSpec::PuppetSeams.parser_scope
Without this patch all of the spec tests for parser functions in stdlib
would instantiate their own scope instances. This is a problem because
the standard library is tightly coupled with the internal behavior of
Puppet. Tight coupling like this creates failures when we change the
internal behavior of Puppet. This is exactly what happened recently
when we changed the method signature for the initializer of
Puppet::Parser::Scope instances.
This patch fixes the problem by creating scope instances using the
puppet labs spec helper. The specific method that provides scope
instances in Puppet-version-independent way is something like this:
Jeff McCune [Fri, 11 May 2012 05:01:40 +0000 (22:01 -0700)]
Fix spec tests using the new spec_helper
This patch back ports the file from the master branch. The spec tests
fail without this patch applied. This should make it easier to setup
Puppet settings using the puppet_spec_helper project.
Jeff McCune [Fri, 30 Mar 2012 06:04:12 +0000 (23:04 -0700)]
(#13439) Fix MRI 1.9 issue with spec_helper
When using MRI 1.9.x the stdlib spec helper does not invoke because
Puppet.settings.private_methods returns symbols instead of strings.
This is a problem because we need to set default configuration settings
like Puppet[:vardir] when using the compiler.
This patch fixes the issue by simply checking the Puppet version. This
seems a better choice than rescuing NoMethodError since the method might
be renamed or removed in the future.
Jeff McCune [Thu, 29 Mar 2012 23:52:15 +0000 (16:52 -0700)]
(#13439) Fix test failures with Puppet 2.6.x
Without this patch the spec_helper sends a message named
initialize_everything_for_tests to Puppet.settings. This is a problem
because Puppet 2.6.x does not have this method, only Puppet 2.7.x and
Puppet master have this method at this time and we're getting false
positive test failures.
This patch fixes the problem by looking before we leap. We test if the
private method exists before calling it. This works with Ruby 1.8.5 and
onwards and Puppet 2.6, 2.7 and master.
This should fix all of the failures I've caused in Jenkins today.
Jeff McCune [Thu, 29 Mar 2012 22:12:06 +0000 (15:12 -0700)]
(#13494) Specify the behavior of zero padded strings
Without this patch the specified behavior of strings that are numeric
only and zero padded is unclear and untested in the spec tests. This is
a problem because it's not clear that range('00', '10') will actually
return [ "0", "1", ..., "10" ] instead of [ "00", "01", ..., "10" ]
This patch addresses the issue by providing explicit test coverage. If
the string conversion behavior of puppet changes, this test will begin
to fail.
Jeff McCune [Mon, 6 Feb 2012 05:22:27 +0000 (21:22 -0800)]
(#12377) Avoid infinite loop when retrying require json
Without this patch an infinite loop will be entered if the json and
rubygems libraries are not available.
This patch fixes the problem by retrying the `require 'json'` only if
rubygems was successfully loaded for the first time. Subsequent
attempts to load rubygems will cause the LoadError exception from a
missing json library to be re-raised.
Thanks to Krzysztof Wilczynski for pointing out this issue.
Jeff McCune [Thu, 12 Jan 2012 03:15:04 +0000 (19:15 -0800)]
Add additional domain name tests
Without this patch some valid domain names are not covered in the spec
tests as Stig Sandbeck Mathisen <ssm@debian.org> points out. This patch
adds spec tests for the domains "." and "x.com" which are both valid.
Jeff McCune [Thu, 12 Jan 2012 02:55:21 +0000 (18:55 -0800)]
(maint) Memoize scope in domain_name spec
This is an opportunity improvement since I'm in the code. Get rid of
instance variables in the spec test and replace them with a memo let
method block.
Jeff McCune [Thu, 12 Jan 2012 01:39:15 +0000 (17:39 -0800)]
(#11901) Fix sort order error in tests for 'keys' and 'values'
Between Ruby 1.8.7 p352 and p357 the way arrays were returned when using
keys and values in Ruby changed, and due to assumption about the
ordering our tests are now failing.
This patch fixes the issue by using the =~ operator matcher in rspec.
This matcher is implemented as RSpec::Matchers::MatchArray and performs
multiset equality matching of arrays. Order doesn't matter, but
duplicate values do.
This patch also switches @scope instance variables to memoized let
methods for clarity in the code.
Original Author: Ken Barber Reviewed-by: Nick Lewis
This commit closes GH-29
Ken Barber [Tue, 10 Jan 2012 18:58:07 +0000 (18:58 +0000)]
(#11873) time function spec failure on Fixnum matcher
The rspec code for the time function was trying to match the type to be a
'Fixnum'. Ruby will sometimes make this a 'Bignum' depending on its internals
and we can't rely on this to be true all the time.
This patch just makes sure the type is an integer instead.
Jeff McCune [Fri, 30 Dec 2011 23:45:00 +0000 (15:45 -0800)]
(#11607) Add Rakefile to enable spec testing
Without this patch the 2.1.x branch does not have a Rakefile like the
2.2.x and master branches do. This is a problem for the continuous
integration testing since it executes `rake test` against 2.1.x, 2.2.x
and master currently.
This patch fixes the problem by copying the Rakefile into place enabling
the `rake test` task.
Jeff McCune [Fri, 30 Dec 2011 19:48:21 +0000 (11:48 -0800)]
Merge branch 'v2.1.x' into v2.2.x
* v2.1.x:
(maint) Add semantic versioning info to README
Docs: Clarify the use case for the anchor type
Docs: Remove author emails from stdlib functions
Docs: Copyedit function doc strings
Docs: Correct indentation of markdown code examples
Docs: Update documentation of stdlib classes
Docs: Update file_line documentation
Docs: Improve example in merge function
Jeff McCune [Fri, 30 Dec 2011 19:46:21 +0000 (11:46 -0800)]
(maint) Add semantic versioning info to README
This patch adds semantic versioning information to the README of this
module. This information is missing and unclear without this patch.
This should help clarify the support matrix for the Standard Library as
it relates to Puppet Enterprise released versions.
Jeff McCune [Mon, 10 Oct 2011 18:58:48 +0000 (11:58 -0700)]
(Maint) Make rspec tests work with Puppet 2.6.4
The behavior without this patch applied is that the rspec tests do not
function with Puppet 2.6.4. This patch back-ports some fixes introduced
in Puppet 2.7.x to the spec_helper to make the tests work as expected on
Puppet 2.6.4.
The specific patches back ported from Puppet are:
* 2ae88067 (Puppet::Util::ExecutionStub.reset)
* cf183534 (Switched spec tests to use a class rather than Array as the
log destination.)
Jeff McCune [Mon, 3 Oct 2011 18:51:05 +0000 (11:51 -0700)]
(#9859) Add root_home fact and tests
Without this patch applied, the stdlib module does not provide a
root_home fact. This fact is necessary to easily determine the root
account home directory on platforms Puppet is supported on.
The major variations this fact address are:
---
solaris: /
linux: /root
macosx: /var/root
Spec tests using rspec have been provided as well to cover these three
general cases. Windows tests are marked as pending.
nfagerlund [Wed, 17 Aug 2011 22:55:07 +0000 (15:55 -0700)]
Docs: Remove author emails from stdlib functions
Author email addresses were included in the doc strings for some (but not all)
stdlib functions. This commit removes them in the interest of consistency.
nfagerlund [Wed, 17 Aug 2011 22:20:26 +0000 (15:20 -0700)]
Docs: Correct indentation of markdown code examples
Code examples in several function doc strings were only indented by two
spaces, which would not result in proper display when rendered as HTML. This
commit corrects the indentation to four spaces.
Jeff McCune [Tue, 16 Aug 2011 22:57:47 +0000 (15:57 -0700)]
Docs: Improve example in merge function
This commit replaces the example in the merge function with a much clearer
one. It also mentions that the rightmost value wins in the event of duplicated
hash keys.
Jeff McCune [Thu, 18 Aug 2011 17:44:40 +0000 (10:44 -0700)]
(#9080) Make facts.d match Facter 2.0
Based on feedback from Luke, the facts.d directory should at least match
the directory that will be used by Facter 2.0.
Reading #2157 I believe the Facter 2.0 facts.d feature is reasonably API
compatible with this custom fact from R.I. so I'm comfortable using the
same filesystem path.
Change in behavior: Now look for facts in:
* /etc/facter/facts.d
* /etc/puppetlabs/facter/facts.d
The mcollectivepe module relies on these facts being set and we need a
persistent place to write them during the interview process and later
read them when puppet agent runs to configure MCollective on the agent
systems.
Since stdlib is a public module, both /etc/facts.d and
/etc/puppetlabs/facts.d are scanned for static facts.
Reviewed-by: Jeff McCune
Verified all spec tests pass using rspec **/*_spec.rb
* issue/master/8797_puppetlabs-functions_merge: (164 commits)
* Moved kwalify to puppetlabs-kwalify project * Re-arranged tests in line with puppetlabs-stdlib
Prep for stdlib merge * Renamed load_yaml & load_json to parseyaml & parsejson * Renamed is_valid_* functions and remove the 'valid_'
Fix some ruby 1.9.2 issues.
(#3) Provide documentation for remaining functions.
(#3) Apply missing documentation to more functions.
Remove rand.
Some improvements to values_at tests.
(#1) provide some more detailed tests for a number of functions.
Removed date stub since this functinality is available in strftime anyway.
(#2) fix is_string finally so it also makes sure numbers return false.
(#2) unstub is_valid_domain_name
Added doc strings for first five functions
Removed join_with_prefix.
(#2) unstub is_valid_mac_address.
Allow sort for strings.
Count functionality overlaps with size - so removing it.
Removed crontab functions instead of unstubbing them.
Removed load_variables. load_yaml is sufficient to solve this problem on its own.
Remove is_valid_netmask instead of unstubbing. Doesn't seem like a sensible function on its own.
(#2) unstub is_numeric function.
...
Jeff McCune [Mon, 8 Aug 2011 16:33:56 +0000 (09:33 -0700)]
(#8792) Rename basic smoke test to reflect file_line rename
Without this patch the basic smoke test in the module tests/ directory
did not math up with the renamed whole_line => file_line resource type.
This patch updates the smoke test file to match the most recently
selected name of file_line. The filename has been changed, comments
added to the smoke test file, and resource declarations inside the file
changed.
Ken Barber [Fri, 5 Aug 2011 07:52:00 +0000 (08:52 +0100)]
(#8797) Merge puppetlabs-functions into puppetlabs-stdlib
It was decided that maintaining puppetlabs-functions and
puppetlabs-stdlib was duplication as both are trying to
achieve the same goal.
This patch provides a merge of the puppetlabs-functions
into the puppetlabs-stdlib repository, with history
preservation.
The following conflicts were found and resolved:
* LICENSE file from functions was used as it aligns with
ASL usage instructions and contains relevant copyright
information:
http://www.apache.org/licenses/LICENSE-2.0.html
* Used spec_helper.rb from functions - this is what
Puppet core uses and doesn't break tests.
* Merged .gitignore and spec.opts options.
Jeff McCune [Fri, 5 Aug 2011 02:17:48 +0000 (19:17 -0700)]
(#8792) Rename whole_line type to file_line
Without this patch the resource whole_line would be included in the
stable stdlib module shipping in PE 1.2. Ideally the name will be
stable and unchanging in the future.
There was quite a bit of concern over whole_line being an unwise name.
file_line appears to be the most suitable name and least likely to need
another rename in the future.