-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add mix test --dry-run flag #14499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add mix test --dry-run flag #14499
Conversation
0eadca6
to
64bb5e1
Compare
I'm not quite sure why one of the builds is failing:
|
@@ -770,6 +770,40 @@ defmodule Mix.Tasks.TestTest do | |||
end | |||
end | |||
|
|||
describe "--dry-run" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More test cases to add:
-
--dry-run
+--only
-
--dry-run
+--exclude
- ...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, implementation-wise I think we might need to take a different approach. Right now, I see two main issues:
- We're not running
ExUnit.Formatter
s on dry runs—I think we might want to. Basically, the only thing we want--dry-run
to do is to literally skip executing the body of tests (+setup
/setup_all
calls and whatnot), but everything else would be the same. - We are printing test files, but this doesn't give us information about what tests (or test cases even, if there are >1 test cases in a file) would run. I think this is important. Think of using
--dry-run
to answer the question "if I pass this--exclude
option, how many tests will be skipped"?.
Do these points make sense? I am not even sure this is very feasible, so we'd need to sort of proof-of-concept this.
modules_to_restore = | ||
if not opts[:dry_run] do | ||
do_run(config, modules_to_restore, opts, load_us) | ||
else | ||
nil | ||
end | ||
|
||
stats = ExUnit.RunnerStats.stats(stats_pid) | ||
EM.stop(config.manager) | ||
after_suite_callbacks = Application.fetch_env!(:ex_unit, :after_suite) | ||
Enum.each(after_suite_callbacks, fn callback -> callback.(stats) end) | ||
{stats, modules_to_restore} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whatyouhide So, I tried to move the flag down the stack as far as possible. I still need to write tests, but does this look more in the right direction? 🙏
Aims to address #14393