summaryrefslogtreecommitdiff
path: root/spec/integration/parser
AgeCommit message (Collapse)AuthorFilesLines
2014-06-12(PUP-514) Add support for opt-in typing of define/class parametersHenrik Lindberg1-3/+6
This makes define and class parameters support optionally typed parameters when using the future parser. The type expressions are evaluated by the Pops Bridge when parameters are transformed t 3x. The 3x parameters are not aware of type information (they are encoded as arrays), and changes to all the logic that deals with parameters turned on to not be a good design. The resource type and resource is instead made aware of the opt-in types via a separate param-name to type map that it applies in the validation step that was already performed.
2014-06-12(PUP-2756) Fix test of future parser evaluation of empty stringJosh Partlow1-0/+117
An empty string is no longer undef when parser is future, and will evaluate as true in a conditional test. This commit fixes a test that was failing this check for the future parser. This, and several like it, was an acceptance test which was just compiling a simple manifest with some conditional logic to test evaluation of conditionals. Since acceptance tests are expensive, I've pulled them back into the integration specs. The actual test being fixed is acceptance/tests/apply/conditionals/should_evaluate_empty.rb which is now the two 'evaluates empty string as <false|true>' specs in the new spec/integration/parser/conditionals_spec.rb
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-11Merge pull request #2660 from hlindberg/PUP-121_remove-relative-name-spacingJosh Partlow1-4/+8
(PUP-121) remove relative name spacing
2014-06-11(PUP-121) Change transformation of CatalogEntryType to not be absoluteHenrik Lindberg1-4/+4
The attempt to make all catalogEntryTypes absolute did not work out so great as the lower level APIs in 3x expect non :: prefixed names to be absolute. This changes the transformation made in the evaluator to always use "relative" names.
2014-06-11(PUP-121) Ensure classes are absolute when transforming to ResourceHenrik Lindberg1-4/+8
When the 3x to 4x calls take place, resource references in the form of a PCatalogEntryType are transformed to Puppet::Resource. Depending on where these (reference) Puppet::Resource instances are used they need to either be absolute, or not (yes, 3x is inconsistent). Since future parser in 3.7 (and later 4.0) will not support dynamic name scoping, the PCatalogEntryType's should in general be absolute. This commit changes the transformation to make the created Puppet::Resource (references) absolute (when it is possible). This also adds more tests
2014-06-03Merge remote-tracking branch 'upstream/stable'Andrew Parker2-0/+57
* upstream/stable: (maint) Remove failure for empty generated tags (maint) Update test to use resource matcher (maint) Add sitemoduledir to env env tests (PUP-2689) Make AST Resource check tags against "inherited" tags (maint) Remove unused Puppet::Parser::AST::Tag class
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 Lindberg2-0/+57
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-05-19(PUP-867) Remove support for dynamic defaults for future parserHenrik Lindberg1-0/+32
WHen future parser is in effect, the lookup of default values will now not look in "parent scopes" (i.e. scopes that *contain* the resource). Instead it now only looks in inherited and enclosing scopes + itself. This removes the confusion that occurs when a class may be included from different locations, and the location that wins manages to impose the defaults from its scope. This removal goes hand in hand with dynamic scoping being removed everywhere else.
2014-05-12(PUP-1028) Remove pending tests that aren't neededAndrew Parker1-14/+20
The new parser has been updated to be able to handle nodes with numeric names and so the test for that case now passes for both the current and future parser. The only remaining case is when the name is an invalid number. The future parser won't ever parse this correctly and so the test has been changed to assert the desired behavior, in which the parser fails. The new changes to the parser also allows it to handle dotted names and so a new test has been added for that.
2014-05-12(PUP-1028) Specify various ways of matching nodesAndrew Parker1-0/+161
There were no tests that tried to specify how node statements are selected. This adds coverage for various ways in which a node statements can match a given node object and varifies that the future evaluator and the current evaluator produce the same results. There are 2 cases where the future evaluator isn't able to handle the same node statements: using numbers. One case, where a name begins with a number, seems completely reasonable. The other case, where the name is a valid number, seems like an arbitrary restriction and so we need to discuss.
2014-04-28(PUP-1699) Retain an instance of a Catalog's environmentJosh Partlow1-5/+0
A catalog used to have the symbolic name if it's environment set, but did not retain a reference to the actual environment instance. This could would likely allow the catalog to reference it's original environment for a legacy, memoized environment, but does not work with newer cacheing models for directory environments. The problem was showing up specifically in the spec/integration/parser/ruby_manifest_spec which would compile a catalog and then interrogate the catalog to see if it contained the expected resources. Resources have unfortunate behavior causing them to lookup environment in order to load types in support of the Resource#parse_title. But the current_environment retrieved by the resource in the spec was likely different than the one overridden during compilation, and if it had never performed an initial import, might fail attempting to lookup classes which were not on its path. To short circuit some of this madness, the compiler is explicitly setting a new Catalog#environment_instance, and Catalog#to_catalog is ensuring that it copies when duplicating. Catalog#resource then overrides current_environment to this instance.
2014-04-27(maint) Convert to using have_resource matcherAndrew Parker1-22/+17
Using the have_resource matcher makes the tests a little shorter and more expressive. It also uses the common way of matching so that we can get better error reporting. It turns out that one of the tests was matching against the incorrect class name, so that is now fixed. This also extracts a be_resource matcher so that you can match against an individual resource independent of a catalog.
2014-04-27(maint) Convert to compile_to_catalogAndrew Parker1-135/+68
The tests used various ways to contruct the catalog. However, putting together a catalog isn't always as simple as just calling compile. compile_to_catalog puts all of the steps together in a way that is easy to use in the tests.
2014-04-23(PUP-2302) Fix issue with Resource Defaults for qualified namesHenrik Lindberg1-0/+15
When defaults were set using future evaluator and the resource has a qualified name, the registration of the default was not recognized because scope requires every segment of a qualified name to be upper cased. This adds upper casing of every segment. An integration test checks that the capitalization works.
2014-04-07(PUP-1964) Handle nil class parameter valueHenrik Lindberg1-1/+12
The problem was that nil was not transformed to undef for the result of a parameter default expression and nil was interpreted as value missing by the 3x class/define logic. This adds a transformation in the PopsBridge by introducing a new kind of bridging expression. Likewise, a transformation was needed back again to nil as the value was set in TypeCalculator when performing an inference and symbol :undef can not be used where a String is expected. It was also observed in PUP-1964 that the error that surfaced lacked location information. This was caused by the transformation of unparenthesized call, where the transformed call expression did not get location information set. Tests added for the two different problems. The factory method for recording position now also checks if the end_locateable is void of location information (which can happen in some transformations).
2014-03-18(PUP-1973) Fix getting scope vars to template for inherited scopeHenrik Lindberg1-0/+41
The change in PUP-1220 (turning off access to dynamic scope) accidentally also turned off access to inherited scope. This is a big problem because it blocks the most used pattern of getting parameters into classes in modules (and then accessing them in templates).
2014-03-05Merge pull request #2117 from ↵Andrew Parker1-0/+34
ffrank/ticket/master/22800-dynamic-lookup-in-templates (PUP-1220) apply proper scoping rules to scope#to_hash
2014-02-28Merge branch ↵Andrew Parker1-29/+46
'adrienthebo-issue/master/pup-542-deep_freeze_arrays_numerics_booleans' * adrienthebo-issue/master/pup-542-deep_freeze_arrays_numerics_booleans: (PUP-542) Test the gamut of mutation (maint) Detect reparse when :code changes (maint) Allow arrays, bools, and numerics to be frozen
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-28(PUP-1144) Improve handling of underscore in variable namesHenrik Lindberg1-0/+24
The last segment of a qualified variable name is allowed to start with an underscore. Previously this was only allowed for a single segment.
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.
2014-02-13(PUP-1220) make the dynamic scoping fix for #22800 flexibleFelix Frank1-33/+31
As suggested by Henrik Lindberg, make the parser only behave correctly when parser=future is configured. If working manifests rely on the regression, the next point release won't break them. Instead, users can test for this using the configuration setting. The next major release should adopt the fix as standard behavior and the legacy support should be removed. Since the variable lookups in templates relies on the accessing of local attributes, there is no way to issue deprecation warnings to users.
2014-02-13(PUP-1220) apply proper scoping rules to scope#to_hashFelix Frank1-0/+36
The fix for #1427 added an instance method to the scope class for exporting all variables from the local scope. This method apparently re-implemented the dynamic scoping rules. When those were removed, the #to_hash method was left as was. As a result, dynamic scoping still worked from within templates, when using the @variable syntax in the erb code. Fix this by using the new #enclosing_scope method so that proper scoping rules are used instead.
2013-12-17(maint) Make integratin/scope_spec run for both current & future parserHenrik Lindberg1-534/+586
This changes scope_spec to run for both current and future parser. (At this point, the future evaluator still has issues; to be fixed in coming committs).
2013-12-17(maint) Move 'jeff_append_to_array' from acceptance to integration testHenrik Lindberg1-60/+100
The test only checked if it was possible to append to an array in an outer scope by creating two notify resource based on the array. This test does not have to run as part of the acceptance tests and was moved to catalog_spec in integration. This also makes catalog_spec run for both current and future parser. (The future parser still has issues at this point; to be fixed in later commits).
2013-12-12(#7659) add more tests for possible hash use syntaxesFelix Frank1-6/+32
2013-12-12(#7659) add a test for puppetdoc in the presence of hash literalsFelix Frank1-1/+9
Add a test to confirm the effect of the fix for a puppetdoc bug.
2013-12-12(#7659) Fix commentstack when parsing hashesSebastian Schmidt1-1/+9
We need to pop from commentstack in the grammar whenever we parse a hash; an LBRACE pushes to commentstack, yet an AST::ASTHash does not have a doc string which would get the comment popped from the stack again. This left an extra item on the commentstack which caused all subsequent Lexer#getcomment to return "". Make the test for "comments before statement" contain a more complex example to demonstrate that nested comments should not be returned.
2013-12-06(#22363) Fix problems from changed validation of relationships.Henrik Lindberg1-1/+1
The vaidation was changed from a specific relationship validation to using just R-Value check. This was a mistake since a CollectExpression is a valid operand in a relationship even if not producing an R-Value. Old version resurrected and streamlined to do either R-Value check, or check that operand is a Collector.
2013-12-06(maint) Fix stale comments and remove commented out code.Henrik Lindberg1-8/+2
2013-12-05(maint) Fix failing tests after rebase to latest masterHenrik Lindberg1-2/+2
4 tests were failing because Puppet[:hashed_node_data] was renamed to Puppet[:trusted_node_data]. This commit changes the failing tests to use the renamed setting.
2013-12-05(#22363) Add compiler integration test for future evaluatorHenrik Lindberg1-0/+398
(This was missing in an earlier commit)
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 Lindberg2-116/+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-12-05(#22363) Add strict variable lookup modeHenrik Lindberg1-1/+1
This adds the setting :strict_variables. When used the scope will throw :unkown_variable (which if not handled, will raise an exception). The future evaluator can handle this, but none of the other parsers/evaluator options. Testing of the future evaluator turns on strict variables mode (and has tests that an error is raised). This commit also contains maintenance (removal of unused code), fixing of the pops bridge (special case when evaluating without a proper boot)
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-09-10(maint) Fix failing test.Henrik Lindberg1-2/+2
The test was wrong (inadvertent inclusion of an unexpected error while testing ability to catch a different problem).
2013-08-20(#21201) Remove test for thread-safetyAndrew Parker1-16/+0
The functions test for thread safety, after many runs after having removed the thread safety code, still did not fail. This removes the test.
2013-07-29(Maint) Rename catalog integration specAndrew Parker1-0/+0
The catalog integration spec was originally intended as just to be about the order in which some elements appeared in it, but it has evolved to be about the general invariants and properties of the catalog as it is transmitted between the master and the agent.
2013-07-29(#18508) Assert kinds of resources sent to agentAndrew Parker1-13/+57
This adds assertions that the virtual resources are not sent to the agent, and neither are exported resources.
2013-07-29(#18508) Preserve order of insertion for resourcesPatrick Carlisle1-4/+13
The order that resources are added into the catalog is needed in order to ensure a less surprising order when applying resources on the agent. This ensures that the order that resources are transmitted to the agent preserves that insertion order.
2013-07-29(#18508) Specify the order of resources in the catalogAndrew Parker1-0/+32
This adds a specification to the order in which resources appear in the catalog. They must appear in the order in which they are added to the catalog. In order to make this kind of assertion easier this commit also brings in Ramcrest.
2013-04-05(#11331) Add more negative tests (rvalue checks).Henrik Lindberg1-0/+20
This adds checks for validation of non rvalue producing expressions that can be created with the current concrete syntax. (Combinations that can not be created via the current egrammar are not included since it is difficult to create them).
2013-04-05(#11331) Fix issues with detailed errors for hostnames.Henrik Lindberg1-1/+31
The validation of hostname expressions did not produce good messages for interpolated string (syntax error vs. detailed error). Relaxes the grammar to accept a concatenated string which is then validated. Refactors parameter name from 'node' to 'semantic' in hostname_xxx checks (the role of the parameter is to provide semantic location, it is not required to be a node). Contains additional tests for other (already passing) detailed errors.