Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit 0408954

Browse files
committed
Throw a fatal error when 'strainer test' is called on a chef_repo with no arguments
1 parent b7ace47 commit 0408954

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/strainer/runner.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ def run!
6565
end
6666

6767
# Move the logfile back over
68-
FileUtils.mv(Strainer.logfile_path, Strainer.sandbox_path.join('strainer.out'))
68+
if File.exist?(Strainer.sandbox_path.join('strainer.out'))
69+
FileUtils.mv(Strainer.logfile_path, Strainer.sandbox_path.join('strainer.out'))
70+
end
6971

7072
if @report.values.collect(&:values).flatten.all?
7173
Strainer.ui.say "Strainer marked build OK"

lib/strainer/sandbox.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,15 @@ def initialize(cookbook_names, options = {})
3737
@options = options
3838

3939
if chef_repo?
40-
@cookbooks = load_cookbooks(cookbook_names)
40+
Strainer.ui.debug "Detected as a chef repo"
41+
if cookbook_names.empty?
42+
Strainer.ui.fatal "You must specify one or more cookbook names to `strainer test`!"
43+
exit(false)
44+
else
45+
@cookbooks = load_cookbooks(cookbook_names)
46+
end
4147
elsif cookbook_repo?
48+
Strainer.ui.debug "Detected as a cookbook repo"
4249
unless cookbook_names.empty?
4350
Strainer.ui.warn "Supply specific cookbooks to a cookbook_repo is not supported. Use `strainer test` with no arguments instead."
4451
end

0 commit comments

Comments
 (0)