summaryrefslogtreecommitdiff
path: root/spec/integration/parser/compiler_spec.rb
AgeCommit message (Collapse)AuthorFilesLines
2014-08-27(PUP-2349) Specify mode as an octal string consistently in spec manifest ↵Kylo Ginsberg1-2/+2
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).
2014-08-18(maint) Extract language specification toolsAndrew Parker1-1/+1
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.
2014-07-24(maint) Remove unnecessary Puppet.settings.clear calls from specsJosh Partlow1-4/+0
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.
2014-06-12(maint) Refactor shared example from parser/compiler_specJosh Partlow1-397/+385
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.
2014-06-03(maint) Update test to use resource matcherAndrew Parker1-2/+2
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.
2014-05-30(PUP-2689) Make AST Resource check tags against "inherited" tagsHenrik Lindberg1-0/+28
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).
2014-02-28(PUP-542) Test the gamut of mutationAndrew Parker1-29/+46
There are a lot of ways that the facts hash could be mutated. This checks that none of those ways can happen.
2014-02-26(PUP-542) Make tests pass on 1.8.7 ('hash' vs 'Hash' in message)Henrik Lindberg1-1/+1
2014-02-26(PUP-542) Add structured facts to immutable $factsHenrik Lindberg1-0/+84
When opting in with trusted_node_data or immutable_node_data the facts are also available via $facts, an immutable hash of data.
2013-12-05(maint) Remove debugger callHenrik Lindberg1-1/+0
2013-12-05(#22363) Make queries work with future evaluatorHenrik Lindberg1-0/+1
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.
2013-12-05(#22363) Fix problems with undef equality & problems from added testsHenrik Lindberg1-13/+1
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.
2013-11-18(#19514) Correct error message matching for Ruby 1.8.7Henrik Lindberg1-2/+2
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).
2013-11-18(#19514)(PP-773) Rename hashed_node_data and cliencert for $trustedHenrik Lindberg1-4/+31
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.
2013-10-11(#19514) Add $trusted as hash with trusted node dataHenrik Lindberg1-0/+63
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'.
2013-04-05(#11331) Clean up trailing spaces and bad formatting.Henrik Lindberg1-49/+49
This cleans up source formatting (spaces/tabs), dead todo, blank lines, ending without a linebreak, and corrects indentation.
2013-04-05(#11331) Make tests run for both current and future parser.Henrik Lindberg1-264/+286
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.
2013-04-05(#11331) Make compiler unit test use ParserFactory to create parser.Henrik Lindberg1-0/+3
The compiler test is not testing the parser and should use the configured parser dictated by the ParserFactory.
2013-03-25Skip test that runs git if we can't run gitNick Lewis1-10/+10
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.
2012-09-26(Maint) Remove rspec from shebang lineJeff McCune1-1/+1
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,'
2012-07-02(maint) Standardize on /usr/bin/env ruby -S rspecJeff McCune1-1/+1
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-28(#13349) Add integration test for incorrect scopeJeff Weiss1-0/+27
2012-04-18Use conditional pending to block out "fails_on_windows" tests.Daniel Pittman1-9/+10
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>
2011-12-13(#6710) Support relationships for resources defined by other constructsNick Lewis1-0/+58
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]"
2011-12-13(#6710) Support relationship arrows between resource refs with title arraysNick Lewis1-0/+89
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.
2011-08-19(#8663) Exclude git rev-parse HEAD spec test on WindowsJosh Cooper1-1/+2
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)
2011-08-19(#8663) Disable spec tests for unsupported functionality on WindowsJosh Cooper1-1/+1
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)
2011-08-19Maint: Tagged spec tests that are known to fail on WindowsJosh Cooper1-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> (cherry picked from commit 255c5b4663bd389d2c87a2d39ec350034421a6f0) Conflicts: spec/unit/resource/catalog_spec.rb
2011-04-13maint: clean up the spec test headers in bulk.Daniel Pittman1-2/+1
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-08maint: just require 'spec_helper', thanks rspec2Daniel Pittman1-1/+1
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>
2010-12-06maint: Use expand_path when requiring spec_helper or puppettestMatt Robinson1-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
2010-10-04Merge commit '2.6.2rc1' into nextJesse Wolfe1-0/+21
2010-09-30Fixes #4792 (Duplicate definition since 2.6.1 upgrade)Paul Berry1-0/+21
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.
2010-09-07Modified the error message that is generated when a class, definition,Paul Berry1-7/+15
or node occurs in a conditional construct so that it contains the proper line number.
2010-09-01[#4685] Classes, defines, and nodes allowed inside of non-evaluated conditionalsPaul Berry1-1/+12
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.
2010-08-13[#4496]+[#4521]+[#4522] Add structures to the AST to represent type ↵Paul Berry1-0/+11
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.
2010-08-13Moved perform_initial_import from Puppet::Resource::TypeCollection to ↵Paul Berry1-0/+11
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.
2010-08-03[#4397]+[#4344] Move type-name resolution out of Puppet::Resource into the ↵Jesse Wolfe1-0/+43
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>
2010-07-30[#4397]+[#4344] Move type-name resolution out of Puppet::Resource into the ↵Jesse Wolfe1-0/+43
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>
2010-07-09Code smell: Two space indentationMarkus Roberts1-17/+17
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
2010-06-28[#3994-part 2] rename integration tests to *_spec.rbMarkus Roberts1-0/+29
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