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

Ability to pass different args and use different environments for different tasks #80

Open
doughsay opened this issue Sep 8, 2017 · 4 comments

Comments

@doughsay
Copy link

doughsay commented Sep 8, 2017

This would be great and a lot more flexible:

# config/config.exs
use Mix.Config

if Mix.env == :dev do
  config :mix_test_watch,
    tasks: [
      {"test", args: "--stale"},
      {"dialyzer", mix_env: "dev"}
    ]
end

As noted in #56, the dialyzer task fails if passed unknown args. Also, the default env to run the task in is "dev" (I don't know if this matters much though).

The above API seems to make a lot of sense though and would offer a lot of flexibility.

@stefanjarina
Copy link

Hello, I concur this - I run credo before my tests and I would love to specify some arguments to it while use --stale with tests as well.

@yuchunc
Copy link

yuchunc commented Sep 27, 2017

Hi, I'm running in to the same issue when use with credo, and keep getting error.

Unknown switch: --stale

be able to specify which task would be awesome!

@phikes
Copy link

phikes commented May 17, 2018

This seems to work for me:

# config/config.exs

use Mix.Config

if Mix.env == :dev do
  config :mix_test_watch,
    tasks: [
      "test --stale",
      "credo -a --strict",
    ]
end

randycoulman pushed a commit to randycoulman/mix_test_interactive that referenced this issue Jan 24, 2021
Because `mix test.interactive` is geared towards running `mix test` interactively, some of the configuration options inherited from mix-test.watch don't make as much sense.

With interactive mode, changing the CLI executable from `mix` to `iex -S mix` doesn't work, so we now hard-code that to `mix`.  If there is another use case for this option, I'm willing to reconsider.

The support for running multiple tasks was not ideal, as it would pass the same arguments to all of the commands, which is probably not what we really want (see lpil/mix-test.watch#80) for example.

However, there is still a use for defining a task alias that runs `mix test` under the hood, so we still allow configuration of a single task.  However, `mix test.interactive` assumes that the custom task accepts the same command-line arguments as `mix test`.

Again, if there is a legitimate use cas e for running multiple tasks, I'm willing to consider adding that feature back, but I'd want to find a way to allow different arguments to be passed to different tasks.
@stocks29
Copy link

The ability to run tasks under separate envs would be really nice. I have e2e tests which run in an :e2e environment. I'm unable to run them with this module because I cannot override the env.

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

5 participants