Skip to content

mix test works but mix test <exunit file name> fails #43

@ymtszw

Description

@ymtszw

Situation

In mix project, you can mix test to run ExUnit tests that contains calls to Gleam APIs (e.g. :[email protected]), but it fails if you specifically target ExUnit test files with command line arguments.

Reproduction

  • Clone this repository
  • Install Erlang/Elixir/Gleam as per official doc
  • mix archive.install hex mix_gleam
  • cd test_projects/basic_project
  • mix deps.get
  • mix test
Result (Success):
$ mix test
Compiling 1 file (.gleam)
warning: Transitive dependency imported
  ┌─ /Users/yumatsuzawa/workspace/mix_gleam/test_projects/basic_project/_build/test/lib/basic_project/test/basic_project_test.gleam:1:1
  │
1 │ import gleeunit
  │ ^^^^^^^^^^^^^^^

The module gleeunit is being imported, but gleeunit, the package it
belongs to, is not a direct dependency of your package.
In a future version of Gleam this may become a compile error.

Run this command to add it to your dependencies:

gleam add gleeunit

warning: Redundant assertion
┌─ /Users/yumatsuzawa/workspace/mix_gleam/test_projects/basic_project/_build/test/lib/basic_project/test/basic_project_test.gleam:9:7

9 │ let assert World = basic_project.hello()
│ ^^^^^^ You can remove this

This assertion is redundant since the pattern covers all possibilities.

warning: Redundant assertion
┌─ /Users/yumatsuzawa/workspace/mix_gleam/test_projects/basic_project/_build/test/lib/basic_project/test/basic_project_test.gleam:13:7

13 │ let assert World = hello_elixir()
│ ^^^^^^ You can remove this

This assertion is redundant since the pattern covers all possibilities.

Compiling 2 files (.erl)
Running ExUnit with seed: 5817, max_cases: 16

....
Finished in 0.04 seconds (0.00s async, 0.04s sync)
1 doctest, 3 tests, 0 failures

  • mix test test/basic_project_test.exs

Result (Failure):

$ mix test test/basic_project_test.exs 
** (Mix) Unknown dependency test/basic_project_test.exs for environment test

Environments

  • OS: macOS Sonoma 14.7
  • Erlang: 27.1.1 (installed with mise)
  • Elixir: 1.17.3-otp-27 (installed with mise)
  • Gleam: 1.6.2 (installed with mise, asdf-community/asdf-gleam)
  • mix_gleam: 0.6.2

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