Skip to content

Commit

Permalink
Added a watchr-based autobuilder.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Burke committed Oct 26, 2009
1 parent 74db68f commit 891df0f
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
69 changes: 69 additions & 0 deletions 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
1 change: 1 addition & 0 deletions autorake.rb
@@ -0,0 +1 @@
watch(/\.cs$/) { |m| system 'rake' }

0 comments on commit 891df0f

Please sign in to comment.