Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a config option to debug failures #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/vagrant-spec/acceptance/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ class Configuration
# different depending on mode.
attr_accessor :run_mode

# Remove isolated environment on example failure. By default this
# is set to be true, but can be disabled by setting to false which
# will result in teardown skipping removal and messaging the output
# as to the paths retained.
attr_accessor :clean_on_fail

def initialize
@component_paths = [
Vagrant::Spec.source_root.join("acceptance"),
Expand All @@ -48,6 +54,7 @@ def initialize
@skeleton_paths = []
@vagrant_path = "vagrant"
@run_mode = "standalone"
@clean_on_fail = true
end

# Tells vagrant-spec to acceptance test a certain provider.
Expand Down
8 changes: 6 additions & 2 deletions lib/vagrant-spec/acceptance/rspec/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@
config.skeleton_paths.dup.unshift(root)
end

after(:each) do
environment.close
after(:each) do |example|
if example.exception.nil? || config.clean_on_fail
environment.close
else
example.reporter.message("Temporary work and home dirs (#{environment.workdir} and #{environment.homedir}) not removed to allow debug")
end
end

# Creates a new isolated environment instance each time it is called.
Expand Down