Skip to content

Inconsistent behaviour of tasks in mix aliases #5462

@stevedomin

Description

@stevedomin

Environment

  • Elixir version (elixir -v): 1.3.4
  • Operating system: macOS Sierra 10.12.1

Current behavior

I have the following aliases defined:

defp aliases do
    ["test": ["ecto.create --quiet", "ecto.migrate", "test"],
     "test.ci": ["ecto.migrate", "test"],
     "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
     "ecto.reset": ["ecto.drop", "ecto.setup"]]
  end

I'm using the test.ci to run tests using Heroku CI. In that environment I don't need to run ecto.create --quiet because the database is already created for me.

Unfortunately, due to the way aliases work the call to test in my test.ci alias actually calls the test alias and not the original mix test. Having recursive aliases is pretty useful but I feel like it creates inconsistencies: in my example the both the test and test.ci aliases are calling the test task but in one case it's calling the actual task and in the other an alias.

Expected behavior

Running mix test.ci should be the equivalent of running mix ecto.migrate && mix test.

Alternatively there should be a way to say "run this task" and circumvent any alias setup for it. Or by default it should that and then you could have a way of saying, I want to run this alias rather than the task. Something like (the syntax is terrible, it's just to illustrate my proposition):

defp aliases do
    ["test": ["ecto.create --quiet", "ecto.migrate", "test"],
     "test.ci": ["ecto.migrate", "test"],
     "test.distributed": ["prepare.distribution", {:alias, "test"}]]
  end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions