You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

testing.rake 3.9 kB

13 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. ### From http://svn.geekdaily.org/public/rails/plugins/generally_useful/tasks/coverage_via_rcov.rake
  2. namespace :test do
  3. desc 'Measures test coverage'
  4. task :coverage do
  5. rm_f "coverage"
  6. rm_f "coverage.data"
  7. rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib --html --exclude gems/"
  8. files = %w(unit functional integration).map {|dir| Dir.glob("test/#{dir}/**/*_test.rb")}.flatten.join(" ")
  9. system("#{rcov} #{files}")
  10. end
  11. desc 'Run unit and functional scm tests'
  12. task :scm do
  13. errors = %w(test:scm:units test:scm:functionals).collect do |task|
  14. begin
  15. Rake::Task[task].invoke
  16. nil
  17. rescue => e
  18. task
  19. end
  20. end.compact
  21. abort "Errors running #{errors.to_sentence(:locale => :en)}!" if errors.any?
  22. end
  23. namespace :scm do
  24. namespace :setup do
  25. desc "Creates directory for test repositories"
  26. task :create_dir do
  27. FileUtils.mkdir_p Rails.root + '/tmp/test'
  28. end
  29. supported_scms = [:subversion, :cvs, :bazaar, :mercurial, :git, :darcs, :filesystem]
  30. desc "Creates a test subversion repository"
  31. task :subversion => :create_dir do
  32. repo_path = "tmp/test/subversion_repository"
  33. unless File.exists?(repo_path)
  34. system "svnadmin create #{repo_path}"
  35. system "gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load #{repo_path}"
  36. end
  37. end
  38. desc "Creates a test mercurial repository"
  39. task :mercurial => :create_dir do
  40. repo_path = "tmp/test/mercurial_repository"
  41. unless File.exists?(repo_path)
  42. bundle_path = "test/fixtures/repositories/mercurial_repository.hg"
  43. system "hg init #{repo_path}"
  44. system "hg -R #{repo_path} pull #{bundle_path}"
  45. end
  46. end
  47. (supported_scms - [:subversion, :mercurial]).each do |scm|
  48. desc "Creates a test #{scm} repository"
  49. task scm => :create_dir do
  50. unless File.exists?("tmp/test/#{scm}_repository")
  51. # system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test"
  52. system "tar -xvz -C tmp/test -f test/fixtures/repositories/#{scm}_repository.tar.gz"
  53. end
  54. end
  55. end
  56. desc "Creates all test repositories"
  57. task :all => supported_scms
  58. end
  59. desc "Updates installed test repositories"
  60. task :update do
  61. require 'fileutils'
  62. Dir.glob("tmp/test/*_repository").each do |dir|
  63. next unless File.basename(dir) =~ %r{^(.+)_repository$} && File.directory?(dir)
  64. scm = $1
  65. next unless fixture = Dir.glob("test/fixtures/repositories/#{scm}_repository.*").first
  66. next if File.stat(dir).ctime > File.stat(fixture).mtime
  67. FileUtils.rm_rf dir
  68. Rake::Task["test:scm:setup:#{scm}"].execute
  69. end
  70. end
  71. Rake::TestTask.new(:units => "db:test:prepare") do |t|
  72. t.libs << "test"
  73. t.verbose = true
  74. t.test_files = FileList['test/unit/repository*_test.rb'] + FileList['test/unit/lib/redmine/scm/**/*_test.rb']
  75. end
  76. Rake::Task['test:scm:units'].comment = "Run the scm unit tests"
  77. Rake::TestTask.new(:functionals => "db:test:prepare") do |t|
  78. t.libs << "test"
  79. t.verbose = true
  80. t.test_files = FileList['test/functional/repositories*_test.rb']
  81. end
  82. Rake::Task['test:scm:functionals'].comment = "Run the scm functional tests"
  83. end
  84. Rake::TestTask.new(:rdm_routing) do |t|
  85. t.libs << "test"
  86. t.verbose = true
  87. t.test_files = FileList['test/integration/routing/*_test.rb']
  88. end
  89. Rake::Task['test:rdm_routing'].comment = "Run the routing tests"
  90. Rake::TestTask.new(:ui => "db:test:prepare") do |t|
  91. t.libs << "test"
  92. t.verbose = true
  93. t.test_files = FileList['test/ui/**/*_test.rb']
  94. end
  95. Rake::Task['test:ui'].comment = "Run the UI tests with Capybara (PhantomJS listening on port 4444 is required)"
  96. end

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...