Skip to content

regression: zig test on a std lib file errors with 'file exists in multiple packages' #14504

@squeek502

Description

@squeek502

Zig Version

0.11.0-dev.1502+d6b430b52

Steps to Reproduce and Observed Behavior

Previously, something like the following worked, and only the tests within fs/test.zig would get run (at least after #12939):

zig test lib/std/fs/test.zig --zig-lib-dir lib --main-pkg-path lib/std

With current master branch, however, it will error:

lib/std/std.zig:1:1: error: file exists in multiple packages
lib/std/std.zig:1:1: note: root of package std
lib/std/fs/test.zig:1:21: note: imported from package root
const std = @import("../std.zig");
                    ^~~~~~~~~~~~
lib/std/multi_array_list.zig:1:21: note: imported from package std
const std = @import("std.zig");
                    ^~~~~~~~~

... (omitted a lot of notes) ...

lib/std/build/LibExeObjStep.zig:2:21: note: imported from package std
const std = @import("../std.zig");
                    ^~~~~~~~~~~~
lib/std/fs/test.zig:1:1: error: file exists in multiple packages
lib/std/fs/test.zig:1:1: note: root of package root
lib/std/fs.zig:3131:17: note: imported from package std
    _ = @import("fs/test.zig");
                ^~~~~~~~~~~~~

This is a use-case that I use quite often but I know isn't fully endorsed (some context: #2331 (comment), #9946). I expect some change similar to what caused it to regress before #12926 / #12939 has happened again.

Expected Behavior

$ zig test lib/std/fs/test.zig --main-pkg-path lib/std --zig-lib-dir lib
All 45 tests passed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    regressionIt worked in a previous version of Zig, but stopped working.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions