1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
# frozen_string_literal: true
require "helper"
# Make sure that exit codes of tests are propagated properly
# See https://github.com/simplecov-ruby/simplecov/issues/5
describe "return codes" do
context "inside fixtures/frameworks" do
around do |test|
Dir.chdir(File.join(File.dirname(__FILE__), "fixtures", "frameworks")) do
FileUtils.rm_rf("./coverage")
test.call
end
end
before do
@stdout, @stderr, @status = Open3.capture3(command)
end
shared_examples "good tests" do
it "has a zero exit status" do
expect(@status.exitstatus).to be_zero
end
xit "prints nothing to STDERR" do
expect(@stderr).to be_empty
end
end
shared_examples "bad tests" do
context "with default configuration" do
it "has a non-zero exit status" do
expect(@status.exitstatus).not_to be_zero
end
it "prints a message to STDERR" do
expect(@stderr).to match(/stopped.+SimpleCov.+previous.+error/i)
end
end
context "when print_error_status is disabled" do
let(:command) { "PRINT_ERROR_STATUS=false #{super()}" }
it "has a non-zero exit status" do
expect(@status.exitstatus).not_to be_zero
end
xit "does not print anything to STDERR" do
expect(@stderr).to be_empty
end
end
end
context "when running testunit_good.rb" do
let(:command) { "#{RbConfig.ruby} testunit_good.rb" }
it_behaves_like "good tests"
end
context "when running rspec_good.rb" do
let(:command) { "rspec rspec_good.rb" }
it_behaves_like "good tests"
end
context "when running testunit_bad.rb" do
let(:command) { "#{RbConfig.ruby} testunit_bad.rb" }
it_behaves_like "bad tests"
end
context "when running rspec_bad.rb" do
let(:command) { "rspec rspec_bad.rb" }
it_behaves_like "bad tests"
end
end
end
|