diff --git a/CHANGELOG.md b/CHANGELOG.md index 375c280d..3e36b243 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This changelog adheres to [Keep a CHANGELOG](https://keepachangelog.com). ## [Unreleased] - Bump minimum ruby requirement to 2.7 +- Fix preserve param default behaving like `always` but should be `on-failure` ## [0.52.0] - 2024-06-03 ### Added diff --git a/lib/vanagon/cli/build.rb b/lib/vanagon/cli/build.rb index 69c3f1ee..ef66b962 100644 --- a/lib/vanagon/cli/build.rb +++ b/lib/vanagon/cli/build.rb @@ -15,7 +15,7 @@ class Build < Vanagon::CLI -o, --only-build COMPONENT,COMPONENT,... Only build listed COMPONENTs -p, --preserve [RULE] Rule for VM preservation: never, on-failure, always - [Default: always] + [Default: on-failure] -r, --remote-workdir DIRECTORY Working directory on the remote host -s, --skipcheck Skip the "check" stage when building components -w, --workdir DIRECTORY Working directory on the local host diff --git a/lib/vanagon/driver.rb b/lib/vanagon/driver.rb index d598ba2b..95a661a6 100644 --- a/lib/vanagon/driver.rb +++ b/lib/vanagon/driver.rb @@ -24,7 +24,7 @@ def retry_count def initialize(platform, project, options = {}) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity @options = options @verbose = options[:verbose] || false - @preserve = options[:preserve] || false + @preserve = options[:preserve] || :'on-failure' @workdir = options[:workdir] || Dir.mktmpdir @@configdir = options[:configdir] || File.join(Dir.pwd, "configs") diff --git a/spec/lib/vanagon/cli_spec.rb b/spec/lib/vanagon/cli_spec.rb index 59aff35e..9845851d 100644 --- a/spec/lib/vanagon/cli_spec.rb +++ b/spec/lib/vanagon/cli_spec.rb @@ -1,18 +1,5 @@ require 'vanagon/cli' -## -## Ignore the CLI calling 'exit' -## -RSpec.configure do |rspec| - rspec.around(:example) do |ex| - begin - ex.run - rescue SystemExit => e - puts "Got SystemExit: #{e.inspect}. Ignoring" - end - end -end - describe Vanagon::CLI do describe "options that don't take a value" do [:skipcheck, :verbose].each do |flag| @@ -53,7 +40,7 @@ end it "preserve defaults to :on-failure" do subject = described_class.new - expect(subject.parse([])).to include(:preserve => :'on-failure') + expect(subject.parse(%W[build hello project platform])).to include(:preserve => :'on-failure') end end