Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug in busted --list: Path and line number omitted for top-level tests #743

Open
MisanthropicBit opened this issue Jul 31, 2024 · 0 comments · May be fixed by #749
Open

Possible bug in busted --list: Path and line number omitted for top-level tests #743

MisanthropicBit opened this issue Jul 31, 2024 · 0 comments · May be fixed by #749

Comments

@MisanthropicBit
Copy link

I've encountered some strange behaviour when using busted --list. Consider the following test file:

it("top", function()
    assert.is_true(true)
end)

describe("describe 1", function()
    it("test 1", function()
        assert.is_true(true)
    end)

    it("test 2", function()
        assert.is_true(true)
    end)
end)

Running busted --list on it outputs:

> busted --list test_spec.lua
top
test_spec.lua:6: describe 1 test 1
test_spec.lua:10: describe 1 test 2

As you can see, the path and line number information is omitted for top-level tests even though they are allowed and running the tests works just fine.

> busted test_spec.lua
●●●
3 successes / 0 failures / 0 errors / 0 pending : 0.001417 seconds

I've looked at the existing issues as well as the documentation of cli options but I couldn't find anything. I've tracked down the issue to this function which only prepends the extra information if trace.what == 'Lua'. For the top-level test, trace.what is 'main' so it just prints the name of the test.

Changing the line to if trace and (trace.what == 'Lua' or trace.what == 'main') then fixes the issue but I'm not 100% if that change will break for other cases where what is 'main'. Or perhaps this is the intended behaviour? The lua docs on introspective facilities, where I assume the information is coming from, say the following.

what --- What this function is. Options are "Lua" if foo is a regular Lua function, "C" if it is a C function, or "main" if it is the main part of a Lua chunk.

I don't mind submitting a PR 🙂 In my case, this is making it difficult to consume and use the output programmatically.

@MisanthropicBit MisanthropicBit linked a pull request Nov 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant