-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Use seed
to randomize require order of test files
#12442
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,32 @@ defmodule Mix.Tasks.TestTest do | |
end | ||
end | ||
|
||
describe "--seed" do | ||
test "requires modules alphabetical order if seed is 0" do | ||
in_fixture("test_stale", fn -> | ||
opts = ["--seed", "0", "--trace"] | ||
# Forcing the parallel compiler to operate synchronously | ||
envs = [{"ELIXIR_ERL_OPTIONS", "+S 1:1"}] | ||
output = mix(["test" | opts], envs) | ||
|
||
matches = Regex.scan(~r"\wTest\s\[.*\]", output) | ||
assert matches == [["BTest [test/b_test_stale.exs]"], ["ATest [test/a_test_stale.exs]"]] | ||
end) | ||
end | ||
|
||
test "requires modules in random order if seed is provided" do | ||
in_fixture("test_stale", fn -> | ||
opts = ["--seed", "5", "--trace"] | ||
# Forcing the parallel compiler to operate synchronously | ||
envs = [{"ELIXIR_ERL_OPTIONS", "+S 1:1"}] | ||
output = mix(["test" | opts], envs) | ||
|
||
matches = Regex.scan(~r"\wTest\s\[.*\]", output) | ||
assert matches == [["ATest [test/a_test_stale.exs]"], ["BTest [test/b_test_stale.exs]"]] | ||
end) | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those tests are rather expensive and they rely on implementation details-ish. I am thinking we could just skip them altogether? Other than that, the impl is great! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Works for me! Let me remove the test. |
||
|
||
describe "--stale" do | ||
test "runs all tests for first run, then none on second" do | ||
in_fixture("test_stale", fn -> | ||
|
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.
Had to be outside of
Task.async
to ensureseed
was set when it's fetched intest.ex