##// END OF EJS Templates
scm: mercurial: test:scm:setup:mercurial task can be simpler (#7272)....
Toshi MARUYAMA -
r4563:35b9972c8199
parent child
Show More
@@ -1,93 +1,89
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'
14 desc 'Run unit and functional scm tests'
15 task :scm do
15 task :scm do
16 errors = %w(test:scm:units test:scm:functionals).collect do |task|
16 errors = %w(test:scm:units test:scm:functionals).collect do |task|
17 begin
17 begin
18 Rake::Task[task].invoke
18 Rake::Task[task].invoke
19 nil
19 nil
20 rescue => e
20 rescue => e
21 task
21 task
22 end
22 end
23 end.compact
23 end.compact
24 abort "Errors running #{errors.to_sentence(:locale => :en)}!" if errors.any?
24 abort "Errors running #{errors.to_sentence(:locale => :en)}!" if errors.any?
25 end
25 end
26
26
27 namespace :scm do
27 namespace :scm do
28 namespace :setup do
28 namespace :setup do
29 desc "Creates directory for test repositories"
29 desc "Creates directory for test repositories"
30 task :create_dir do
30 task :create_dir do
31 FileUtils.mkdir_p Rails.root + '/tmp/test'
31 FileUtils.mkdir_p Rails.root + '/tmp/test'
32 end
32 end
33
33
34 supported_scms = [:subversion, :cvs, :bazaar, :mercurial, :git, :darcs, :filesystem]
34 supported_scms = [:subversion, :cvs, :bazaar, :mercurial, :git, :darcs, :filesystem]
35
35
36 desc "Creates a test subversion repository"
36 desc "Creates a test subversion repository"
37 task :subversion => :create_dir do
37 task :subversion => :create_dir do
38 repo_path = "tmp/test/subversion_repository"
38 repo_path = "tmp/test/subversion_repository"
39 system "svnadmin create #{repo_path}"
39 system "svnadmin create #{repo_path}"
40 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}"
41 end
41 end
42
42
43 desc "Creates a test mercurial repository"
43 desc "Creates a test mercurial repository"
44 task :mercurial => :create_dir do
44 task :mercurial => :create_dir do
45 repo_path = "tmp/test/mercurial_repository"
45 repo_path = "tmp/test/mercurial_repository"
46 FileUtils.mkdir_p repo_path
46 bundle_path = "test/fixtures/repositories/mercurial_repository.hg"
47 Dir.chdir repo_path do
47 system "hg clone -U #{bundle_path} #{repo_path}"
48 system "hg init"
49 system "hg unbundle ../../../test/fixtures/repositories/mercurial_repository.hg"
50 system "hg update"
51 end
52 end
48 end
53
49
54 (supported_scms - [:subversion, :mercurial]).each do |scm|
50 (supported_scms - [:subversion, :mercurial]).each do |scm|
55 desc "Creates a test #{scm} repository"
51 desc "Creates a test #{scm} repository"
56 task scm => :create_dir do
52 task scm => :create_dir do
57 system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test"
53 system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test"
58 end
54 end
59 end
55 end
60
56
61 desc "Creates all test repositories"
57 desc "Creates all test repositories"
62 task :all => supported_scms
58 task :all => supported_scms
63 end
59 end
64
60
65 desc "Updates installed test repositories"
61 desc "Updates installed test repositories"
66 task :update do
62 task :update do
67 require 'fileutils'
63 require 'fileutils'
68 Dir.glob("tmp/test/*_repository").each do |dir|
64 Dir.glob("tmp/test/*_repository").each do |dir|
69 next unless File.basename(dir) =~ %r{^(.+)_repository$} && File.directory?(dir)
65 next unless File.basename(dir) =~ %r{^(.+)_repository$} && File.directory?(dir)
70 scm = $1
66 scm = $1
71 next unless fixture = Dir.glob("test/fixtures/repositories/#{scm}_repository.*").first
67 next unless fixture = Dir.glob("test/fixtures/repositories/#{scm}_repository.*").first
72 next if File.stat(dir).ctime > File.stat(fixture).mtime
68 next if File.stat(dir).ctime > File.stat(fixture).mtime
73
69
74 FileUtils.rm_rf dir
70 FileUtils.rm_rf dir
75 Rake::Task["test:scm:setup:#{scm}"].execute
71 Rake::Task["test:scm:setup:#{scm}"].execute
76 end
72 end
77 end
73 end
78
74
79 Rake::TestTask.new(:units => "db:test:prepare") do |t|
75 Rake::TestTask.new(:units => "db:test:prepare") do |t|
80 t.libs << "test"
76 t.libs << "test"
81 t.verbose = true
77 t.verbose = true
82 t.test_files = FileList['test/unit/repository*_test.rb'] + FileList['test/unit/lib/redmine/scm/**/*_test.rb']
78 t.test_files = FileList['test/unit/repository*_test.rb'] + FileList['test/unit/lib/redmine/scm/**/*_test.rb']
83 end
79 end
84 Rake::Task['test:scm:units'].comment = "Run the scm unit tests"
80 Rake::Task['test:scm:units'].comment = "Run the scm unit tests"
85
81
86 Rake::TestTask.new(:functionals => "db:test:prepare") do |t|
82 Rake::TestTask.new(:functionals => "db:test:prepare") do |t|
87 t.libs << "test"
83 t.libs << "test"
88 t.verbose = true
84 t.verbose = true
89 t.test_files = FileList['test/functional/repositories*_test.rb']
85 t.test_files = FileList['test/functional/repositories*_test.rb']
90 end
86 end
91 Rake::Task['test:scm:functionals'].comment = "Run the scm functional tests"
87 Rake::Task['test:scm:functionals'].comment = "Run the scm functional tests"
92 end
88 end
93 end
89 end
General Comments 0
You need to be logged in to leave comments. Login now