Skip to content

Commit

Permalink
Merge pull request #558 from puppetlabs/maint-fix_0_exit_code_on_failure
Browse files Browse the repository at this point in the history
(maint) - Fix failing tests exiting 0
  • Loading branch information
david22swan authored Apr 30, 2024
2 parents 55f7d1f + bd4c6e8 commit 144ba65
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions spec/lib/puppet_litmus/rake_tasks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
expect($stdout).to receive(:puts).with('redhat-5-x86_64')
expect($stdout).to receive(:puts).with('ubuntu-1404-x86_64')
expect($stdout).to receive(:puts).with('ubuntu-1804-x86_64')
allow_any_instance_of(Object).to receive(:exit)
Rake::Task['litmus:metadata'].invoke
end
end
Expand All @@ -44,7 +45,7 @@

expect_any_instance_of(Object).to receive(:install_module).with(inventory_hash, target_nodes, dummy_tar, args[:module_repository])
expect($stdout).to receive(:puts).with("Installed '#{dummy_tar}' on #{target_nodes.join(', ')}")

allow_any_instance_of(Object).to receive(:exit)
Rake::Task['litmus:install_module'].invoke(*args.values)
end

Expand Down Expand Up @@ -93,6 +94,7 @@
expect($stdout).to receive(:puts).with(start_with('Installing \'spec/data/doot.tar.gz\''))
expect_any_instance_of(Object).to receive(:run_command).twice.and_return([])
expect($stdout).to receive(:puts).with(start_with('Installed \'spec/data/doot.tar.gz\''))
allow_any_instance_of(Object).to receive(:exit)
Rake::Task['litmus:install_modules_from_directory'].invoke('./spec/fixtures/modules')
end
end
Expand All @@ -103,6 +105,7 @@
expect(Rake::Task['litmus:provision_list']).to receive(:invoke).with('default')
expect(Rake::Task['litmus:install_agent']).to receive(:invoke).with('puppet6')
expect(Rake::Task['litmus:install_module']).to receive(:invoke)
allow_any_instance_of(Object).to receive(:exit)
Rake::Task['litmus:provision_install'].invoke('default', 'puppet6')
end
end
Expand All @@ -126,7 +129,7 @@
allow_any_instance_of(BoltSpec::Run).to receive(:run_task).with(any_args).and_return(results)
allow_any_instance_of(PuppetLitmus::InventoryManipulation).to receive(:inventory_hash_from_inventory_file).with(any_args).and_return({})
allow_any_instance_of(PuppetLitmus::RakeHelper).to receive(:check_connectivity?).with(any_args).and_return(true)

allow_any_instance_of(Object).to receive(:exit)
expect { Rake::Task['litmus:provision'].invoke('docker', 'centos:7') }.to output(/#{expected_output}/).to_stdout
end
end
Expand All @@ -138,6 +141,7 @@
it 'no key in provision file' do
allow(File).to receive(:file?).with(any_args).and_return(true)
expect(YAML).to receive(:load_file).with(provision_file).and_return(provision_hash)
allow_any_instance_of(Object).to receive(:exit)
expect { Rake::Task['litmus:provision_list'].invoke('deet') }.to raise_error(/deet/)
end
end
Expand All @@ -149,6 +153,7 @@
stub_const('ENV', ENV.to_hash.merge('TARGET_HOST' => 'some.host'))
expect_any_instance_of(PuppetLitmus::InventoryManipulation).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
expect_any_instance_of(PuppetLitmus::RakeHelper).to receive(:check_connectivity?).with(inventory_hash, nil).and_return(true)
allow_any_instance_of(Object).to receive(:exit)
Rake::Task['litmus:check_connectivity'].invoke
end
end
Expand All @@ -157,6 +162,7 @@
it 'calls spec_prep' do
expect(Rake::Task['spec_prep']).to receive(:invoke).and_return('')
expect_any_instance_of(RSpec::Core::RakeTask).to receive(:run_task)
allow_any_instance_of(Object).to receive(:exit)
Rake::Task['litmus:acceptance:localhost'].invoke
end
end
Expand Down

0 comments on commit 144ba65

Please sign in to comment.