Skip to content

Commit

Permalink
fix cli preserve param default and spec tests
Browse files Browse the repository at this point in the history
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
  • Loading branch information
h0tw1r3 committed Aug 4, 2024
1 parent 7e96527 commit fa0f077
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/vanagon/cli/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/vanagon/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
15 changes: 1 addition & 14 deletions spec/lib/vanagon/cli_spec.rb
Original file line number Diff line number Diff line change
@@ -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|
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit fa0f077

Please sign in to comment.