Age | Commit message (Collapse) | Author | Files | Lines |
|
The constructor for the :flat filetype accepts a second argument now.
This second argument must be taken into account when stubbing specific
invocations.
|
|
Since ParsedFile maintains a global queue of records to be flushed and
attempts to flush all outstanding operations each time a resource is flushed,
any failed operations would be retried for each resource. This lead to
unrelated resources failing.
|
|
|
|
Previously, the parsed file provider was prefetching and reading from
/tmp/test, which failed if you happened to have a directory /tmp/test.
This commit updates the test to use a temporary and empty file from it
prefetches.
Paired-with: Rob Reynolds <rob@puppetlabs.com>
Paired-with: Kylo Ginsberg <kylo@puppetlabs.com>
|
|
|
|
The current behavior of read errors in file types is to raise a generic
error, which is difficult to rescue without rescuing everything. This
commit adds a new exception subclass that can be explicitly rescued
without rescuing every other error.
|
|
The parsedfile provider can handle multiple targets (multiple files,
multiple crontabs, etc) but the provider does not handle the case when
retrieving a target during prefetch fails. When the provider does only
handle one target this doesn't really matter because a possible error is
caught at a higher level (inside Puppet::Transaction). But if the
provider handles multiple targets, one error will cause the whole
prefetching method to fail and all targets are treated as empty.
One example of the issue is described in #5752: Multiple crontabs are
manages with crontab resources and one cronresource describes a
cronentry of an absent user. Because prefetching the crontab of the
absent user fails, the crontab of *all* users are purged and every
crontab entry which is not managed by puppet is lost.
The change now handles the error inside the parsedfile provider itself,
so only the target that is causing troubles is treated as empty.
|
|
This commit replaces the use of instance variables with `let` blocks in
the parsedfile provider specs.
|
|
The current test coverage for the ParsedFile provider uses an instance
variable referencing the class. This commit removes the instance
variable use and replaces them by setting `subject` to an anonymous
subclass of ParsedFile.
|
|
The initial implementation of the unit tests for a simple provider
inheriting ParsedFile was imperfect and full of repitition. The
restructuring makes the code reflect the semantics a lot better.
Based on suggestions from Adrien Thebo.
|
|
Some managed configurations (notably the vixie cron crontabs) are
automatically prefixed with headers not unlike those generated by
puppet providers themselves. This can lead to "mutual 1up" situations
in which puppet and the third party software will insert header upon
header in their respective output.
This change introduces the a "native header" for a parsed file. Providers
can define a regex object that will be used to identify the part of a parsed
file that comprises such a vendor header.
When writing the content back to disk, puppet will try and insert
its own header underneath the vendor's headers. Additionally, providers
can override a "drop native headers" field in order to have puppet
skip the vendor header alltogether when writing file contents. This allows
"smart" software like vixie cron to manage its header on its own.
The unit tests are based on example code kindly provided by Jeff McCune.
|
|
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.
|
|
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
|
|
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
|