Add progress counter to ./mfc.sh test#980
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds a progress counter to the MFC test runner, displaying the current test number and total test count during test execution. This enhancement improves user experience by providing visibility into test progress.
Key changes:
- Added global variables to track current test number and total test count
- Modified test output format to include progress information
- Updated the test header to accommodate the new progress column
| def _handle_case(case: TestCase, devices: typing.Set[int]): | ||
| # pylint: disable=global-statement, global-variable-not-assigned | ||
| global current_test_number | ||
| start_time = time.time() |
There was a problem hiding this comment.
The global variable current_test_number is being modified in _handle_case which appears to be called from multiple threads based on the comment 'Run cases with multiple threads'. This creates a race condition where multiple threads could increment the counter simultaneously, leading to incorrect progress reporting.
| start_time = time.time() | |
| start_time = time.time() | |
| # Ensure thread-safe increment of current_test_number | |
| with current_test_number_lock: | |
| current_test_number += 1 |
| current_test_number += 1 | ||
| progress_str = f"({current_test_number:3d}/{total_test_count:3d})" |
There was a problem hiding this comment.
This increment operation is not thread-safe. When multiple test cases run concurrently, the progress counter will be inaccurate due to race conditions. Consider using a thread-safe counter or moving this logic to a synchronized section.
| current_test_number += 1 | |
| progress_str = f"({current_test_number:3d}/{total_test_count:3d})" | |
| with current_test_number_lock: | |
| current_test_number += 1 | |
| progress_str = f"({current_test_number:3d}/{total_test_count:3d})" |
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||
User description
Adds progress counter to test.
PR Type
Enhancement
Description
Add progress counter to test execution output
Update job name formatting in CI script
Diagram Walkthrough
File Walkthrough
test.py
Add progress tracking to test executiontoolchain/mfc/test/test.py
current_test_numberandtotal_test_countfortracking progress
total_test_countwith the number of test casessubmit.sh
Fix job name formatting.github/workflows/frontier/submit.sh