free_mutant/lib/mutant/warning_expectation.rb
Markus Schirp 41d9700473 Refactor runer infrastructure
* Nuke around 800 lock
* Honor LSP with not anymore squeezing something non LSP compatible in
  the same inheritance tree.
* Separate running from result tree.
* Clean up kill logic and early exits on already dead mutations.
* Fix #runnin? smell for reporters.
* Decouple config object from VM state. Makes it serializable to enable
  config loading.
* Fix sequence of global VM events to match PRIOR rspec infects VM with
  gazillions of classes / modules. Thix fixes a startup speed
  degeneration.
* Various fixes to enhance determinism.
* Replace some unneded manual double dispatch with single manual dispatch for
  reporter / runners.
2014-07-05 23:04:38 +00:00

47 lines
1,007 B
Ruby

module Mutant
# A class to expect some warning message raising on absence of unexpected warnings
class WarningExpectation
include Adamantium::Flat, Concord.new(:expected)
# Error raised on expectation miss
class ExpectationError < RuntimeError
include Concord.new(:unexpected)
# Return exception message
#
# @return [String]
#
# @api private
#
def message
"Unexpected warnings: #{unexpected.inspect}"
end
end
# Execute blocks with warning expectations
#
# @return [self]
#
# @api private
#
def execute(&block)
warnings = WarningFilter.use do
block.call
end
missing = expected - warnings
unexpected = warnings - expected
if unexpected.any?
fail ExpectationError, unexpected
end
if missing.any?
$stderr.puts("Expected but missing warnings: #{missing}")
end
self
end
end # WarningExpectation
end # Mutant