Rakefile 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. task :default => :test
  2. task :test => %w[test:unit test:integration]
  3. namespace :test do
  4. task :unit => %w[test:php:unit test:hhvm:unit]
  5. task :integration => %w[test:php:integration test:hhvm:integration]
  6. namespace :php do
  7. desc "print PHP version"
  8. task :version do
  9. print_php_version("php")
  10. end
  11. desc "run unit tests under PHP"
  12. task :unit => :version do
  13. run_php_test_suite("php", "unit")
  14. end
  15. desc "run integration tests under PHP"
  16. task :integration do
  17. run_php_test_suite("php", "integration")
  18. end
  19. end
  20. namespace :hhvm do
  21. desc "print HHVM version"
  22. task :version do
  23. print_php_version("hhvm")
  24. end
  25. desc "run tests under HHVM"
  26. task :test => [:unit, :integration]
  27. desc "run unit tests under HHVM"
  28. task :unit => :version do
  29. run_php_test_suite("hhvm", "unit")
  30. end
  31. desc "run integration tests under HHVM"
  32. task :integration do
  33. run_php_test_suite("hhvm", "integration")
  34. end
  35. end
  36. desc "run tests under PHP"
  37. task :php => %w[php:unit php:integration]
  38. desc "run tests under HHVM"
  39. task :hhvm => %w[hhvm:unit hhvm:integration]
  40. desc "run a single test file"
  41. task :file, :file_path do |t, args|
  42. run_php_test_file(args[:file_path])
  43. end
  44. desc "run single test (e.g. rake test:single[GatewayTest::testConfigGetsAssertedValid])"
  45. task :single, :test_name do |t, args|
  46. run_php_test(args[:test_name])
  47. end
  48. end
  49. desc "update the copyright year"
  50. task :copyright, :from_year, :to_year do |t, args|
  51. sh "find tests lib -type f -name '*.php' -exec sed -i 's/#{args[:from_year]} Braintree/#{args[:to_year]} Braintree/g' {} +"
  52. end
  53. def print_php_version(interpreter)
  54. sh "#{interpreter} --version"
  55. end
  56. def run_php_test_suite(interpreter, test_suite)
  57. sh "#{interpreter} ./vendor/bin/phpunit --testsuite #{test_suite}"
  58. end
  59. def run_php_test_file(test_file)
  60. sh "./vendor/bin/phpunit #{test_file}"
  61. end
  62. def run_php_test(test_name)
  63. sh "./vendor/bin/phpunit --filter #{test_name}"
  64. end