diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 2ce39d7ed3eff2970aca4cfd9abfc6b7e8bb647e..4a28074f2c82d29bbec47296f25c7873f874d65f 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,7 @@ +* Bring back `TEST=` env for `rake test` task. + + *Yves Senn* + * Specify log file names or all logs to clear `rake log:clear` Specify which logs to clear when using the `rake log:clear` task, e.g. `rake log:clear LOGS=test,staging` diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake index 6676c6a07997e91e25a73dac301357d059bbdd3a..41921e43f361b126aa8f234eedc7d1760d2a4352 100644 --- a/railties/lib/rails/test_unit/testing.rake +++ b/railties/lib/rails/test_unit/testing.rake @@ -7,7 +7,12 @@ task default: :test desc "Runs all tests in test folder" task :test do $: << "test" - Minitest.rake_run(["test"]) + pattern = if ENV.key?('TEST') + ENV['TEST'] + else + "test" + end + Minitest.rake_run([pattern]) end namespace :test do diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb index ae8a73842c3563ae2db0dc3bb079a7927e8b4045..bb6c6574c5027ac9c59b8d0ddf6fa456a112a220 100644 --- a/railties/test/application/test_runner_test.rb +++ b/railties/test/application/test_runner_test.rb @@ -450,6 +450,17 @@ def test_raise_error_when_specified_file_does_not_exist assert_match(%r{cannot load such file.+test/not_exists\.rb}, error) end + def test_pass_TEST_env_on_rake_test + create_test_file :models, 'account' + create_test_file :models, 'post', pass: false + + output = Dir.chdir(app_path) { `bin/rake test TEST=test/models/post_test.rb` } + + assert_match "PostTest", output, "passing TEST= should run selected test" + assert_no_match "AccountTest", output, "passing TEST= should only run selected test" + assert_match '1 runs, 1 assertions', output + end + private def run_test_command(arguments = 'test/unit/test_test.rb') Dir.chdir(app_path) { `bin/rails t #{arguments}` }