##// END OF EJS Templates
Adds tasks to run scm tests: test:scm:units, test:scm:functionals and test:scm....
Jean-Philippe Lang -
r4432:339bcc97e0e1
parent child
Show More
@@ -1,41 +1,68
1 ### From http://svn.geekdaily.org/public/rails/plugins/generally_useful/tasks/coverage_via_rcov.rake
1 ### From http://svn.geekdaily.org/public/rails/plugins/generally_useful/tasks/coverage_via_rcov.rake
2
2
3 namespace :test do
3 namespace :test do
4 desc 'Measures test coverage'
4 desc 'Measures test coverage'
5 task :coverage do
5 task :coverage do
6 rm_f "coverage"
6 rm_f "coverage"
7 rm_f "coverage.data"
7 rm_f "coverage.data"
8 rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib --html"
8 rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib --html"
9 files = Dir.glob("test/**/*_test.rb").join(" ")
9 files = Dir.glob("test/**/*_test.rb").join(" ")
10 system("#{rcov} #{files}")
10 system("#{rcov} #{files}")
11 system("open coverage/index.html") if PLATFORM['darwin']
11 system("open coverage/index.html") if PLATFORM['darwin']
12 end
12 end
13
13
14 desc 'Run unit and functional scm tests'
15 task :scm do
16 errors = %w(test:scm:units test:scm:functionals).collect do |task|
17 begin
18 Rake::Task[task].invoke
19 nil
20 rescue => e
21 task
22 end
23 end.compact
24 abort "Errors running #{errors.to_sentence(:locale => :en)}!" if errors.any?
25 end
26
14 namespace :scm do
27 namespace :scm do
15 namespace :setup do
28 namespace :setup do
16 desc "Creates directory for test repositories"
29 desc "Creates directory for test repositories"
17 task :create_dir do
30 task :create_dir do
18 FileUtils.mkdir_p Rails.root + '/tmp/test'
31 FileUtils.mkdir_p Rails.root + '/tmp/test'
19 end
32 end
20
33
21 supported_scms = [:subversion, :cvs, :bazaar, :mercurial, :git, :darcs, :filesystem]
34 supported_scms = [:subversion, :cvs, :bazaar, :mercurial, :git, :darcs, :filesystem]
22
35
23 desc "Creates a test subversion repository"
36 desc "Creates a test subversion repository"
24 task :subversion => :create_dir do
37 task :subversion => :create_dir do
25 repo_path = "tmp/test/subversion_repository"
38 repo_path = "tmp/test/subversion_repository"
26 system "svnadmin create #{repo_path}"
39 system "svnadmin create #{repo_path}"
27 system "gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load #{repo_path}"
40 system "gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load #{repo_path}"
28 end
41 end
29
42
30 (supported_scms - [:subversion]).each do |scm|
43 (supported_scms - [:subversion]).each do |scm|
31 desc "Creates a test #{scm} repository"
44 desc "Creates a test #{scm} repository"
32 task scm => :create_dir do
45 task scm => :create_dir do
33 system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test"
46 system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test"
34 end
47 end
35 end
48 end
36
49
37 desc "Creates all test repositories"
50 desc "Creates all test repositories"
38 task :all => supported_scms
51 task :all => supported_scms
39 end
52 end
53
54 Rake::TestTask.new(:units => "db:test:prepare") do |t|
55 t.libs << "test"
56 t.verbose = true
57 t.test_files = FileList['test/unit/repository*_test.rb'] + FileList['test/unit/lib/redmine/scm/**/*_test.rb']
58 end
59 Rake::Task['test:scm:units'].comment = "Run the scm unit tests"
60
61 Rake::TestTask.new(:functionals => "db:test:prepare") do |t|
62 t.libs << "test"
63 t.verbose = true
64 t.test_files = FileList['test/functional/repositories*_test.rb']
65 end
66 Rake::Task['test:scm:functionals'].comment = "Run the scm unit tests"
40 end
67 end
41 end
68 end
General Comments 0
You need to be logged in to leave comments. Login now