Age | Commit message (Collapse) | Author | Files | Lines |
|
This adds a deprecation warning to operations that mutates array
and hash - i.e. $a = [1,2,4] $a[3] = 5, and equivalent for hash.
The warning message has a URL that leads to PUP-864.
Existing tests that test that mutation is possible now also checks
that a warning is issued.
|
|
It should naturally have produced false. The test for "having value" was
wrong and equated nil with false.
|
|
Make sure we get ParseErrors that contain "not a hash or array" so it's
clear what has happened.
|
|
|
|
Without this patch Ruby 1.9 is still complaining loudly about trying to
parse the spec files. The previous attempt to clean up this problem in
edc3ddf works for Ruby 1.8 but not 1.9.
I'd prefer to remove the shebang lines entirely, but doing so will cause
encoding errors in Ruby 1.9. This patch strives for a happy middle
ground of convincing Ruby it is actually working with Ruby while not
confusing it to think it should exec() to rspec.
This patch is the result of the following command run against the source
tree:
find spec -type f -print0 | \
xargs -0 perl -pl -i -e 's,^\#\!\s?/(.*)rspec,\#! /usr/bin/env ruby,'
|
|
This eliminates a to_s that duplicates the parent class.
It also avoids depending on matching a regular expression object against a
regular expression object - something that apparently works, but I can only
imagine does so by pure accident.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
A string that contained an embedded double-quote wouldn't be correctly escaped
when the AST rendered the node to a flat string - it quoted around the
outside, but didn't escape the content.
This fixes that, and adds testing that embedded double-quotes are correctly
handled on output.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
Now that the compiler is always required by the scope we can save a few
keystrokes by making the non-optional argument a regular value, not a name
prefixed option.
(...even if I love Objective-C as much as the next developer, having the same
text in every call just to name the argument doesn't make much sense in such
an internal context.)
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
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>
|
|
* 2.7.x:
Revert "Fix incorrect argument handling for expire in NodeExpirer"
Fix #14123 for Windows
Fix incorrect argument handling for expire in NodeExpirer
Fix filebucket specs on Windows
(#8778) Make '' == undef commutative in the DSL
(#14173) Enforce that filebucket paths must be absolute
(#14127) Add integration tests for ssh_authorized_key
maint: refactor integration specs for ssh_authorized_key
(#14127) ssh_authorized_keys grammer fails on blank lines.
(#14123) Puppet shouldn't explode if PATH contains ~nonexistent_user
Conflicts:
lib/puppet/provider/ssh_authorized_key/parsed.rb
lib/puppet/util.rb
|
|
Without this patch applied the Puppet DSL treats undef == '' as true
but '' == undef as false. This is undesirable because the equality
operator should be commutative.
This patch fixes the problem by adding an explicit check for '' == undef
in the AST. Without this patch applied, Puppet already has an explicit
check for undef == '' but not for '' == undef.
The spec tests are also updated by this patch to reflect the change.
|
|
Conflicts:
lib/puppet/daemon.rb
spec/unit/daemon_spec.rb
spec/unit/parser/ast/leaf_spec.rb
spec/unit/provider/package/dpkg_spec.rb
spec/unit/util/settings_spec.rb
|
|
As part of commit 53869e99 we did work to make the behaviour of variables that
were explicitly `undef` at least somewhat saner.
One unintended side-effect of this was that we started matching `undef` as the
literal string `undef`, not as the empty string, and not "not matching".
Either of the later would have been sane things to do; this fixes that by
picking "match undef as empty string".
That is for consistency: we already match the *literal* empty string as equal
to undef, so it makes sense to treat it the same way for a regular expression.
(Debate on that point is welcome elsewhere, but we should change literal and
regexp matching the same, consistent way if we change it anywhere.)
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
|
|
The truethiness test done in P::P::Scope.true? doesn't handle nil
values, because it is not valid as result of a puppet expression.
Unfortunately ruby hash['invalid'] or array[inexistant_index] returns
nil which then was considered as true in an if expression.
This patch makes sure :undef is returned in those cases.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
|
|
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>
|
|
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.
|
|
This fix implements the same logic as Nick & Paul's patch in a different way.
There aren't any tests yet and I'm still working out if I agree with the
handling of some edge cases, so this should be considered premliminary.
|
|
This patch adds an options hash to lookupvar analogous to the one taken by
setvar and uses it to pass in source location for error reporting. It also
fixes the mechanism used by setvar (file was not being passed correctly), adds
line and file information to errors in templates, and extends/corrects tests.
As presently written it does not gather userful line numbers from inline
templates and there are no tests for the template line number generation.
|
|
The usestring parameter to lookupvar was objectionable for several reasons;
first, it performed a function orthogonal to the main purpose of the method,
second its default was the least common value, and third it was causing other
code to work for reasons that were not obvious (extlookup).
This refactor breaks the value-transforming function out into a seperate
method which allows the user to specify the value to be used in lieu of :undef
and removes the parameter. The function, Scope#undef_as(default,exp) is
written so that it can be used in user code (templates, functions, etc.) if
needed.
This refactor will introduce a user-visible behaviour change in the case where
users were counting on lookupvar to return "" for undefined variables. The
best solution is to have them use undef_as, replacing:
lookupvar('myvar')
with
undef_as('',lookupvar('myvar'))
(with the option to specify another default value if desired). If this is too
objectionable, we could rename the existing lookupvar as raw_lookupvar and
define
def lookupvar(v)
undef_as('',raw_lookupvar(v))
end
to restore the present behaviour.
|
|
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>
|
|
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
|
|
|
|
Accesing an array with an integer index (ie $array[1]) is producing
a ruby error: can't convert String into Integer
This is because the array index is not properly converted to an number
before the array element lookup is performed.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
|
|
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
|
|
This fixes double-quoted strings to interpolate undef variables
as an empty string. This is the behavior present in 0.25.x.
|
|
Ticket #4238 introduced a problem that a function couldn't compare to
another value until after it was evaluated, and AST::Function didn't have the
evaluate_match method. This change moves that method from AST::Leaf to AST.
The special casing necessary for doing comparisons between AST objects
feels messy and could probably be encapsulated better. I've created
ticket #4291 to remind us to refactor this at some point.
Paired with: Nick Lewis
Signed-off-by: Matt Robinson <matt@puppetlabs.com>
|
|
The comparisons operator (and more particularly == and !=) were not treating
the undef value as '', like case and selector did since #2818.
This patch makes sure comparison operator uses AST leaf matching.
Unfortunately, doing this introduces a behavior change compared to
the previous versions:
Numbers embedded in strings will now be matched as numbers in case and
selector statements instead of string matching.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
|
|
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
|
|
Part 2 re-did the change on the spec files, which it shouldn't have.
|
|
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
|
|
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
|