Strip down plugin helper and change windows prefix execution.

Powershell doesn't use "&&" and we have it all over the tests.
Changing to ";".

Also starting to unify the plugin helper w/ the functional helper
since it has a LOT of duplication.

Signed-off-by: Ryan Davis <zenspider@chef.io>
This commit is contained in:
Ryan Davis 2019-08-14 14:26:46 -07:00
parent e60dc84188
commit a598356e12

View file

@ -12,6 +12,7 @@ require "tmpdir"
require "pathname"
require "forwardable"
require "functional/helper"
require "inspec/plugin/v2"
# Configure Minitest to expose things like `let`
@ -36,28 +37,24 @@ end
# end
# end
# TODO: remove me! There's no need!
module CorePluginBaseHelper
libdir = File.expand_path "lib"
let(:repo_path) { File.expand_path(File.join(__FILE__, "..", "..", "..", "..")) }
let(:inspec_path) { File.join(repo_path, "inspec-bin", "bin", "inspec") }
let(:exec_inspec) { [Gem.ruby, "-I#{libdir}", inspec_path].join " " }
let(:core_mock_path) { File.join(repo_path, "test", "fixtures") }
let(:core_fixture_plugins_path) { File.join(core_mock_path, "plugins") }
let(:core_config_dir_path) { File.join(core_mock_path, "config_dirs") }
let(:mock_path) { File.join(repo_path, "test", "fixtures", "mock") }
let(:core_fixture_plugins_path) { File.join(mock_path, "plugins") }
let(:core_config_dir_path) { File.join(mock_path, "config_dirs") }
let(:registry) { Inspec::Plugin::V2::Registry.instance }
end
require "functional/helper"
module CorePluginFunctionalHelper
include CorePluginBaseHelper
include FunctionalHelper
# TODO: so much duplication! Remove everything we can!
require "train"
TRAIN_CONNECTION = Train.create("local", command_runner: :generic).connection
# TODO: remove me! it's in test/functional/helper.rb
def run_inspec_process(command_line, opts = {})
prefix = ""
if opts.key?(:prefix)
@ -65,6 +62,7 @@ module CorePluginFunctionalHelper
elsif opts.key?(:env)
prefix = opts[:env].to_a.map { |assignment| "#{assignment[0]}=#{assignment[1]}" }.join(" ")
end
TRAIN_CONNECTION.run_command("#{prefix} #{exec_inspec} #{command_line}")
end