bring back TEST
env for rake test
.
Closes #23027. This does not restore complete backwards compatibility. It simply passes the contets of the `TEST` env to the new runner.
This commit is contained in:
parent
f718e52bcc
commit
64448c29de
@ -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`
|
||||
|
@ -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
|
||||
|
@ -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}` }
|
||||
|
Loading…
Reference in New Issue
Block a user