| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, we were always using string comparisons, and hard-coded
paths to temp locations on non-Windows platforms. This was
problematic for a few reasons. We had to maintain a list of temp
locations for the various platforms, and the string comparisons were
unreliable on Windows, since paths have two string representations
(the "short" name containing a ~ followed by a number, and the "full"
name).
By getting the current temp location using Dir.tempdir (the same
mechanism our temp creation code uses), we no longer need to maintain
the list of temp locations. Also, rather than doing string
comparisons on file paths, we can use a combination of
Pathname#ascend, and File.identical? to determine if the path
registered as a temp file for deletion was actually created in the
temp location.
With this refactoring, the same code now works for both Windows, and
non-Windows platforms.
Reviewed-by: Nick Lewis <nick@puppetlabs.com>
|
|\
| |
| |
| |
| |
| | |
Conflicts:
lib/puppet/type/file/source.rb
spec/unit/resource/catalog_spec.rb
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Ruby 1.8.7 is fairly lax about various bits of introspection, including that
we can't tell much about what arguments a block takes. Ruby 1.9.2 makes it
possible to do this, though.
Meanwhile, the Faces system uses this to make sure that scripts and actions
take the right set of arguments, to avoid surprises: failing early and
explicitly is better than failing at runtime.
Which, in final turn, exposes that I forgot to accept the right arguments in a
couple of my testing actions for Faces, but didn't notice because 1.8.7
doesn't check that, and I didn't test on 1.9.2.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When we define an action on an older version of a Face, we must be sure to
directly load the core of that version, not just define it with the external
Action(s) that it had.
Otherwise we break our contract, which is that any core Actions for a specific
version will be available to your external Action for as long as we support
that core version.
Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When we first touch a Face, we load all the available Actions from disk.
Given they define themselves against a specific version of a Face, they are
automatically available tied to the correct version; this makes it trivially
possible to locate those on demand and return them.
Now, we have the ability to find and, consequently, invoke Actions on older
versions of Faces. We don't load enough context, though: the older face will
only have external Actions defined, not anything core.
Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
|
|/
|
|
|
|
|
|
|
|
|
|
|
| |
Absolute paths on Unix, e.g. /foo/bar, are not absolute on Windows,
which breaks many test cases. This commit adds a method to
PuppetSpec::Files.make_absolute that makes the path absolute in
test cases.
On Unix (Puppet.features.posix?) it is a no-op. On Windows,
(Puppet.features.microsoft_windows?) the drive from the current
working directory is prepended.
Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
We were emitting a bunch of unhelpful failure messages, surrounding invalid
actions and especially default actions interacting with the command-line.
This cleans those up, to give a helpful, informative, and correct message in
all cases. Notably, we no longer report that there is no "default" action
when you specify an unknown action on a face.
This change revealed some other weaknesses in our unit tests, now correctly,
that result in slightly more robust code.
|
|
|
|
|
|
|
|
|
|
| |
Ruby 1.9 is stricter about arity for for arguments passed as a block. A
test case just hadn't been updated to take this into account for Face
scripts (a simpler form of action), which isn't surprising since script
isn't used anywhere in the code, which makes it a prime candidate for
removal as far as I'm concerned, but apparently Luke wants it in there.
Reviewed-by: Pieter van de Bruggen <pieter@puppetlabs.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
We refer to rendering formats pretty consistently as `json`, `yaml`, `s`, and
so forth; unqualified names.
On the other hand, we refer to the rendering hooks *mostly* as `to_*`, except
the `:for_humans` and `:json` formats. Which is kind of confusing because of
the internal inconsistency, and because it doesn't match the public name.
Fix the code to resolve both, so the `to_*` format still works, but we mostly
expect to use the `*` version, to match public expectation.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We used to let actions be declared without the `when_invoked` block, which was
usually a sign of either someone writing their method code direct in action
declaration, or someone forgetting to add their code at all.
This was just let silently by: the error only showed up when you finally tried
to invoke the action, and a NoMethod error was raised by the face.
...except for our own testing. We took advantage of this a whole pile of
times in there; fixing the original UI issue means fixing all those too.
Reviewed-By: Nick Lewis <nick@puppetlabs.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
You can now write expectations along the lines of:
expect { ... }.to print /whatever/
This will do the expected thing, which is to require that we print something
matching that regular expression during the block. The output itself is
suppressed during operation of the matcher.
Paired-With: Max Martin <max@puppetlabs.com>
|
|
|
|
|
|
|
|
|
|
| |
We now run all the faces, and their actions, as well as global help through
the wringer in this test: this way we can be confident that we have, at least,
the ability to generate the help without a user-visible failure.
We also check that we have set copyright and license terms in our own faces.
Theoretically this might fail if the end user has extra faces on LOAD_PATH,
but my hope is that we won't hit that...
|
|
|
|
|
|
|
|
| |
When a face or action fails we should exit non-zero on the CLI to signal this
to our caller. "Fails" is defined as "raises an exception"; we don't treat
any return value as a significant failure.
Reviewed-By: Jesse Wolf <jesse@puppetlabs.com>
|
|\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
'remotes/lak/tickets/next/7118-summaries_for_all_faces' into 2.7.x
Fix conflicts due to version drift in:
lib/puppet/face/certificate.rb
lib/puppet/face/facts.rb
lib/puppet/face/node.rb
lib/puppet/face/secret_agent.rb
spec/lib/puppet/face/basetest.rb
spec/unit/face/help_spec.rb
Reviewed-By: Markus Roberts <markus@puppetlabs.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
It's usually just a one-liner, but when I saw an
obvious opportunity for longer docs, I've added a
@longdocs variable that can be converted to longer
forms when ready.
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
"Invisible glob", or "prefix", version matching means that when you specify a
version string to use you can specify as little as one version number out of
the semantic versioning spec.
Matching is done on the prefix; an omitted number is treated as "anything" in
that slot, and we return the highest matching versioned face by that spec.
For example, given the set of versions: 1.0.0, 1.0.1, 1.1.0, 1.1.1, 2.0.0
The following would be matched:
input matched
1 1.1.1
1.0 1.0.1
1.0.1 1.0.1
1.0.2 fail - no match
1.1 1.1.1
1.1.1 1.1.1
1.2 fail - no match
|
|\ \
| | |
| | |
| | | |
'feature/2.7.x/6978-face-and-action-options-should-have-hooks-for-various-actions' into 2.7.x
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Options can now add before_action and after_action blocks; these are invoked
before or after any action is invoked on the face. This allows these options
to declare common behaviour and have it automatically applied to the actions
invoked.
Option hooks have no defined order of invocation: they will run in a
completely random order. Where there are dependencies they should be on the
value of the options hash passed to the invocation, not on side-effects of the
other invocations.
You are not able to influence the arguments, options, or calling of the action
body in a before or after decorator. This is by design.
The invocation passes to the hook:
1. The action object representing this action.
2. The arguments to the action, as an array.
3. The options for the action, as a hash.
Paired-With: Max Martin <max@puppetlabs.com>
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These make the JSON tests much easier to read and
write. They're the first custom matchers that I can
find, so they're breaking a bit of new ground,
but the JSON tests were pretty hard to read
and there was a lot of duplication, so it seemed
worth it.
Note that for some reason they're not working on
Facts - it seems to get immediately turned into
a full instance by the JSON parsing subsystem,
and I've no idea why.
Reviewed-by: Daniel Pittman <daniel@puppetlabs.com>
Signed-off-by: Luke Kanies <luke@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.
|
|
|
|
|
|
|
|
|
| |
After some discussion we decided that most uses of the Puppet Face
infrastructure were about single faces on their own, not about the collection,
and so we were better referring to Puppet::Face[...] in code.
This implements that by translating names and references in the Ruby code to
the new, s-less, name.
|
|
|
|
|
|
|
|
| |
We used to create temporary directories to have some support files on disk
during testing of faces; we don't really need that most of the time, and this
updates a test to reflect that reality.
Reviewed-By: Matt Robinson <matt@puppetlabs.com>
|
|
|
|
|
|
|
|
| |
We now use the summary information available in other faces as part of
emitting a list our list of available subcommands. This is seldom used in
faces, but enough emit the information to prove the concept.
Reviewed-By: Matt Robinson <matt@puppetlabs.com>
|
|
|
|
|
|
|
|
|
| |
We used to shell out to chmod and rm to clean up temporary files; this lead to
the cleanup method here being one of the largest consumers of walltime.
Replacing that with FileUtil calls is as, or more, secure, and performs
sufficiently well that we can just delegate.
Reviewed-By: Matt Robinson <matt@puppetlabs.com>
|
|
|
|
|
| |
This joins the two repositories, including full history, into a single run, as
well as landing the interfaces work on the next branch ready for release.
|
|\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* 2.6.next:
Fixed #6562 - Minor kick documentation fix
(#6658) Propagate ENC connection errors to the agent
(#4884) Remove typo from spec test
(#4884) Modify tests to pass on non-OS X systems
(#4884) Revise new exec tests, add a few more
(#4884) Add an shell provider for execs
(#4884) Fix Test::Unit exec tests
(#4884) Break the exec type out to have a posix provider
(#4884) Add consistent path validation and behavior
(#4884) Add expand_path to requiring the spec_helper
(#4884) Autorequire shared behaviors and method to silence warnings
(#4884) Fix whitespace
(#4884) Get rid of open3 require since it wasn't being used
(#5814) Improved cron type specs
(#5814) cron_spec shouldn't depend on cron provider
Manually Resolved Conflicts:
lib/puppet/util/command_line/puppetrun
spec/spec_helper.rb
spec/unit/type/exec_spec.rb
spec/unit/type_spec.rb
test/ral/type/exec.rb
|
| |
| |
| |
| |
| |
| |
| | |
with_verbose_disabled allows you to run tests that muck with constans
without getting spammy warnings.
Reviewed-by: Max Martin and Matt Robinson
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
As part of implementing the fixture support I hard-coded the assumption that
the git checkout was a directory named 'puppet'; this broke on our CI server,
and would break for anyone else who didn't follow that default.
This commit eliminates that assumption and depends only on the appropriate
part of the input filename.
Reviewed-By: Paul Berry <paul@puppetlabs.com>
|
| |
| |
| |
| |
| |
| |
| |
| | |
We move the tempfile cleanup support off into the module that uses it, which
removes some of the dependency on magic globals from configure. It still
exists, but is hidden in the same module that uses it, which helps.
Reviewed-By: Nick Lewis <nick@puppetlabs.com>
|
|/
|
|
|
|
|
|
|
|
|
|
|
| |
We validate that fixtures exist, when requested, or that they match something
when they use a glob. This catches internal errors where we don't match any
fixtures with a glob; this can reveal problems that would otherwise avoid all
assertions and result in internal failures.
The code is hidden out in a module, included in the main RSpec namespace.
This doesn't clean up the API any, but it isolates the code more effectively
and keeps the configuration file cleaner.
Reviewed-By: Nick Lewis <nick@puppetlabs.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The function import_if_possible, which was supposed to be responsible
for making sure that no two threads tried to import the same file at
the same time, was not making this decision based on the full pathname
of the file, since it was being invoked before pathnames were
resolved. As a result, if we attempted to import two distinct files
with the same name at the same time (either in two threads or in a
single thread due to recursion), one of the files would not always get
imported.
Fixed this problem by moving the thread-safety logic to happen after
filenames are resolved to absolute paths. This made it possible to
simplify the thread-safety logic significantly.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We had a common pattern for creating a temporary
file during integration tests, and this just
makes that common pattern explicit by
moving it to a module in the newly-created
lib directory in the spec directory.
We definitely don't want to go overboard in
using libraries in our tests, but sometimes
it gets a bit excessive to completely avoid them.
Signed-off-by: Luke Kanies <luke@madstop.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
changed and it can't be found otherwise.
Adding $PUPPET/vendor/gems, with unpacked rspec gem there, introducing to spec_helper.rb LOAD_PATH incantation. Eliminating ad hoc unpacked rspec from spec/lib.
Moving monkey_patches and shared_behaviors up under spec/. Adjusting spec_helper.rb accordingly.
Nuking spec/lib.
Fixing up autotest/puppet_rspec.rb to be able to hunt down our vendor/gems/rspec/bin/spec binary. We can now run rspec without having to have the rspec gem installed.
|
| |
|
|
|
|
|
| |
rspec version. It's not perfect, in that it only tests
the :ensure state, but that's where 90% of the behaviour is.
|
| |
|
|
|
|
| |
autotest config file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Puppet specs.
Created a spec/lib/monkey_patches/ directory for holding patches to RSpec functionality.
Extraced 'confine' and 'runnable?' support from the local copy of RSpec (spec/lib/spec/) and now load them from the monkey_patches/ directory.
Fixed a bad include in one of the specs.
Made it possible for the gem-installed spec binary (which autotest calls) to be used with Puppet.
Imported the Autotest::Rspec class, created a PuppetRspec autotest class, added a discovery.rb file for autotest to pick these up.
Autotest still has the following problems:
* it needs to be run with the proper include path:
% ruby -I spec/lib/ `which autotest`
* the patterns in our custom autotest handler (puppet_rspec) aren't yet fully specified (they
only recognize changes in our spec files, not changes in the puppet libs
which they are testing)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
single files, across modules, local file system,
and the traditional file server.
This work revolves around making sure that the termini
produce functional file instances, meaning that they
know how to find their content or metadata, which largely
comes down to setting their paths correctly.
I also created a new terminus base class for the local
filesystem, since there was so much common code between
content and metadata.
|
| |
|
|
|
|
| |
to :file.
|
|
|
|
|
|
|
|
|
|
| |
This was done by putting all of the functionality in the
Content and Metadata class (actually, in a new base class
for them).
There are still some issues, and there need to be integration
tests between the :local (soon to be renamed :file) termini for
these classes.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
module_files indirection terminus types. Both hooks
use the fileserver configuration, but the module_files
hook only uses the 'modules' mount.
Also moved all responsibility for knowing whether to
use the 'modules' terminus type to the terminus selector;
it was previously spread between that and the file_server
terminus, which made some things annoyingly complicated.
This normalizes the deprecation notices and the logic about
how we make these decisions.
|
|
|
|
| |
tests accordingly.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
use it, and added integration tests at the most important
hook points.
This provides the final class structure for all of these classes,
but a lot of the class names are pretty bad, so I'm planning on
going through all of them (especially the file_server stuff) and
renaming.
The functionality is all here for finding files, though (finally).
Once the classes are renamed, I'll be adding searching ability
(which will enable the recursive file copies) and then adding
the link management and enabling ignoring files.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
addition to Rest): A local terminus that just uses direct file paths,
and a mounts terminus that uses the file server to figure out what
the path should be.
It looks like it also makes sense to split the 'mounts' terminus further,
so there is a 'modules' terminus used to look files up in the terminus.
I've added some integration tests to verify that everything is
hooked together correctly.
Lastly, I added a directory for shared behaviours. There's a ton of
duplication in this setup, because the Content and Metadata classes
behave almost but not quite identically across the board.
|
| |
|
|
|
|
| |
and are used instead of the network handlers, which have been removed. There are some failing tests as a result, but I want to get this code committed before I massage the rest of the system to make it work again.
|