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

Ensure Logs Are Captured for Assertions and Printed During Tests #7769

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

raymondkfcheung
Copy link
Contributor

@raymondkfcheung raymondkfcheung commented Mar 3, 2025

This PR enhances test_log_capture, ensuring logs are captured for assertions and printed to the console during test execution.

Motivation

Changes

  • Ensures logs up to TRACE level are captured (for assertions) and printed (for visibility).
  • Refines documentation to clearly specify when to use each function.
  • Removes ANSI escape codes from captured logs to ensure clean, readable assertions.

When to Use?

Usage Captures Logs? Prints Logs? Example
init_log_capture(LevelFilter::INFO, false) ✅ Yes ❌ No Capture logs for assertions without printing.
init_log_capture(LevelFilter::TRACE, true) ✅ Yes ✅ Yes Capture logs and print them in test output.
sp_tracing::init_for_tests() ❌ No ✅ Yes Print logs to the console without capturing.

@raymondkfcheung raymondkfcheung self-assigned this Mar 3, 2025
@raymondkfcheung raymondkfcheung added the T10-tests This PR/Issue is related to tests. label Mar 3, 2025
@raymondkfcheung
Copy link
Contributor Author

/cmd prdoc --audience runtime_dev --bump minor

@raymondkfcheung
Copy link
Contributor Author

/cmd fmt

@raymondkfcheung
Copy link
Contributor Author

/cmd fmt

@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: build-test-collators
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/8301234

@raymondkfcheung
Copy link
Contributor Author

/cmd fmt

@acatangiu acatangiu requested a review from serban300 March 4, 2025 10:44
@raymondkfcheung raymondkfcheung requested a review from a team as a code owner March 4, 2025 17:16
@raymondkfcheung raymondkfcheung added the T6-XCM This PR/Issue is related to XCM. label Mar 4, 2025
@raymondkfcheung
Copy link
Contributor Author

/cmd fmt

raymondkfcheung added a commit to jpserrat/polkadot-sdk that referenced this pull request Mar 5, 2025
@paritytech-workflow-stopper
Copy link

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/13675331552
Failed job name: test-linux-stable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T6-XCM This PR/Issue is related to XCM. T10-tests This PR/Issue is related to tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants