E1143: test file or directory in the wrong place

View source

Tests live in two places (ADR-0121).

Tests live in two places (ADR-0121). The tests of a module are .act files directly in the tests directory next to its facade, as in src/math/tests/. The tests of the project are .act files directly in tests/. The compiler reports the path that is in the wrong place, with no line and column. It rejects:

  • a tests directory with a facade tests.act, because a tests directory is never a module;
  • a src/tests directory, because the root unit has no tests directory;
  • a subdirectory inside a tests directory, except one named fixtures or snapshots, which holds test data;
  • an .act file in a subdirectory of tests/, the old layout that mirrored a source path.

The message names the directory or file and tells where it belongs.

Example

actus
import math;

verb main() {
}
actus
open add;
actus
open verb add(abs left: Int, abs right: Int) -> Int {
    return left + right;
}
actus
meta test
verb adds() -> Int {
    return 0;
}
actus
import math;

verb main() {
}
actus
open add;
actus
open verb add(abs left: Int, abs right: Int) -> Int {
    return left + right;
}
actus
meta test
verb adds() -> Int {
    return 0;
}

Fix

Put the test file directly in the tests directory of its module.

actus
import math;

verb main() {
}
actus
open add;
actus
open verb add(abs left: Int, abs right: Int) -> Int {
    return left + right;
}
actus
meta test
verb adds() -> Int {
    return 0;
}

Run actus explain E1143 in your terminal to read this entry offline. Browse Modules & rules or all error codes.