Permalink
Browse files

use Chef::Log to print MiniTest's output. Fix #32.

  • Loading branch information...
1 parent caa41cb commit a725968dbc5659b1d0434548fd0be245d188ac2c @calavera calavera committed Sep 16, 2012
Showing with 18 additions and 1 deletion.
  1. +2 −1 .gitignore
  2. +1 −0 examples/simple-solo/solo.rb
  3. +3 −0 lib/minitest-chef-handler.rb
  4. +12 −0 lib/minitest-chef-handler/core_ext.rb
View
@@ -15,4 +15,5 @@ spec/reports
test/tmp
test/version_tmp
tmp
-.vagrant
+.vagrant
+examples/simple-solo/chef.log
@@ -4,3 +4,4 @@
report_handlers << MiniTest::Chef::Handler.new(:path => path)
cookbook_path File.expand_path('cookbooks', File.dirname(__FILE__))
+log_location 'chef.log'
@@ -1,3 +1,4 @@
+require 'minitest-chef-handler/core_ext'
require 'minitest-chef-handler/context'
require 'minitest-chef-handler/resources'
require 'minitest-chef-handler/unit'
@@ -25,6 +26,8 @@ def report
require_test_suites(@options.delete(:path))
+ MiniTest::Unit.output = ::Chef::Log
+
if @options[:ci_reports]
ENV['CI_REPORTS'] = @options[:ci_reports]
runner = CIRunner.new(run_status)
@@ -0,0 +1,12 @@
+class Chef
+ class Log
+ def self.puts(*a)
+ self.<< "\n" if a.empty?
+ a.each {|m| self.<< m; self.<< "\n"}
+ end
+
+ def self.print(*a)
+ a.each {|m| self.<< m}
+ end
+ end
+end

1 comment on commit a725968

crekev commented on a725968 Nov 5, 2012

I solved the problem a bit different (git://gist.github.com/4016688.git). Your way is very elegant, but it leaves some important information out of the logs like the timestamps and formatting is not consistent.

Please sign in to comment.