]> source.dussan.org Git - redmine.git/commitdiff
Adds a rake task test:scm:update to update test repositories if needed.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 6 Jan 2011 18:52:37 +0000 (18:52 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 6 Jan 2011 18:52:37 +0000 (18:52 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4643 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/tasks/ci.rake
lib/tasks/testing.rake

index 0925753176d6ba2e2da3c183e526d2e2516e63a9..e6cf78fa3b81b54021015b1ecb9ae4feeb66ff14 100644 (file)
@@ -16,6 +16,7 @@ namespace :ci do
     Rake::Task["db:create"].invoke
     Rake::Task["db:migrate"].invoke
     Rake::Task["db:schema:dump"].invoke
+    Rake::Task["test:scm:update"].invoke
   end
 
   desc "Build Redmine"
index 27eb053f4e2647ca550f1fa3d776ab56caac3d55..45066ae3045a8db85b2f7c588614a718a6514f04 100644 (file)
@@ -1,68 +1,82 @@
-### From http://svn.geekdaily.org/public/rails/plugins/generally_useful/tasks/coverage_via_rcov.rake
-
-namespace :test do
-  desc 'Measures test coverage'
-  task :coverage do
-    rm_f "coverage"
-    rm_f "coverage.data"
-    rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib --html"
-    files = Dir.glob("test/**/*_test.rb").join(" ")
-    system("#{rcov} #{files}")
-    system("open coverage/index.html") if PLATFORM['darwin']
-  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"
-      task :create_dir do
-        FileUtils.mkdir_p Rails.root + '/tmp/test'
-      end
-      
-      supported_scms = [:subversion, :cvs, :bazaar, :mercurial, :git, :darcs, :filesystem]
-      
-      desc "Creates a test subversion repository"
-      task :subversion => :create_dir do
-        repo_path = "tmp/test/subversion_repository"
-        system "svnadmin create #{repo_path}"
-        system "gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load #{repo_path}"
-      end
-      
-      (supported_scms - [:subversion]).each do |scm|
-        desc "Creates a test #{scm} repository"
-        task scm => :create_dir do
-          system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test"
-        end
-      end
-      
-      desc "Creates all test repositories"
-      task :all => supported_scms
-    end
-    
-    Rake::TestTask.new(:units => "db:test:prepare") do |t|
-      t.libs << "test"
-      t.verbose = true
-      t.test_files = FileList['test/unit/repository*_test.rb'] + FileList['test/unit/lib/redmine/scm/**/*_test.rb']
-    end
-    Rake::Task['test:scm:units'].comment = "Run the scm unit tests"
-    
-    Rake::TestTask.new(:functionals => "db:test:prepare") do |t|
-      t.libs << "test"
-      t.verbose = true
-      t.test_files = FileList['test/functional/repositories*_test.rb']
-    end
-    Rake::Task['test:scm:functionals'].comment = "Run the scm functional tests"
-  end
-end
+### From http://svn.geekdaily.org/public/rails/plugins/generally_useful/tasks/coverage_via_rcov.rake\r
+\r
+namespace :test do\r
+  desc 'Measures test coverage'\r
+  task :coverage do\r
+    rm_f "coverage"\r
+    rm_f "coverage.data"\r
+    rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib --html"\r
+    files = Dir.glob("test/**/*_test.rb").join(" ")\r
+    system("#{rcov} #{files}")\r
+    system("open coverage/index.html") if PLATFORM['darwin']\r
+  end\r
+\r
+  desc 'Run unit and functional scm tests'\r
+  task :scm do\r
+    errors = %w(test:scm:units test:scm:functionals).collect do |task|\r
+      begin\r
+        Rake::Task[task].invoke\r
+        nil\r
+      rescue => e\r
+        task\r
+      end\r
+    end.compact\r
+    abort "Errors running #{errors.to_sentence(:locale => :en)}!" if errors.any?\r
+  end\r
+\r
+  namespace :scm do\r
+    namespace :setup do\r
+      desc "Creates directory for test repositories"\r
+      task :create_dir do\r
+        FileUtils.mkdir_p Rails.root + '/tmp/test'\r
+      end\r
+      \r
+      supported_scms = [:subversion, :cvs, :bazaar, :mercurial, :git, :darcs, :filesystem]\r
+      \r
+      desc "Creates a test subversion repository"\r
+      task :subversion => :create_dir do\r
+        repo_path = "tmp/test/subversion_repository"\r
+        system "svnadmin create #{repo_path}"\r
+        system "gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load #{repo_path}"\r
+      end\r
+      \r
+      (supported_scms - [:subversion]).each do |scm|\r
+        desc "Creates a test #{scm} repository"\r
+        task scm => :create_dir do\r
+          system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test"\r
+        end\r
+      end\r
+      \r
+      desc "Creates all test repositories"\r
+      task :all => supported_scms\r
+    end\r
+      \r
+    desc "Updates installed test repositories"\r
+    task :update do\r
+      require 'fileutils'\r
+      Dir.glob("tmp/test/*_repository").each do |dir|\r
+        next unless File.basename(dir) =~ %r{^(.+)_repository$} && File.directory?(dir)\r
+        scm = $1\r
+        next unless fixture = Dir.glob("test/fixtures/repositories/#{scm}_repository.*").first\r
+        next if File.stat(dir).ctime > File.stat(fixture).mtime\r
+        \r
+        FileUtils.rm_rf dir\r
+        Rake::Task["test:scm:setup:#{scm}"].execute\r
+      end\r
+    end\r
+    \r
+    Rake::TestTask.new(:units => "db:test:prepare") do |t|\r
+      t.libs << "test"\r
+      t.verbose = true\r
+      t.test_files = FileList['test/unit/repository*_test.rb'] + FileList['test/unit/lib/redmine/scm/**/*_test.rb']\r
+    end\r
+    Rake::Task['test:scm:units'].comment = "Run the scm unit tests"\r
+    \r
+    Rake::TestTask.new(:functionals => "db:test:prepare") do |t|\r
+      t.libs << "test"\r
+      t.verbose = true\r
+      t.test_files = FileList['test/functional/repositories*_test.rb']\r
+    end\r
+    Rake::Task['test:scm:functionals'].comment = "Run the scm functional tests"\r
+  end\r
+end\r