diff options
author | Thom May <thom@chef.io> | 2016-05-17 11:42:12 +0100 |
---|---|---|
committer | Thom May <thom@chef.io> | 2016-06-22 12:09:28 +0100 |
commit | 848545b6038d05ea370ea69be783db1a881e9280 (patch) | |
tree | ffb8702b8d098f5ffc2bd0c73f98cd103b98a63e /spec/support | |
parent | 996301a9d073207fa37eed4d83dfae57d4501168 (diff) | |
download | chef-848545b6038d05ea370ea69be783db1a881e9280.tar.gz |
Add most common knife commands to integration teststm/knife_integration_tests
Signed-off-by: Thom May <thom@chef.io>
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/shared/integration/knife_support.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/spec/support/shared/integration/knife_support.rb b/spec/support/shared/integration/knife_support.rb index 1e81cd115c..398d90dff0 100644 --- a/spec/support/shared/integration/knife_support.rb +++ b/spec/support/shared/integration/knife_support.rb @@ -23,7 +23,7 @@ require "chef/log" module KnifeSupport DEBUG = ENV["DEBUG"] - def knife(*args) + def knife(*args, input: nil) # Allow knife('role from file roles/blah.json') rather than requiring the # arguments to be split like knife('role', 'from', 'file', 'roles/blah.json') # If any argument will have actual spaces in it, the long form is required. @@ -37,7 +37,7 @@ module KnifeSupport Chef::Config[:concurrency] = 1 # Work on machines where we can't access /var - checksums_cache_dir = Dir.mktmpdir("checksums") do |checksums_cache_dir| + Dir.mktmpdir("checksums") do |checksums_cache_dir| Chef::Config[:cache_options] = { :path => checksums_cache_dir, :skip_expires => true, @@ -47,6 +47,13 @@ module KnifeSupport # ourselves, thank you very much stdout = StringIO.new stderr = StringIO.new + + stdin = if input + StringIO.new(input) + else + STDIN + end + old_loggers = Chef::Log.loggers old_log_level = Chef::Log.level begin @@ -57,7 +64,7 @@ module KnifeSupport instance = subcommand_class.new(args) # Capture stdout/stderr - instance.ui = Chef::Knife::UI.new(stdout, stderr, STDIN, {}) + instance.ui = Chef::Knife::UI.new(stdout, stderr, stdin, disable_editing: true) # Don't print stuff Chef::Config[:verbosity] = ( DEBUG ? 2 : 0 ) |