##// END OF EJS Templates
Prevent test:scm:setup:* task to overwrite if the test repository already exists....
Jean-Philippe Lang -
r8929:55bbfa19b6ed
parent child
Show More
@@ -1,98 +1,104
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 --exclude gems/"
8 rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib --html --exclude gems/"
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 unless File.exists?(repo_path)
39 system "svnadmin create #{repo_path}"
40 system "svnadmin create #{repo_path}"
40 system "gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load #{repo_path}"
41 system "gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load #{repo_path}"
41 end
42 end
43 end
42
44
43 desc "Creates a test mercurial repository"
45 desc "Creates a test mercurial repository"
44 task :mercurial => :create_dir do
46 task :mercurial => :create_dir do
45 repo_path = "tmp/test/mercurial_repository"
47 repo_path = "tmp/test/mercurial_repository"
48 unless File.exists?(repo_path)
46 bundle_path = "test/fixtures/repositories/mercurial_repository.hg"
49 bundle_path = "test/fixtures/repositories/mercurial_repository.hg"
47 system "hg init #{repo_path}"
50 system "hg init #{repo_path}"
48 system "hg -R #{repo_path} pull #{bundle_path}"
51 system "hg -R #{repo_path} pull #{bundle_path}"
49 end
52 end
53 end
50
54
51 (supported_scms - [:subversion, :mercurial]).each do |scm|
55 (supported_scms - [:subversion, :mercurial]).each do |scm|
52 desc "Creates a test #{scm} repository"
56 desc "Creates a test #{scm} repository"
53 task scm => :create_dir do
57 task scm => :create_dir do
58 unless File.exists?("tmp/test/#{scm}_repository")
54 # system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test"
59 # system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test"
55 system "tar -xvz -C tmp/test -f test/fixtures/repositories/#{scm}_repository.tar.gz"
60 system "tar -xvz -C tmp/test -f test/fixtures/repositories/#{scm}_repository.tar.gz"
56 end
61 end
57 end
62 end
63 end
58
64
59 desc "Creates all test repositories"
65 desc "Creates all test repositories"
60 task :all => supported_scms
66 task :all => supported_scms
61 end
67 end
62
68
63 desc "Updates installed test repositories"
69 desc "Updates installed test repositories"
64 task :update do
70 task :update do
65 require 'fileutils'
71 require 'fileutils'
66 Dir.glob("tmp/test/*_repository").each do |dir|
72 Dir.glob("tmp/test/*_repository").each do |dir|
67 next unless File.basename(dir) =~ %r{^(.+)_repository$} && File.directory?(dir)
73 next unless File.basename(dir) =~ %r{^(.+)_repository$} && File.directory?(dir)
68 scm = $1
74 scm = $1
69 next unless fixture = Dir.glob("test/fixtures/repositories/#{scm}_repository.*").first
75 next unless fixture = Dir.glob("test/fixtures/repositories/#{scm}_repository.*").first
70 next if File.stat(dir).ctime > File.stat(fixture).mtime
76 next if File.stat(dir).ctime > File.stat(fixture).mtime
71
77
72 FileUtils.rm_rf dir
78 FileUtils.rm_rf dir
73 Rake::Task["test:scm:setup:#{scm}"].execute
79 Rake::Task["test:scm:setup:#{scm}"].execute
74 end
80 end
75 end
81 end
76
82
77 Rake::TestTask.new(:units => "db:test:prepare") do |t|
83 Rake::TestTask.new(:units => "db:test:prepare") do |t|
78 t.libs << "test"
84 t.libs << "test"
79 t.verbose = true
85 t.verbose = true
80 t.test_files = FileList['test/unit/repository*_test.rb'] + FileList['test/unit/lib/redmine/scm/**/*_test.rb']
86 t.test_files = FileList['test/unit/repository*_test.rb'] + FileList['test/unit/lib/redmine/scm/**/*_test.rb']
81 end
87 end
82 Rake::Task['test:scm:units'].comment = "Run the scm unit tests"
88 Rake::Task['test:scm:units'].comment = "Run the scm unit tests"
83
89
84 Rake::TestTask.new(:functionals => "db:test:prepare") do |t|
90 Rake::TestTask.new(:functionals => "db:test:prepare") do |t|
85 t.libs << "test"
91 t.libs << "test"
86 t.verbose = true
92 t.verbose = true
87 t.test_files = FileList['test/functional/repositories*_test.rb']
93 t.test_files = FileList['test/functional/repositories*_test.rb']
88 end
94 end
89 Rake::Task['test:scm:functionals'].comment = "Run the scm functional tests"
95 Rake::Task['test:scm:functionals'].comment = "Run the scm functional tests"
90 end
96 end
91
97
92 Rake::TestTask.new(:rdm_routing) do |t|
98 Rake::TestTask.new(:rdm_routing) do |t|
93 t.libs << "test"
99 t.libs << "test"
94 t.verbose = true
100 t.verbose = true
95 t.test_files = FileList['test/integration/routing/*_test.rb']
101 t.test_files = FileList['test/integration/routing/*_test.rb']
96 end
102 end
97 Rake::Task['test:rdm_routing'].comment = "Run the routing tests"
103 Rake::Task['test:rdm_routing'].comment = "Run the routing tests"
98 end
104 end
General Comments 0
You need to be logged in to leave comments. Login now