Build fix for archive and vendor tests due to cookstyle offenses

Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
This commit is contained in:
Nikita Mathur 2021-08-19 15:02:50 +05:30
parent ab1d423a35
commit 1de38f3b13
4 changed files with 22 additions and 9 deletions

View file

@ -404,18 +404,23 @@ module Inspec
"--parallel",
"--only=InSpec/Deprecations,InSpec/Deprecations/AttributeHelper,InSpec/Deprecations/AttributeDefault",
]
spec.patterns += Dir.glob("#{@target}/**/*").reject { |f| File.directory?(f) || (f.include? "inspec.lock") }
spec.patterns += Dir.glob("#{@target}/**/*.rb").reject { |f| File.directory?(f) }
spec.fail_on_error = false
end
rescue LoadError
puts "Rubocop is not available. Install the rubocop gem to run the lint tests."
end
begin
stdout = StringIO.new
$stdout = stdout
Rake::Task["cookstyle_lint"].invoke
$stdout = STDOUT
Rake.application["cookstyle_lint"].reenable
stdout.string
rescue => e
puts "Cookstyle lint checks could not be performed. Error while running cookstyle - #{e}"
""
end
end
# Check if the profile is internally well-structured. The logger will be

View file

@ -235,6 +235,14 @@ module FunctionalHelper
end
end
def prepare_profiles(dir = nil, &block)
Dir.mktmpdir do |tmpdir|
FileUtils.cp_r(profile_path, tmpdir)
bn = File.basename(profile_path)
yield(File.join(tmpdir, bn, dir.to_s))
end
end
private
def assemble_env_prefix(env = {})

View file

@ -102,7 +102,7 @@ describe "inspec archive" do
end
it "vendors dependencies by default" do
prepare_examples("meta-profile") do |dir|
prepare_profiles("dependencies/inheritance") do |dir|
out = inspec("archive " + dir + " --output " + dst.path)
_(out.stderr).must_equal ""

View file

@ -155,7 +155,7 @@ describe "example inheritance profile" do
end
it "use lockfile in tarball" do
prepare_examples("meta-profile") do |dir|
prepare_profiles("dependencies/inheritance") do |dir|
# ensure the profile is vendored and packaged as tar
out = inspec("vendor " + dir + " --overwrite")