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

dcrdtest: Remove need for *testing.T #17

Merged
merged 1 commit into from
Oct 18, 2023
Merged

Conversation

matheusd
Copy link
Member

@matheusd matheusd commented Jul 24, 2023

This removes the need for passing a valid *testing.T object to the harness initializing function New() by switching the logging statements from using the test object to log it to using a standard slog logger.

The API is not yet changed to avoid having to perform a major version bump in the package, but a deprecation note is added to the function's documentation.

The purpose of this change is to allow this package to be more broadly useful, not just in tests, but also in benchmarks and in generic code not tied specifically to tests.

Fixes #2

This removes the need for passing a valid *testing.T object to the
harness initializing function New() by switching the logging statements
from using the test object to log it to using a standard slog logger.

The API is not yet changed to avoid having to perform a major version
bump in the package, but a deprecation note is added to the function's
documentation.

The purpose of this change is to allow this package to be more broadly
useful, not just in tests, but also in benchmarks and in generic code
not tied specifically to tests.
if err := h.node.shutdown(); err != nil {
return err
}

if !(debug || trace) {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this should be retained via another means?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. The way I've done it in dcrlnd is that on test failures, the data dirs (dcrd, dcrwallet, etc) are kept, while on test successes they are automatically removed. I could bring that same behavior here, or add a *Harness.KeepTestNodeDir() or something for doing it manually.

I'm working on an additional PR that improves setup/teardown reliability, so I could also add it as part of that.

Copy link
Member

Choose a reason for hiding this comment

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

Nice. That'll work.

@davecgh davecgh merged commit 53bcbaa into decred:master Oct 18, 2023
6 checks passed
@matheusd matheusd deleted the logging branch October 18, 2023 18:31
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.

Remove need to pass testing.T to harness objects
2 participants