##// END OF EJS Templates
split method for scm test repository extracting (#16881)...
Toshi MARUYAMA -
r12861:4b0f418c801a
parent child
Show More
@@ -1,110 +1,114
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 --exclude gems/"
9 9 files = %w(unit functional integration).map {|dir| Dir.glob("test/#{dir}/**/*_test.rb")}.flatten.join(" ")
10 10 system("#{rcov} #{files}")
11 11 end
12 12
13 13 desc 'Run unit and functional scm tests'
14 14 task :scm do
15 15 errors = %w(test:scm:units test:scm:functionals).collect do |task|
16 16 begin
17 17 Rake::Task[task].invoke
18 18 nil
19 19 rescue => e
20 20 task
21 21 end
22 22 end.compact
23 23 abort "Errors running #{errors.to_sentence(:locale => :en)}!" if errors.any?
24 24 end
25 25
26 26 namespace :scm do
27 27 namespace :setup do
28 28 desc "Creates directory for test repositories"
29 29 task :create_dir => :environment do
30 30 FileUtils.mkdir_p Rails.root + '/tmp/test'
31 31 end
32 32
33 33 supported_scms = [:subversion, :cvs, :bazaar, :mercurial, :git, :darcs, :filesystem]
34 34
35 35 desc "Creates a test subversion repository"
36 36 task :subversion => :create_dir do
37 37 repo_path = "tmp/test/subversion_repository"
38 38 unless File.exists?(repo_path)
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 end
43 43
44 44 desc "Creates a test mercurial repository"
45 45 task :mercurial => :create_dir do
46 46 repo_path = "tmp/test/mercurial_repository"
47 47 unless File.exists?(repo_path)
48 48 bundle_path = "test/fixtures/repositories/mercurial_repository.hg"
49 49 system "hg init #{repo_path}"
50 50 system "hg -R #{repo_path} pull #{bundle_path}"
51 51 end
52 52 end
53 53
54 def extract_tar_gz(prefix)
55 unless File.exists?("tmp/test/#{prefix}_repository")
56 # system "gunzip < test/fixtures/repositories/#{prefix}_repository.tar.gz | tar -xv -C tmp/test"
57 system "tar -xvz -C tmp/test -f test/fixtures/repositories/#{prefix}_repository.tar.gz"
58 end
59 end
60
54 61 (supported_scms - [:subversion, :mercurial]).each do |scm|
55 62 desc "Creates a test #{scm} repository"
56 63 task scm => :create_dir do
57 unless File.exists?("tmp/test/#{scm}_repository")
58 # system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test"
59 system "tar -xvz -C tmp/test -f test/fixtures/repositories/#{scm}_repository.tar.gz"
60 end
64 extract_tar_gz(scm)
61 65 end
62 66 end
63 67
64 68 desc "Creates all test repositories"
65 69 task :all => supported_scms
66 70 end
67 71
68 72 desc "Updates installed test repositories"
69 73 task :update => :environment do
70 74 require 'fileutils'
71 75 Dir.glob("tmp/test/*_repository").each do |dir|
72 76 next unless File.basename(dir) =~ %r{^(.+)_repository$} && File.directory?(dir)
73 77 scm = $1
74 78 next unless fixture = Dir.glob("test/fixtures/repositories/#{scm}_repository.*").first
75 79 next if File.stat(dir).ctime > File.stat(fixture).mtime
76 80
77 81 FileUtils.rm_rf dir
78 82 Rake::Task["test:scm:setup:#{scm}"].execute
79 83 end
80 84 end
81 85
82 86 Rake::TestTask.new(:units => "db:test:prepare") do |t|
83 87 t.libs << "test"
84 88 t.verbose = true
85 89 t.test_files = FileList['test/unit/repository*_test.rb'] + FileList['test/unit/lib/redmine/scm/**/*_test.rb']
86 90 end
87 91 Rake::Task['test:scm:units'].comment = "Run the scm unit tests"
88 92
89 93 Rake::TestTask.new(:functionals => "db:test:prepare") do |t|
90 94 t.libs << "test"
91 95 t.verbose = true
92 96 t.test_files = FileList['test/functional/repositories*_test.rb']
93 97 end
94 98 Rake::Task['test:scm:functionals'].comment = "Run the scm functional tests"
95 99 end
96 100
97 101 Rake::TestTask.new(:rdm_routing) do |t|
98 102 t.libs << "test"
99 103 t.verbose = true
100 104 t.test_files = FileList['test/integration/routing/*_test.rb']
101 105 end
102 106 Rake::Task['test:rdm_routing'].comment = "Run the routing tests"
103 107
104 108 Rake::TestTask.new(:ui => "db:test:prepare") do |t|
105 109 t.libs << "test"
106 110 t.verbose = true
107 111 t.test_files = FileList['test/ui/**/*_test.rb']
108 112 end
109 113 Rake::Task['test:ui'].comment = "Run the UI tests with Capybara (PhantomJS listening on port 4444 is required)"
110 114 end
General Comments 0
You need to be logged in to leave comments. Login now