Class: MiniTest::Chef::Handler
- Inherits:
-
Chef::Handler
- Object
- Chef::Handler
- MiniTest::Chef::Handler
- Includes:
- Lookup
- Defined in:
- lib/minitest-chef-handler.rb
Instance Method Summary collapse
-
#custom_runner? ⇒ Boolean
Before Minitest 2.1.0 Minitest::Unit called ‘run` because the custom runners support was poorly designed.
-
#initialize(options = {}) ⇒ Handler
constructor
A new instance of Handler.
- #miniunit_options ⇒ Object
- #report ⇒ Object
Methods included from Lookup
#lookup_cookbook, #require_test_suites, #seen_recipes_paths, #used_recipe_names
Constructor Details
#initialize(options = {}) ⇒ Handler
Returns a new instance of Handler.
19 20 21 |
# File 'lib/minitest-chef-handler.rb', line 19 def initialize( = {}) @options = end |
Instance Method Details
#custom_runner? ⇒ Boolean
Before Minitest 2.1.0 Minitest::Unit called ‘run` because the custom runners support was poorly designed. See: github.com/seattlerb/minitest/commit/6023c879cf3d5169953ee929343b679de4a48bbc
Using this workaround we still allow to use any other runner with the test suite for versions greater than 2.1.0. If the test suite doesn’t use any chef injection capability it still can be ran with the default Minitest runner.
66 67 68 |
# File 'lib/minitest-chef-handler.rb', line 66 def custom_runner? Gem::Version.new(MiniTest::Unit::VERSION) >= Gem::Version.new('2.1.0') end |
#miniunit_options ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/minitest-chef-handler.rb', line 53 def = [] << ['-n', @options[:filter]] if @options[:filter] << "-v" if @options[:verbose] << ['-s', @options[:seed]] if @options[:seed] .flatten end |
#report ⇒ Object
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 |
# File 'lib/minitest-chef-handler.rb', line 23 def report # do not run tests if chef failed return if failed? require_test_suites(@options.delete(:path)) MiniTest::Unit.output = ::Chef::Log runner = if @options[:ci_reports] ENV['CI_REPORTS'] = @options[:ci_reports] CIRunner.new(run_status) else Runner.new(run_status) end result = if custom_runner? runner._run() else runner.run() end if result && result.nonzero? ::Chef::Client.when_run_completes_successfully do |run_status| error_msg = "MiniTest failed with #{runner.failures} failure(s) and #{runner.errors} error(s).\n" error_msg << runner.report.sort.join("\n") raise error_msg end end end |