Merge pull request #4419 from inspec/cw/check-enforce-version

inspec check: warn if inspec_version is not supported by current inspec
This commit is contained in:
Clinton Wolfe 2019-08-27 20:03:19 -04:00 committed by GitHub
commit f90a4c633d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View file

@ -88,6 +88,10 @@ module Inspec
errors.push("Version needs to be in SemVer format") errors.push("Version needs to be in SemVer format")
end end
unless supports_runtime?
warnings.push("The current inspec version #{Inspec::VERSION} cannot satisfy profile inspec_version constraint #{params[:inspec_version]}")
end
%w{title summary maintainer copyright license}.each do |field| %w{title summary maintainer copyright license}.each do |field|
next unless params[field.to_sym].nil? next unless params[field.to_sym].nil?

View file

@ -106,4 +106,13 @@ describe "inspec check" do
assert_exit_code 1, out assert_exit_code 1, out
end end
end end
describe "inspec check with unsatisfied runtime version constraint" do
it "should enforce runtime version constraint" do
out = inspec("check #{profile_path}/unsupported_inspec")
out.stdout.must_include "The current inspec version #{Inspec::VERSION}"
out.stdout.must_include ">= 99.0.0"
assert_exit_code 1, out
end
end
end end

View file

@ -242,5 +242,10 @@ EOF
m = version_meta("> " + next_version) m = version_meta("> " + next_version)
m.supports_runtime?.must_equal false m.supports_runtime?.must_equal false
end end
it "is included in valid?" do
m = version_meta("> #{next_version}")
refute m.valid?
end
end end
end end