| 
									
										
										
										
											2023-11-26 14:07:17 +00:00
										 |  |  | # Redmine - project management software | 
					
						
							| 
									
										
										
										
											2024-02-26 22:55:54 +00:00
										 |  |  | # Copyright (C) 2006-  Jean-Philippe Lang | 
					
						
							| 
									
										
										
										
											2023-11-26 14:07:17 +00:00
										 |  |  | # | 
					
						
							|  |  |  | # This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  | # modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  | # as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  | # of the License, or (at your option) any later version. | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  | # GNU General Public License for more details. | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  | # along with this program; if not, write to the Free Software | 
					
						
							|  |  |  | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-24 00:05:29 +00:00
										 |  |  | namespace :test do | 
					
						
							|  |  |  |   desc 'Measures test coverage' | 
					
						
							|  |  |  |   task :coverage do | 
					
						
							|  |  |  |     rm_f "coverage" | 
					
						
							| 
									
										
										
										
											2014-12-02 19:59:38 +00:00
										 |  |  |     ENV["COVERAGE"] = "1" | 
					
						
							|  |  |  |     Rake::Task["test"].invoke | 
					
						
							| 
									
										
										
										
											2011-12-24 00:05:29 +00:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   desc 'Run unit and functional scm tests' | 
					
						
							|  |  |  |   task :scm do | 
					
						
							|  |  |  |     errors = %w(test:scm:units test:scm:functionals).collect do |task| | 
					
						
							|  |  |  |       begin | 
					
						
							|  |  |  |         Rake::Task[task].invoke | 
					
						
							|  |  |  |         nil | 
					
						
							|  |  |  |       rescue => e | 
					
						
							|  |  |  |         task | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end.compact | 
					
						
							|  |  |  |     abort "Errors running #{errors.to_sentence(:locale => :en)}!" if errors.any? | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   namespace :scm do | 
					
						
							|  |  |  |     namespace :setup do | 
					
						
							|  |  |  |       desc "Creates directory for test repositories" | 
					
						
							| 
									
										
										
										
											2014-05-14 06:10:23 +00:00
										 |  |  |       task :create_dir => :environment do | 
					
						
							| 
									
										
										
										
											2011-12-24 00:05:29 +00:00
										 |  |  |         FileUtils.mkdir_p Rails.root + '/tmp/test' | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-14 08:20:41 +00:00
										 |  |  |       supported_scms = [:subversion, :cvs, :bazaar, :mercurial, :git, :git_utf8, :filesystem] | 
					
						
							| 
									
										
										
										
											2011-12-24 00:05:29 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |       desc "Creates a test subversion repository" | 
					
						
							|  |  |  |       task :subversion => :create_dir do | 
					
						
							|  |  |  |         repo_path = "tmp/test/subversion_repository" | 
					
						
							| 
									
										
										
										
											2021-12-27 03:20:31 +00:00
										 |  |  |         unless File.exist?(repo_path) | 
					
						
							| 
									
										
										
										
											2012-03-01 21:01:37 +00:00
										 |  |  |           system "svnadmin create #{repo_path}" | 
					
						
							|  |  |  |           system "gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load #{repo_path}" | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2011-12-24 00:05:29 +00:00
										 |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       desc "Creates a test mercurial repository" | 
					
						
							|  |  |  |       task :mercurial => :create_dir do | 
					
						
							|  |  |  |         repo_path = "tmp/test/mercurial_repository" | 
					
						
							| 
									
										
										
										
											2021-12-27 03:20:31 +00:00
										 |  |  |         unless File.exist?(repo_path) | 
					
						
							| 
									
										
										
										
											2012-03-01 21:01:37 +00:00
										 |  |  |           bundle_path = "test/fixtures/repositories/mercurial_repository.hg" | 
					
						
							|  |  |  |           system "hg init #{repo_path}" | 
					
						
							|  |  |  |           system "hg -R #{repo_path} pull #{bundle_path}" | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2011-12-24 00:05:29 +00:00
										 |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-14 06:10:37 +00:00
										 |  |  |       def extract_tar_gz(prefix) | 
					
						
							| 
									
										
										
										
											2021-12-27 03:20:31 +00:00
										 |  |  |         unless File.exist?("tmp/test/#{prefix}_repository") | 
					
						
							| 
									
										
										
										
											2014-05-14 06:10:37 +00:00
										 |  |  |           # system "gunzip < test/fixtures/repositories/#{prefix}_repository.tar.gz | tar -xv -C tmp/test" | 
					
						
							|  |  |  |           system "tar -xvz -C tmp/test -f test/fixtures/repositories/#{prefix}_repository.tar.gz" | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-24 00:05:29 +00:00
										 |  |  |       (supported_scms - [:subversion, :mercurial]).each do |scm| | 
					
						
							|  |  |  |         desc "Creates a test #{scm} repository" | 
					
						
							|  |  |  |         task scm => :create_dir do | 
					
						
							| 
									
										
										
										
											2014-05-14 06:10:37 +00:00
										 |  |  |           extract_tar_gz(scm) | 
					
						
							| 
									
										
										
										
											2011-12-24 00:05:29 +00:00
										 |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       desc "Creates all test repositories" | 
					
						
							|  |  |  |       task :all => supported_scms | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     desc "Updates installed test repositories" | 
					
						
							| 
									
										
										
										
											2014-05-14 06:10:23 +00:00
										 |  |  |     task :update => :environment do | 
					
						
							| 
									
										
										
										
											2011-12-24 00:05:29 +00:00
										 |  |  |       require 'fileutils' | 
					
						
							|  |  |  |       Dir.glob("tmp/test/*_repository").each do |dir| | 
					
						
							|  |  |  |         next unless File.basename(dir) =~ %r{^(.+)_repository$} && File.directory?(dir) | 
					
						
							|  |  |  |         scm = $1 | 
					
						
							|  |  |  |         next unless fixture = Dir.glob("test/fixtures/repositories/#{scm}_repository.*").first | 
					
						
							|  |  |  |         next if File.stat(dir).ctime > File.stat(fixture).mtime | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         FileUtils.rm_rf dir | 
					
						
							|  |  |  |         Rake::Task["test:scm:setup:#{scm}"].execute | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-23 11:26:04 +00:00
										 |  |  |     task(:units => "db:test:prepare") do |t| | 
					
						
							|  |  |  |       $: << "test" | 
					
						
							| 
									
										
										
										
											2023-12-12 16:52:46 +00:00
										 |  |  |       Rails::TestUnit::Runner.run_from_rake 'test', FileList['test/unit/repository*_test.rb'] + FileList['test/unit/lib/redmine/scm/**/*_test.rb'] | 
					
						
							| 
									
										
										
										
											2011-12-24 00:05:29 +00:00
										 |  |  |     end | 
					
						
							|  |  |  |     Rake::Task['test:scm:units'].comment = "Run the scm unit tests" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-23 11:26:04 +00:00
										 |  |  |     task(:functionals => "db:test:prepare") do |t| | 
					
						
							|  |  |  |       $: << "test" | 
					
						
							| 
									
										
										
										
											2023-12-12 16:52:46 +00:00
										 |  |  |       Rails::TestUnit::Runner.run_from_rake 'test', FileList['test/functional/repositories*_test.rb'] | 
					
						
							| 
									
										
										
										
											2011-12-24 00:05:29 +00:00
										 |  |  |     end | 
					
						
							|  |  |  |     Rake::Task['test:scm:functionals'].comment = "Run the scm functional tests" | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-23 11:26:04 +00:00
										 |  |  |   task(:routing) do |t| | 
					
						
							|  |  |  |     $: << "test" | 
					
						
							| 
									
										
										
										
											2023-12-12 16:52:46 +00:00
										 |  |  |     Rails::TestUnit::Runner.run_from_rake 'test', FileList['test/integration/routing/*_test.rb'] + FileList['test/integration/api_test/*_routing_test.rb'] | 
					
						
							| 
									
										
										
										
											2011-12-24 00:05:29 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2014-11-18 11:23:07 +00:00
										 |  |  |   Rake::Task['test:routing'].comment = "Run the routing tests" | 
					
						
							| 
									
										
										
										
											2023-12-17 15:05:47 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   task(:autoload) do |t| | 
					
						
							|  |  |  |     $: << "test" | 
					
						
							|  |  |  |     ENV["REDMINE_PLUGINS_DIRECTORY"] = "test/fixtures/plugins" | 
					
						
							|  |  |  |     Rails::TestUnit::Runner.run_from_rake 'test', FileList['test/autoload/*_test.rb'] | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  |   Rake::Task['test:autoload'].comment = "Run the plugin autoload tests" | 
					
						
							| 
									
										
										
										
											2011-12-24 00:05:29 +00:00
										 |  |  | end |