Friday, October 17, 2008

Rake task example for CruiseControl.rb using xcode

testing Xcode using cruisecontrol rb.
create a Rakefile in your trunk directory
assuming your directory structure is something like
trunk/
------- app/
------- tests/
    1 require 'rubygems'
2 require 'rake'
3
4 class FailedTestsException < Exception;end
5 class FailedBuildException < Exception;end
6 class FailedCleanException < Exception;end
7 task :default => 'test:all'
8
9 namespace :test do
10
11 current_dir = File.dirname(__FILE__)
12 test_dir = "#{current_dir}/tests/googleUnitTests"
13 ENV['DYLD_FRAMEWORK_PATH'] = \
14 "#{current_dir}/tests/gtest-1.1.0/xcode/build/Release"
15 Dir.chdir(test_dir)
16
17
18 desc "clean out the build directory"
19 task :clean do
20 clean_result = %x{xcodebuild clean}
21 print clean_result
22 if clean_result.match(/error/i)
23 puts "clean failed"
24 throw FailedCleanException.new
25 end
26 end
27
28 desc "build the test executable"
29 task :build do
30 build_result = \
31 %x{xcodebuild -target UnitTests -configuration Release}
32 print build_result
33 if build_result.match(/error/i)
34 puts "build failed"
35 throw FailedBuildException.new
36 end
37 end
38
39 desc "run the tests"
40 task :run => :build do
41 test_result = %x{#{test_dir}/build/Release/UnitTests}
42 print test_result
43 if test_result.match(/FAILED TEST/i)
44 puts "tests failed"
45 throw FailedTestsException.new
46 end
47 end
48
49 desc "run a full clean and build then run"
50 task :all => [ :clean, :build , :run]
51
52 end
53


No comments:

Post a Comment