voxpupuli / onceover

Your gateway drug to automated infrastructure testing with Puppet
Apache License 2.0
142 stars 45 forks source link

Phych::ParserError if controlrepo.yaml is missing #1

Closed GeoffWilliams closed 8 years ago

GeoffWilliams commented 8 years ago

If controlrepo_spec is run without a controlrepo.yaml file the user will get the following error:

geoff ~/github/r10k-control $ bundle exec rake controlrepo_spec
rake aborted!
NameError: uninitialized constant Psych::ParserError
/Library/Ruby/Gems/2.0.0/gems/controlrepo-2.0.1/lib/controlrepo/testconfig.rb:21:in `rescue in initialize'
/Library/Ruby/Gems/2.0.0/gems/controlrepo-2.0.1/lib/controlrepo/testconfig.rb:19:in `initialize'
/Library/Ruby/Gems/2.0.0/gems/controlrepo-2.0.1/lib/controlrepo/rake_tasks.rb:80:in `new'
/Library/Ruby/Gems/2.0.0/gems/controlrepo-2.0.1/lib/controlrepo/rake_tasks.rb:80:in `block in <top (required)>'
Tasks: TOP => controlrepo_spec => controlrepo_autotest_prep
(See full trace by running task with --trace)

On line 80 we can see the code is trying to open the controlrepo.yaml file:

@config = Controlrepo::TestConfig.new("#{@repo.spec_dir}/controlrepo.yaml")

Suggested fix

Exit if the controlrepo.yaml file is missing

GeoffWilliams commented 8 years ago

Even better - ship a default controlrepo.yaml inside the gem and use that if no customised version is present - does it/can it make sense to do this?

dylanratcliffe commented 8 years ago

This does make sense, a lot of the code to do it is already there too, will do