Skip to content

Conversation

@Gravemind1142
Copy link

This PR updates the test runner to include stack traces in the output for failed tests. This will make it easier to debug both the tests and the source code.

Copy link
Collaborator

@Vighnesh-V Vighnesh-V left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is really nice to have - can you add a test like I suggested as well as look into if it's possible to trim the full stacktrace on display?

error: string, -- the error message from the assertion
filename: string, -- source file where the failure occurred
linenumber: number, -- line number of the failure
stacktrace: string, -- full stacktrace at the point of failure
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at tests/cli/test/test.test.luau (sorry for horrific naming lol), can you add a test for this? Moreover is it possible to trim the stacktrace? E.g. show the last 5 frames before the crash?

@Gravemind1142
Copy link
Author

Gravemind1142 commented Nov 4, 2025

look into if it's possible to trim the full stacktrace on display?

@Vighnesh-V

Most popular test runners have a way to pass configuration to the unit test runner for things like stacktrace verbosity in CI vs during development. We don't have that today, and forcing engs to use "only truncated" in the meantime seems too restrictive, so I think it would be best to align on how we want configuration for test.luau to work first.

@Vighnesh-V
Copy link
Collaborator

@Gravemind1142 That's reasonable - we can include the full stacktrace for now and include the verbosity as a toggle in lute test. Do you mind making an issue for this in the github and assigning it to me?

print(`❌ {failed.test}`)
print(` {failed.filename}:{failed.linenumber}`)
print(` {failed.assertion}: {failed.error}`)
if failed.stacktrace and failed.stacktrace ~= "" then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if failed.stacktrace and failed.stacktrace ~= "" then
if failed.stacktrace ~= "" then

if the stacktrace is always present and just empty string when not set, we don't need to check if it's present

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants