Skip to content
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

test.watch for one test file runs all tests instead #103

Open
Ziinc opened this issue Apr 28, 2019 · 5 comments
Open

test.watch for one test file runs all tests instead #103

Ziinc opened this issue Apr 28, 2019 · 5 comments

Comments

@Ziinc
Copy link

Ziinc commented Apr 28, 2019

Following the instructions in the README, I tried to run a single test file like so, but it does not behave as expected:

Expected (same output as mix test test/path_to_test_file.exs) :

C:\path_to_project\server (develop -> origin)
λ mix test.watch test/path_to_test_file.exs

Finished in 0.2 seconds
3 tests, 0 failures

Randomized with seed 726000

Actual:

C:\path_to_project\server (develop -> origin)
λ mix test.watch test/path_to_test_file.exs

Running tests...

...........**................................................................................................................................................................*........................

Finished in 2.3 seconds
198 tests, 0 failures, 3 skipped

Randomized with seed 484000

I am on windows 10, mix deps is as so:

...
{:mix_test_watch, "~> 0.8", only: :dev, runtime: false},
...
@lpil
Copy link
Owner

lpil commented Apr 28, 2019

Hi, thanks for the report.

I'm unable to reproduce this on my Linux machine. Could you provide a minimal reproduction of the problem and upload the project to GitHub? It would help determine if the problem is windows or something else.

Thank you.

@Ziinc
Copy link
Author

Ziinc commented Apr 28, 2019

I've reproduced it here: https://github.com/Ziinc/mix-test-watch-repro

Thanks for the super prompt reply!

@Ziinc
Copy link
Author

Ziinc commented Apr 28, 2019

Seems like the command variable containing build tasks cmds isn't passed to the windows cmd command

System.cmd("cmd", ["/C", "set MIX_ENV=test&& mix test"], into: IO.stream(:stdio, :line))

as compared to the linux version:

System.cmd("sh", ["-c", command], into: IO.stream(:stdio, :line))

@lpil
Copy link
Owner

lpil commented Apr 28, 2019

Great catch!! Would you like to make a PR fixing this?

@Ziinc
Copy link
Author

Ziinc commented Apr 28, 2019

Made: #104

Isn't completely fixed though, there's a weird double quote issue that I explained in the PR.

randycoulman pushed a commit to randycoulman/mix_test_interactive that referenced this issue Feb 12, 2021
As reported in lpil/mix-test.watch#103, the code we adopted from mix-test.watch was always running `mix test` without arguments on Windows even if a custom command or other options were provided.

Now, we run the proper command on Windows.

As reported in lpil/mix-test.watch#104, I also had trouble getting past the quote and backslash issues with the ANSI-enable command on Windows. Plus, in my experimenting, I found that a basic Windows command shell doesn't support ANSI commands.

Therefore, we do not enable ANSI output when running on Windows.

If someone is able to figure out the quoting/backslash issues and help fix the problem, I'm open to solutions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants