Skip to content

zig test no output #10242

Open
Open
@tankorsmash

Description

@tankorsmash

Zig Version

0.9.0-dev.1737+c42763f8c

Steps to Reproduce

mkdir repro
cd repro
zig init-exe
mkdir subdir
mkdir other_subdir
touch subdir/solution.zig
touch other_subdir/solution.zig

edit src/Main.zig to

const std = @import("std");

const solution = @import("./subdir/solution.zig");

pub fn main() anyerror!void {
    std.log.info("All your codebase are belong to us.", .{});
    solution.solve();
}

test "basic test" {
    try std.testing.expect(true);

}

edit src/subdir/solution.zig to:

const std = @import("std");
const shared = @import("./../other_subdir/shared.zig");


pub fn solve() void {
    std.log.info("in solve", .{});
    shared.some_func();
}

test "solution test" {
    try std.testing.expect(true);
}

edit src/other_subdir/shared.zig to

const std = @import("std");

pub fn some_func() void {
    std.log.info("in some_func", .{});
}

then run

zig test src/Main.src
>> All 1 tests passed.
zig test ./src/subdir/solution.zig
>> <nothing outputs>

then go into ./src/subdir/solution.zig and change it to

const std = @import("std");
// const shared = @import("./../other_subdir/shared.zig");


pub fn solve() void {
	std.log.info("in solve", .{});
	// shared.some_func();
}

test "solution test" {
	try std.testing.expect(true);
}

and rerun

zig test src/Main.src
>> All 1 tests passed.
zig test ./src/subdir/solution.zig
>> All 1 tests passed.

Expected Behavior

I expect to be able to run zig test somefile/in/subdirs/file.zig to detect and run the tests in <..>/file.zig regardless of whether @import is used

Actual Behavior

zig test somefile/in/subdirs/file.zig is silently running, and not apparently doing anything once the tests compile.

The tests are detected, because removing the test "solution test" { ... } block, zig test <..>/solution.zig correctly tells me that no tests are detected. Any compiler errors are properly detected here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    zig build systemstd.Build, the build runner, `zig build` subcommand, package management

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions