@@ -1,41 +1,42 | |||
|
1 | 1 | desc "Run the Continous Integration tests for Redmine" |
|
2 | 2 | task :ci do |
|
3 | 3 | # RAILS_ENV and ENV[] can diverge so force them both to test |
|
4 | 4 | ENV['RAILS_ENV'] = 'test' |
|
5 | 5 | RAILS_ENV = 'test' |
|
6 | 6 | Rake::Task["ci:setup"].invoke |
|
7 | 7 | Rake::Task["ci:build"].invoke |
|
8 | 8 | Rake::Task["ci:teardown"].invoke |
|
9 | 9 | end |
|
10 | 10 | |
|
11 | 11 | # Tasks can be hooked into by redefining them in a plugin |
|
12 | 12 | namespace :ci do |
|
13 | 13 | desc "Setup Redmine for a new build." |
|
14 | 14 | task :setup do |
|
15 | 15 | Rake::Task["ci:dump_environment"].invoke |
|
16 | 16 | Rake::Task["db:create"].invoke |
|
17 | 17 | Rake::Task["db:migrate"].invoke |
|
18 | 18 | Rake::Task["db:schema:dump"].invoke |
|
19 | Rake::Task["test:scm:update"].invoke | |
|
19 | 20 | end |
|
20 | 21 | |
|
21 | 22 | desc "Build Redmine" |
|
22 | 23 | task :build do |
|
23 | 24 | Rake::Task["test"].invoke |
|
24 | 25 | end |
|
25 | 26 | |
|
26 | 27 | # Use this to cleanup after building or run post-build analysis. |
|
27 | 28 | desc "Finish the build" |
|
28 | 29 | task :teardown do |
|
29 | 30 | end |
|
30 | 31 | |
|
31 | 32 | desc "Dump the environment information to a BUILD_ENVIRONMENT ENV variable for debugging" |
|
32 | 33 | task :dump_environment do |
|
33 | 34 | |
|
34 | 35 | ENV['BUILD_ENVIRONMENT'] = ['ruby -v', 'gem -v', 'gem list'].collect do |command| |
|
35 | 36 | result = `#{command}` |
|
36 | 37 | "$ #{command}\n#{result}" |
|
37 | 38 | end.join("\n") |
|
38 | 39 | |
|
39 | 40 | end |
|
40 | 41 | end |
|
41 | 42 |
@@ -1,68 +1,82 | |||
|
1 | 1 | ### From http://svn.geekdaily.org/public/rails/plugins/generally_useful/tasks/coverage_via_rcov.rake |
|
2 | 2 | |
|
3 | 3 | namespace :test do |
|
4 | 4 | desc 'Measures test coverage' |
|
5 | 5 | task :coverage do |
|
6 | 6 | rm_f "coverage" |
|
7 | 7 | rm_f "coverage.data" |
|
8 | 8 | rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib --html" |
|
9 | 9 | files = Dir.glob("test/**/*_test.rb").join(" ") |
|
10 | 10 | system("#{rcov} #{files}") |
|
11 | 11 | system("open coverage/index.html") if PLATFORM['darwin'] |
|
12 | 12 | end |
|
13 | 13 | |
|
14 | 14 | desc 'Run unit and functional scm tests' |
|
15 | 15 | task :scm do |
|
16 | 16 | errors = %w(test:scm:units test:scm:functionals).collect do |task| |
|
17 | 17 | begin |
|
18 | 18 | Rake::Task[task].invoke |
|
19 | 19 | nil |
|
20 | 20 | rescue => e |
|
21 | 21 | task |
|
22 | 22 | end |
|
23 | 23 | end.compact |
|
24 | 24 | abort "Errors running #{errors.to_sentence(:locale => :en)}!" if errors.any? |
|
25 | 25 | end |
|
26 | 26 | |
|
27 | 27 | namespace :scm do |
|
28 | 28 | namespace :setup do |
|
29 | 29 | desc "Creates directory for test repositories" |
|
30 | 30 | task :create_dir do |
|
31 | 31 | FileUtils.mkdir_p Rails.root + '/tmp/test' |
|
32 | 32 | end |
|
33 | 33 | |
|
34 | 34 | supported_scms = [:subversion, :cvs, :bazaar, :mercurial, :git, :darcs, :filesystem] |
|
35 | 35 | |
|
36 | 36 | desc "Creates a test subversion repository" |
|
37 | 37 | task :subversion => :create_dir do |
|
38 | 38 | repo_path = "tmp/test/subversion_repository" |
|
39 | 39 | system "svnadmin create #{repo_path}" |
|
40 | 40 | system "gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load #{repo_path}" |
|
41 | 41 | end |
|
42 | 42 | |
|
43 | 43 | (supported_scms - [:subversion]).each do |scm| |
|
44 | 44 | desc "Creates a test #{scm} repository" |
|
45 | 45 | task scm => :create_dir do |
|
46 | 46 | system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test" |
|
47 | 47 | end |
|
48 | 48 | end |
|
49 | 49 | |
|
50 | 50 | desc "Creates all test repositories" |
|
51 | 51 | task :all => supported_scms |
|
52 | 52 | end |
|
53 | 53 | |
|
54 | desc "Updates installed test repositories" | |
|
55 | task :update do | |
|
56 | require 'fileutils' | |
|
57 | Dir.glob("tmp/test/*_repository").each do |dir| | |
|
58 | next unless File.basename(dir) =~ %r{^(.+)_repository$} && File.directory?(dir) | |
|
59 | scm = $1 | |
|
60 | next unless fixture = Dir.glob("test/fixtures/repositories/#{scm}_repository.*").first | |
|
61 | next if File.stat(dir).ctime > File.stat(fixture).mtime | |
|
62 | ||
|
63 | FileUtils.rm_rf dir | |
|
64 | Rake::Task["test:scm:setup:#{scm}"].execute | |
|
65 | end | |
|
66 | end | |
|
67 | ||
|
54 | 68 | Rake::TestTask.new(:units => "db:test:prepare") do |t| |
|
55 | 69 | t.libs << "test" |
|
56 | 70 | t.verbose = true |
|
57 | 71 | t.test_files = FileList['test/unit/repository*_test.rb'] + FileList['test/unit/lib/redmine/scm/**/*_test.rb'] |
|
58 | 72 | end |
|
59 | 73 | Rake::Task['test:scm:units'].comment = "Run the scm unit tests" |
|
60 | 74 | |
|
61 | 75 | Rake::TestTask.new(:functionals => "db:test:prepare") do |t| |
|
62 | 76 | t.libs << "test" |
|
63 | 77 | t.verbose = true |
|
64 | 78 | t.test_files = FileList['test/functional/repositories*_test.rb'] |
|
65 | 79 | end |
|
66 | 80 | Rake::Task['test:scm:functionals'].comment = "Run the scm functional tests" |
|
67 | 81 | end |
|
68 | 82 | end |
General Comments 0
You need to be logged in to leave comments.
Login now