Skip to content

Incorrect number logged when a test fails  #10773

@radiohertz

Description

@radiohertz

Zig Version

0.10.0-dev.450+63ee6e662

Steps to Reproduce

  1. Create a test file with the following contents.
const std = @import("std");

pub fn add(x: i32, y: i32) i32 {
    return x + y;
}

test "basic test" {
    try std.testing.expectEqual(10, 3 + 7);
}

test "Test should fail" {
    try std.testing.expectEqual(add(5, 5), 15);
}
  1. Run the test file zig test test.zig

Expected Behavior

Test runner should show the correct test number when the test fails.
Example:

Test [2/2] test "Test should fail"... expected 10, found 15
Test [2/2] test "Test should fail"... FAIL (TestExpectedEqual)

Actual Behavior

Test [1/2] test "Test should fail"... expected 10, found 15
Test [2/2] test "Test should fail"... FAIL (TestExpectedEqual)
/usr/lib/zig/std/testing.zig:79:17: 0x20801f in std.testing.expectEqual (test)
                return error.TestExpectedEqual;
                ^
/home/kenobi/code/sterling/src/test.zig:8:5: 0x207a8f in test "Test should fail" (test)
    try std.testing.expectEqual(5 + 5, 15);
    ^
1 passed; 0 skipped; 1 failed.
error: the following test command failed with exit code 1:
src/zig-cache/o/193861cd31ad5908c0ceb539270824aa/test /usr/bin/zig

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions