Age | Commit message (Collapse) | Author | Files | Lines |
|
snippets
In the puppet 4.0 parser, the file resource's mode property will be
required to be a string containing an octal (or symbolic) representation
of mode.
For consistency then, this commit changes all cases where mode was
specified as a Numeric to be a string containing an octal representation
of mode (always prefaced with a 0, again for clarity and consistency).
|
|
The resource_expressions_spec contained a useful way of writing language
specification tests. This extracts those out so that they can be reused
in other places.
|
|
I believe most of these predated our clearing the settings before each
test in the central puppet/test/test_helper.rb. And since we then set
some base settings (such as :environment_timeout) in the test_helper,
the effect of a secondary clear in the test itself is to wipe out the
baseline setup test_helper just laid down.
In particular this is a problem with environment_timeout, as it leads to
tests which end up creating environments, getting them cached with the
default 180s timeout, which can leak to subsequent tests and create
unpleasant spec order issues.
|
|
Previously this spec's tests were a shared_example that had been shared
between runs with parser=current and parser=future. The future compiler
tests were moved out into
spec/integration/parser/future_compiler_spec.rb in 7a6a7d8. This maint
fix just removes the unused rspec construction of shared_examples_for
from around the specs in parser/compiler_spec, since they are only being
run against the current parser now.
|
|
The other test added for checking the tagging behavior used the resource
matcher but the current compiler spec didn't. This updates it to be
consistent with the future compiler spec and use the matcher.
|
|
This overrides the tagged? method in AST Resource to also search
for tags in its containing resource. These tags will be set when
the resource is finalized (just before serialization on transformation
to external format).
If this is not done, resources will have a different tag set when
a search is made for the node itself (exported or virtual) vs. searching
external resources.
This also correct minor problems with passing an array (which could
result in an array being set as a tag).
It was also possible for empty tags to be set if a string tag contained
multiple :: in sequence, or if ending with ::. Now an error is raised
for these conditions (just like for empty segments generated by using a
sequence of commas (which was on a different code path).
|
|
There are a lot of ways that the facts hash could be mutated. This
checks that none of those ways can happen.
|
|
|
|
When opting in with trusted_node_data or immutable_node_data the facts
are also available via $facts, an immutable hash of data.
|
|
|
|
There were several problems with the query (Collector) implementation.
The CollExpr matching logic used Ruby == and Ruby include? instead
of Puppet Operators. This meant that numeric values in string vs.
numeric form were not comparable. This is now changed by using an
alternative implementation of CollExpr evaluate when Puppet[:parser] ==
future.
The relationship operator implementation did not support handling a
Collector (the result of evaluating a CollectExpression). The 3x
compiler is responsible for late evaluation of the Collector, and a
relationship formed with a Collector was not implemented. Now the
Collector is passed verbatim as operand in a Relationship, and passed on
to the compiler.
|
|
Tests from the parser integration tests were added to the unit tests
for the new evaluator (they were not very good integration tests). The
old test ran for both "current" and "future" and now only run for
"current". The relevant tests were moved to the evaluator unit tests.
This showed several problems in the PopsBridge (typos) for yet
unexercised code paths. These are now fixed.
As the integration/parser/compiler_spec tests were being investigated
to run also for the new parser, problems were found with comparison
against literal undef. Tests were added for this in the evaluator unit
test and the problem corrected (undef compared as :undef == nil => false
which is not the intention. Comparsions :undef == nil, and nil == :undef
are now done correctly.
Exceptions did not show up correctly when file is empty string. This
also fixes the logic where it is checked if a file is known (nil and
empty string are now considered to be "file unknown" instead of file ""
known.
|
|
In Ruby 1.8.7, the error message for an attempt of mutating
a frozen hash refers to 'hash' using lower case whereas later versions
use capital 'H'. This caused two tests to fail (twice).
|
|
This renames hashed_node_data to trusted_node_data, and
the element 'clientcert' to 'certname'.
This also fixes the issues regarding immutability reported in PP-773.
It is now not possible to alter the trusted data. (A freeze was missing
when the data was created). As extra precaution, the data is frozen when
set as trusted data in the node.
There is now also a warning if an attempt is made to modify the trusted
data by manipulating a node.
|
|
This adds a new feature where it is possible to opt in to getting a top
scope variable $trusted to contain a hash of trusted data.
The setting that controls this is called hashed_node_data (it is
intended to later also be used for hashed facts as well as the hashed
trusted data; hence its more generic name).
The variable $trusted is only available if :hashed_node_data is set to
true (the default in 3.x is false).
The hash contains the key 'authenticated' which is always set to one of
'remote', 'local' or boolean false. The key 'clientcert' is set if
'authenticated' is set to 'remote' or 'local'.
|
|
This cleans up source formatting (spaces/tabs), dead todo, blank lines,
ending without a linebreak, and corrects indentation.
|
|
Tests were hardwired to run for only future/eparser. Now all tests
where parser is involved runs for both current/classic and
future/eparser (except when testing methods; where parsing is only
done in order to construct a call; it is the function that is tested,
not the parsing). The collect method testing includes testing the
various ways a call can be made to it, but this is the only place; this
because it is more work to unwire all the others when the final style
for lambdas gets picked.
|
|
The compiler test is not testing the parser and should use
the configured parser dictated by the ParserFactory.
|
|
This test was assuming, incorrectly, that it will always be run from
inside a git repo with git installed. Now we properly handle the case
where it's not, and skip the test.
|
|
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,'
|
|
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.
|
|
|
|
A whole bunch of tests scattered through the system fail on Windows, around
features that are not supported on that platform. (They are things that only
the master does, which an agent-only platform doesn't need to support.)
These were tagged `fails_on_windows` to allow filtering them from rspec runs,
which is great, but doesn't actually communicate nearly as much useful
information as it would if we used the "conditionally pending" facilities that
rspec has supported since 2.3.
That gives us two key things: one, it works automatically based on our
knowledge of the platform, which means you can't forget to turn off failing
tests.
Two, it means that if the test starts unexpectedly passing we also get a
failure, since we should respond to "works when it shouldn't" as seriously as
"fails when it shouldn't".
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
This adds support for using a variable, resource ref-like string, case
statement, selector, or array/hash access for either side of a
relationship. For example, it is now legal (if unwise) to write the
following:
notify { [a,b,c]: }
$var = Notify[a]
$var -> case 'x' {
'x': {
notify { d: }
}
} ~>
'x' ? {
'x' => Notify[b]
} <- "Notify[c]"
|
|
Previously, a relationship such as
Notify[a,b] -> Notify[c,d]
would fail, because relationship objects didn't handle arrays of
resources, and tried to look them up as though the title array were a
single resource name. Now, relationships will be established for each
resource specified by the ref.
|
|
When running spec/integration/parser/compiler_spec.rb, the git command
passed to Puppet::Util.execute is an array containing a single string
["git rev-parse HEAD"]. On Unix, it calls Kernel.exec(*command), but on
Windows it calls Process.create(:command_line =>command), which attempts
to execute the program called "git rev-parse HEAD" and fails:
CreateProcess() failed: The system cannot find the file specified.
This commit marks the test as fails_on_windows, and will be re-enabled
when #8410 is fixed.
Reviewed-by: Nick Lewis <nick@puppetlabs.com>
(cherry picked from commit 7ca187509ce954e5b2707212a5615dbb9eb20378)
|
|
The mount, shell, and ssh_authorized_key types are not supported on
Windows, so these spec tests have been disabled when running on
Windows.
One of the compiler spec tests fails on Windows because
Puppet::Util.execute attempts to execute a program named "git rev-parse
HEAD". This has different semantics than Unix, where the command is
splatted, Kernel.exec(*command). Since this truly is a Windows bug, I
removed the fails_on_windows tag and updated ticket #8410.
Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
(cherry picked from commit d9ce88d10707268fe41c8f3ad1166137fe8e202f)
|
|
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>
(cherry picked from commit 255c5b4663bd389d2c87a2d39ec350034421a6f0)
Conflicts:
spec/unit/resource/catalog_spec.rb
|
|
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.
|
|
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
|
|
|
|
The evaluate_definitions method was first figuring out which resources
needed to be evaluated (using unevaluated_resources), and then
evaluating them one by one. As a result, if evaluating one resource
triggered another resource to be evaluated, the latter resource could
get evaluated twice. This bug could occur, for example, if both
resources were classes that were included into the node by an external
node classifier, and if the first of the two classes included the
second.
Modified Resource#evaluate to be idempotent.
Also added an integration test to verify the fix.
|
|
or node occurs in a conditional construct so that it contains the
proper line number.
|
|
Previously, ASTArray#evaluate() was responsible for checking whether
the user had tried to declare a class, define, or node in a prohibited
location (such as a conditional construct). This meant that errors
would only be reported to the user if the conditional code was
actually evaluated.
Moved the checking into the parser, so that errors are always
reported.
|
|
definitions (classes, definitions, and nodes).
Previously, type definitions were not represented directly in the AST.
Instead, the parser would instantiate types and insert them into
known_resource_types as soon as they were parsed. This made it
difficult to distinguish which types had come from the file that was
just parsed and which types had been loaded previously, which led to
bug 4496.
A side-effect of this change is that the user is no longer allowed to
define types inside of conditional constructs (such as if/else). This
was allowed before but had unexpected semantics (bugs 4521 and 4522).
It is still possible, however, to place an "include" statement inside
a conditional construct, and have that "include" statement trigger the
autoloading of a file that instantiates types.
|
|
Puppet::Node::Environment.
This change is part of an ongoing effort to remove functionality from
TypeCollection that is not related to keeping track of a collection of
types. This reduces TypeCollection's linkage to the environment,
which is a step toward decoupling it from the type loading mechanism.
Also, added a spec test to verify that TypeCollection.version is
correctly recomputed when types are re-imported.
|
|
AST resources.
Move type-name resolution out of Puppet::Resource into the AST resources.
Move find_resource_type out of Puppet::Resource into Scope
Thus, never pass unqualified type names to Puppet::Resource objects.
Thus, Puppet::Resource objects don't need the namespace property,
and Puppet::Resource objects never consult the harddrive to look for
.pp files that might contain their type definitions,
Thus, performance is improved.
Also removes the temporary fix for #4257 that caused #4397
(The code was too eager to look for a class in the topscope)
Paired-With: Paul Berry <paul@puppetlabs.com>
Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
|
|
AST resources.
Move type-name resolution out of Puppet::Resource into the AST resources.
Move find_resource_type out of Puppet::Resource into Scope
Thus, never pass unqualified type names to Puppet::Resource objects.
Thus, Puppet::Resource objects don't need the namespace property,
and Puppet::Resource objects never consult the harddrive to look for
.pp files that might contain their type definitions,
Thus, performance is improved.
Also removes the temporary fix for #4257 that caused #4397
(The code was too eager to look for a class in the topscope)
Paired-With: Paul Berry <paul@puppetlabs.com>
Signed-off-by: Jesse Wolfe <jes5199@gmail.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
|
|
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
|