From 25dbac50344e12918f5531b04dc5b2d32602b58e Mon Sep 17 00:00:00 2001 From: Jeffrey Clark Date: Sun, 4 Aug 2024 18:30:47 +0000 Subject: [PATCH] fix cli preserve param default and spec tests 27086b72 originally changed the preserve default to :on-failure, but 2e3ba3b1 erroneously changed it from on-failure to always, and the spec tests added in 94b87ccb never caught the discrepancy because the class abruptly exits due to invalid parameters in the tests --- CHANGELOG.md | 1 + lib/vanagon/cli/build.rb | 2 +- lib/vanagon/driver.rb | 2 +- spec/lib/vanagon/cli_spec.rb | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) 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..3ad67f41 100644 --- a/spec/lib/vanagon/cli_spec.rb +++ b/spec/lib/vanagon/cli_spec.rb @@ -53,7 +53,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