Permalink
Browse files

Added a watchr-based autobuilder.

  • Loading branch information...
1 parent 74db68f commit 891df0fc7999118c8fec4ea7e53b505cb9083050 Matt Burke committed Oct 26, 2009
Showing with 70 additions and 0 deletions.
  1. +69 −0 Rakefile
  2. +1 −0 autorake.rb
View
69 Rakefile
@@ -0,0 +1,69 @@
+require 'albacore'
+require 'rexml/document'
+
+module Rake
+ class MSBuildTask
+ def define
+ task name do
+ # This is in latest of albacore, so it can eventually be removed from here.
+ fail unless @msbuild.build
+ end
+ end
+ end
+end
+
+task :default => %W(
+ build
+ runtests
+ )
+
+def build task_name, *targets
+ build_properties = { :configuration => 'Debug', :platform => 'x86' }
+ build_properties.merge!(targets.pop) if Hash === targets.last
+ Rake::MSBuildTask.new(task_name) do |msb|
+ msb.properties build_properties
+ msb.targets targets
+ msb.solution = 'GitTfs.sln'
+ end
+end
+
+desc 'Build the entire solution'
+build :build, 'Build'
+
+desc 'Run the tests'
+task :runtests do
+ rm 'results.trx' if File.exist? 'results.trx'
+ mstest_cmd =%W(mstest
+ /testcontainer:GitTfsTest\\bin\\Debug\\GitTfsTest.dll
+ /resultsfile:results.trx)
+ sh(*mstest_cmd) do |ok, status|
+ analyze_tests('results.trx')
+ end
+end
+
+def analyze_tests(results_file)
+ fail_count = 0
+ File.open(results_file) do |file|
+ xml =REXML::Document.new(file)
+ xml.elements.each '//UnitTestResult[@outcome="Failed"]' do |e|
+ puts ''
+ puts '**********************************'
+ puts e.attributes['testName']
+ puts e.elements['Output/ErrorInfo/Message'].get_text.value
+ puts e.elements['Output/ErrorInfo/StackTrace'].get_text.value
+ %W(StdOut StdErr).each do |s|
+ show_stream e, s
+ end
+ puts ''
+ fail_count = fail_count.succ
+ end
+ end
+ fail "#{fail_count} tests failed" if fail_count > 0
+end
+
+def show_stream(e, s)
+ data = e.elements["Output/#{s}"]
+ if data
+ puts "#{s}:", data.get_text.value
+ end
+end
View
1 autorake.rb
@@ -0,0 +1 @@
+watch(/\.cs$/) { |m| system 'rake' }

0 comments on commit 891df0f

Please sign in to comment.