-
Notifications
You must be signed in to change notification settings - Fork 60
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
Improve test output to include correct location #2058
Conversation
- Add t.Helper() in testcli-related helpers, this ensures that output is attributed correctly to test case and not to the helper. - Modify testlcli.Run() to run process in foreground. This is needed for t.Helper to work. - Extend a few assertions with message to help attribute it to proper helper where needed.
internal/testcli/runner.go
Outdated
// once test has been executed. This is needed because flag values reside | ||
// in a global singleton data-structure, and thus subsequent tests might | ||
// otherwise interfere with each other | ||
r.registerFlagCleanup(cli) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This used to be true once in ancient times but is not true anymore. The command objects are not singleton anymore, cmd.New(ctx)
initializes a completely new command tree.
We should be able to remove this bit and the RunBackground
function from here, and the function itself should also be fine to remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this bit of context! I've cleaned up both SetContext and registerFlagCleanup from this PR.
Will clean up it fully in follow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The integration tests failed after the removal: https://github.com/databricks-eng/eng-dev-ecosystem/actions/runs/12579907431/job/35060907953
UPDATE: seems unrelated.
internal/testcli/golden.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note a couple of other helpers are present in:
- integration/libs/filer/helpers_test.go
- integration/libs/filer/filer_test.go (
filerTest
) - integration/python/python_tasks_test.go (
runPythonTasks
etc) - integration/enforce_convention_test.go (
enumeratePackages
)
And probably more...
Feel free to skip them though if you consider them to be out of scope for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, this PR does attempt to fix all. I am inclined to add them everywhere and add linter to enforce that though (in follow-up PRs).
This reverts commit 6b89f4c.
//nolint:staticcheck // cobra sets the context and doesn't clear it | ||
cli.SetContext(nil) | ||
|
||
return stdout, stderr, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the nuance around running this in the main goroutine vs a background one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.Helper() mechanism does not work for background goroutine.
…ilures were unrelated This reverts commit 7593e0d.
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
Changes
Tests
Manually reviewed test output.
Before:
After: