Skip to content

mix test --stale #4696

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

Merged
merged 8 commits into from
May 27, 2016
Merged

mix test --stale #4696

merged 8 commits into from
May 27, 2016

Conversation

ericentin
Copy link
Contributor

Implements #4688.

I managed to make only minimal changes to the existing test task so that it would be easy to verify that nothing was broken by the addition of --stale, which also had the nice benefit of allowing me to put almost all the code for this feature in a separate module/file.

I still have tests to write, but my manual testing is showing that this is working as I am expecting it to, so I invite everyone to review the implementation and try it out on their projects.

/cc @josevalim @fishcakez @lpil

@ericentin
Copy link
Contributor Author

One potential issue I have identified is that a modified test/test_helper.exs will not trigger a force. I will fix that and make sure it is included in the tests.

def project do
[app: :test_stale,
version: "0.0.1",
test_pattern: "*_test_stale.exs"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required here due to how the *_test targets are constructed in the Makefile.

@ericentin
Copy link
Contributor Author

ericentin commented May 27, 2016

I had some trouble with the tests. The only thing that ended up working was calling out to an external mix process and adding sleeps of 1 second in order to get around what seemed to be a combination of the low resolution of mtimes and the fact that other mix tasks repair mtimes in the future before the test --stale task gets a chance to run. It is pretty bad, the test case for this takes 10 seconds to run. Anyone have any ideas? :)

@ericentin
Copy link
Contributor Author

ericentin commented May 27, 2016

Managed to remove the sleeps by setting all files in the directory into the past and then touching the desired file. Improved the speed by ~40%, but still somewhat slow due to the external mix calls, which seem to be necessary due to how ExUnit works?


defp test_helper_stale?(test_paths) do
test_paths
|> Stream.map(&Path.join(&1, "test_helper.exs"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stream here is likely just making things slower. :)

@josevalim
Copy link
Member

@antipax yes, tests are complicated because we already inside another ExUnit suite when running the tests themselves. We can review them later how to make them faster.

@josevalim
Copy link
Member

josevalim commented May 27, 2016

@antipax great job as always! I have two final suggestions:

  1. What if we move this to Mix.Compilers.Test? Since it is very semantically close to the other compilers. I would also move the ParallelRequire call inside the "compiler"

  2. I believe we should not write the manifest down if the tests fail. Otherwise this would happen:

    1. run tests with mix test --stale
    2. tests fail
    3. fix tests
    4. run tests with mix test --stale #=> nothing runs

    So we should write it down just later on if ExUnit.run returns 0 failures.

assert mix(~w[test --stale] ++ opts) =~ expected
end

defp mix(args, envs \\ []) when is_list(args) do
Copy link
Member

@josevalim josevalim May 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should put this and the functions below in the test helper since now there are two files that need them. :)

@ericentin
Copy link
Contributor Author

Ok, lookin pretty good to me now. Any other feedback?

@josevalim josevalim merged commit 2599edd into elixir-lang:master May 27, 2016
@josevalim
Copy link
Member

❤️ 💚 💙 💛 💜

@ericentin ericentin deleted the mix-test-stale branch May 27, 2016 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants