Age | Commit message (Collapse) | Author | Files | Lines |
|
The test of behavior when a module directory is specified as part of an
environment but is missing on disk was hidden inside another test. This
splits it out and calls out that the behavior is that the directory is
simply ignored.
|
|
When a previous commit changed from get() to get!() the agent stopped
being able to use an environment that is available on the master, but
not available locally. I had misread the code and missed a trailing
`&&`. This caused me to think that the environment lookup in this case
was required, where in fact it is still optional.
This changes the structure of the code to make it much clearer that the
environment is optional, changes from get!() to get(), and adds some
tests around these code paths.
|
|
The tests were often creating environments that didn't need to have
manifests. Since we didn't have a way of specifying that when they
were written, we used '' to fill in the blank. This actually caused a
large number of tests to try to find code to load in the PWD, which
caused tests to break if a developer had parse errors in manifests being
used for testing in the root directory of their puppet project. This
changes the manifest to be optional and removes '' from those tests. The
tests no longer fail if a bad manifest is in the PWD :D
|
|
Instead of creating environments directly, we need to go through the
configured environment loaders, otherwise environments can't come from
other places.
|
|
This changes the loader used by the code to list environments to be a
composition of the legacy environments and the new directory
environments.
|
|
|
|
The monolithic settings infrastructure is really hard to work with. In
order to implement the functionality for puppet config print to reliably
be able to print the value of any given section of the configuration I
need to be able to split it apart from the very static structure that
exists inside puppet. This takes a step in that direction by starting
the process of extracting the lookup logic into smaller classes.
|
|
- All previous File and FileTest calls to exist? or exists? go through
the new FileSystem::File abstraction so that the implementation can
later be swapped for a Windows specific one to support symlinks
|
|
Several places use an Autoloader to list files that could be loaded
relative to some prefix, e.g. puppet/application. But then the same
prefix is specified again when requiring a specific instance, e.g.
require File.join('puppet', 'application', name)
This commit adds an Autoload instance method to expand a path, so the
above becomes:
require @loader.expand(name)
|
|
jeffmccune/fix/master/7316_load_faces_from_modulepath_try4"
This reverts commit bdda511d06ed6f89b58343e815585957a33db94e, reversing
changes made to 8f9699cee0d1028d538b0a26aa5bc885751b6d46.
Conflicts:
lib/puppet/settings/config_file.rb
|
|
into 3.x""
This reverts commit ef3fe695fd0be5ff2b5aeb563f34f62a0f503831.
|
|
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,'
|
|
This reverts commit b277bb3874ecd50e1cd6e600bf6d36e3240d5510, reversing
changes made to bdf193640701e9a107b1c6f6661499b31fdefb4d.
These changes are being backed out because they referenced a undefined
methods (`default_global_config_dir` and `default_global_var_dir`).
After fixing that locally, there was still a problem with `puppet help`
printing out a large number of warnings because it could not load face
code correctly.
I think we need to step back from this, re-evaluate what is happening,
and try a new approach.
|
|
Prior to this commit, the vardir and confdir settings were tied to
run_mode. This caused a chicken-and-egg problem where you could not
initialize the confdir and vardir until you'd loaded the
application/subcommand, because that is the first point in time where
you'd know the run_mode. However, without knowing the confdir/vardir
ahead of time, it's impossible to know where all you might need to look
to try to find the application/subcommand for loading.
This commit decouples those settings from run_mode. The default values
for them are now set solely based on whether the user is root or not.
Individual applications may override these defaults a bit later in the
life cycle (e.g., 'master' does this).
Conflicts:
lib/puppet/settings.rb
lib/puppet/util/autoload.rb
lib/puppet/util/run_mode.rb
spec/unit/util/run_mode_spec.rb
|
|
Previously the list of rubygem directories was kept in a thread local
cache. Instead of doing that outright we'll try relying on the rubygem
caching before we go down the path of trying to do that ourselves.
|
|
The autoloader includes rubygems in the search path when searching for
modules to load. Puppet can now load things like Faces, report
processors, and parser functions using rubygems.
Example:
$ gem install puppetlabs-cloud_provisioner-1.0.4.gem
...
Successfully installed fog-1.3.1
Successfully installed guid-0.1.1
Successfully installed puppetlabs-cloud_provisioner-1.0.4
$ puppet help
Usage: puppet <subcommand> [options] <action> [options]
Available subcommands:
...
node_aws View and manage Amazon AWS EC2 nodes.
This patch adds a new `Puppet::Util::RubyGems#directories` method for
locating the latest gems and their load paths. This method is used in
two places:
* When searching for subcommands
* When auto loading plug-ins
Updated specs are included.
|
|
Many tests set stubs or expectations on configuration values. This is
unnecessary, as settings are reset before each test. Because creating a stub
stubs out the entire value method on settings, stubbing any individual setting
interferes with retrieving any other setting. This makes for weird errors and
fragile tests. This commit changes most cases to just set each setting
directly.
Expectations on settings were often used to verify that a setting is used.
This is not a good way of testing this, since it checks that the value is
accessed but not that it is actually used correctly. Most expecations on
settings are better expressed by changing the setting and then verifying a
returned value.
|
|
|
|
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.
|
|
Since I didn't get around to adding a require method to the autoloader, it
still makes sense to have the loaded? method exposed on instances. I also
added the changed? method, which would be useful in similar situations.
Testing these changes revealed inconsistency about how names are normalized,
which is also fixed in this commit.
|
|
Just using Pathname#cleanpath didn't properly convert \ to / on windows. Using
both should give correct normalized paths. This also cleans up the specs to
work better with Windows paths, as problems there were revealed by this
change.
|
|
Now we have passing tests on Ruby 1.9, we can make all those tags go away and
enable the full suite. Now anything that fails should be treated like a real
failure, which is reasonable since this is a real and supported platform.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
In Ruby 1.8 `"foo".map` would yield "foo" once, while in Ruby 1.9 it is not
defined as a method.
Various parts of our testing code stub other methods and return strings where
arrays of strings are appropriate; this historically worked because of that
1.8 shim, and no longer does.
The same is true of `String#each`, which fails in the same way.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
Major changes include:
* support multiple config files (/etc/puppet, ~/.puppet). we no longer
use "run_mode" to determine the location of the config file.
* remove all references to application run_mode/state from defaults
* make the typing of settings a little more strict
* create a new setting type for directories, to make us a little less vulnerable to the terrible matching algorithm in FileSetting
|
|
When setting libdir the path is expanded, so using the actual libdir setting
in the test instead of expecting it to remain what we initially set it to.
|
|
|
|
|
|
Prior to this change, if a file is loaded, and a new version is placed at a
higher priority location in the load path, reload_changed would not detect it.
This makes it properly detected so the first copy in the load path at the time
reload_changed is called will always be loaded.
|
|
This cache module was complex and had obvious bugs in it, and it's not clear
that it was necessary. We'll add something back if it turns out we needed to
cache file operations in the autoloader.
|
|
This adds a reload_changed method to the autoloader. It checks all loaded
files for changes (based on the mtime of the files) and reload any paths that
have changed. Deleted files are still listed as loaded since there is no way
to actually unload code in Ruby.
|
|
|
|
This consolidates all the the loading logic into the singleton associated with
the Autoload class. The Autoload instance is now a thin proxy to this
singleton. This may not seem like an improvement in the short term but it lays
the groundwork for reloading support. Having the logic in the singleton gives
load methods access to the full tree of loaded files, which will be necessary
when we want to reload all changed files.
|
|
In preparation for refactoring, this adds some specs for the autoloader and
cleans up the depedency on PuppetSpec in the existing specs.
|
|
|
|
In the past, Puppet::Util::Autoload used a cached_attr for its 'searchpath'.
However, it no longer does that, so its references to Puppet::Util::Cacher are
unnecessary.
Reviewed-By: Jacob Helwig <jacob@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>
|
|
If the user's path has duplicate entries, we end up looking at them
multiple times. This has bitten people in the past in that if you get a
lot of duplication it can make autloading a lot slower. Really the user
shouldn't be duplicating their path, but since we can't control that,
this is a safe fix to prevent them from having autoload slowness.
Paired-with: Max Martin <max@puppetlabs.com>
|
|
By running:
rspec spec --tag ~@fails_on_ruby_1.9.2
We can now just run the specs that pass under Ruby 1.9. Obviously in
the long term we want to have all the specs passing, but until then we
need notification when we regress. From now on new code will be
required to pass under Ruby 1.9, and Jenkins will give us email
notification if it doesn't or if we break something that was already
working.
Reviewed-by: Daniel Pittman <daniel@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.
|
|
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>
|
|
Running the specs under Ruby 1.9 didn't work using the lambda to recurse
down directories to find the spec_helper. Standardizing the way to find
spec_helper like the rest of specs seemed like the way to go.
Here's the command line perl I used to make the change:
perl -p -i -e "s/Dir.chdir.*lambda.*spec_helper.*$/require
File.expand_path(File.dirname(__FILE__) + '\/..\/..\/spec_helper')/"
`find spec -name "*_spec.rb"`
Then I fixed the number of dots for files that weren't two levels from
the spec dir and whose tests failed.
Reviewed-by: Nick Lewis <nick@puppetlabs.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
|
|
* Replaced 36 occurances of [$][?] with $CHILD_STATUS
3 Examples:
The code:
print "%s finished with exit code %s\n" % [host, $?.exitstatus]
becomes:
print "%s finished with exit code %s\n" % [host, $CHILD_STATUS.exitstatus]
The code:
$stderr.puts "Could not find host for PID %s with status %s" % [pid, $?.exitstatus]
becomes:
$stderr.puts "Could not find host for PID %s with status %s" % [pid, $CHILD_STATUS.exitstatus]
The code:
unless $? == 0
becomes:
unless $CHILD_STATUS == 0
* Replaced 3 occurances of [$][$] with $PID
3 Examples:
The code:
Process.kill(:HUP, $$) if restart_requested?
becomes:
Process.kill(:HUP, $PID) if restart_requested?
The code:
if pid == $$
becomes:
if pid == $PID
The code:
host[:name] = "!invalid.hostname.$$$"
becomes:
host[:name] = "!invalid.hostname.$PID$"
* Replaced 7 occurances of [$]& with $MATCH
3 Examples:
The code:
work.slice!(0, $&.length)
becomes:
work.slice!(0, $MATCH.length)
The code:
if $&
becomes:
if $MATCH
The code:
if $&
becomes:
if $MATCH
* Replaced 28 occurances of [$]:(?!:) with $LOAD_PATH
3 Examples:
The code:
sitelibdir = $:.find { |x| x =~ /site_ruby/ }
becomes:
sitelibdir = $LOAD_PATH.find { |x| x =~ /site_ruby/ }
The code:
$:.unshift "lib"
becomes:
$LOAD_PATH.unshift "lib"
The code:
$:.shift
becomes:
$LOAD_PATH.shift
* Replaced 3 occurances of [$]! with $ERROR_INFO
3 Examples:
The code:
$LOG.fatal("Problem reading #{filepath}: #{$!}")
becomes:
$LOG.fatal("Problem reading #{filepath}: #{$ERROR_INFO}")
The code:
$stderr.puts "Couldn't build man pages: " + $!
becomes:
$stderr.puts "Couldn't build man pages: " + $ERROR_INFO
The code:
$stderr.puts $!.message
becomes:
$stderr.puts $ERROR_INFO.message
* Replaced 3 occurances of ^(.*)[$]" with \1$LOADED_FEATURES
3 Examples:
The code:
unless $".index 'racc/parser.rb'
becomes:
unless $LOADED_FEATURES.index 'racc/parser.rb'
The code:
$".push 'racc/parser.rb'
becomes:
$LOADED_FEATURES.push 'racc/parser.rb'
The code:
$".should be_include("tmp/myfile.rb")
becomes:
$LOADED_FEATURES.should be_include("tmp/myfile.rb")
|
|
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
|