Skip to content

Commit fa0f077

Browse files
committed
fix cli preserve param default and spec tests
27086b7 originally changed the preserve default to :on-failure, but 2e3ba3b erroneously changed it from on-failure to always, and the spec tests added in 94b87cc never caught the discrepancy because the class abruptly exits due to invalid parameters in the tests
1 parent 7e96527 commit fa0f077

File tree

4 files changed

+4
-16
lines changed

4 files changed

+4
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This changelog adheres to [Keep a CHANGELOG](https://keepachangelog.com).
66

77
## [Unreleased]
88
- Bump minimum ruby requirement to 2.7
9+
- Fix preserve param default behaving like `always` but should be `on-failure`
910

1011
## [0.52.0] - 2024-06-03
1112
### Added

lib/vanagon/cli/build.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Build < Vanagon::CLI
1515
-o, --only-build COMPONENT,COMPONENT,...
1616
Only build listed COMPONENTs
1717
-p, --preserve [RULE] Rule for VM preservation: never, on-failure, always
18-
[Default: always]
18+
[Default: on-failure]
1919
-r, --remote-workdir DIRECTORY Working directory on the remote host
2020
-s, --skipcheck Skip the "check" stage when building components
2121
-w, --workdir DIRECTORY Working directory on the local host

lib/vanagon/driver.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def retry_count
2424
def initialize(platform, project, options = {}) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
2525
@options = options
2626
@verbose = options[:verbose] || false
27-
@preserve = options[:preserve] || false
27+
@preserve = options[:preserve] || :'on-failure'
2828
@workdir = options[:workdir] || Dir.mktmpdir
2929

3030
@@configdir = options[:configdir] || File.join(Dir.pwd, "configs")

spec/lib/vanagon/cli_spec.rb

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
11
require 'vanagon/cli'
22

3-
##
4-
## Ignore the CLI calling 'exit'
5-
##
6-
RSpec.configure do |rspec|
7-
rspec.around(:example) do |ex|
8-
begin
9-
ex.run
10-
rescue SystemExit => e
11-
puts "Got SystemExit: #{e.inspect}. Ignoring"
12-
end
13-
end
14-
end
15-
163
describe Vanagon::CLI do
174
describe "options that don't take a value" do
185
[:skipcheck, :verbose].each do |flag|
@@ -53,7 +40,7 @@
5340
end
5441
it "preserve defaults to :on-failure" do
5542
subject = described_class.new
56-
expect(subject.parse([])).to include(:preserve => :'on-failure')
43+
expect(subject.parse(%W[build hello project platform])).to include(:preserve => :'on-failure')
5744
end
5845
end
5946

0 commit comments

Comments
 (0)