diff options
| author | Andrew Leech <andrew.leech@planetinnovation.com.au> | 2025-05-26 19:31:30 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-11-22 00:06:59 +1100 |
| commit | e067d96c8b71b3fe258583fd6cddb1094cb4efe5 (patch) | |
| tree | d04978be6c7739c6987d6f40137191682a5b2baf /tests/micropython/test_normalize_newlines.py | |
| parent | 7ac8fcf752389e2af37b49994478bd9d93f48434 (diff) | |
tests/run-tests.py: Add general newline normalization function.
Add a general normalize_newlines() function that handles newline variations
(\\r\\r\\n, \\r\\n) to \\n while preserving literal \\r characters that are
part of test content.
This provides a robust solution for cross-platform test compatibility,
particularly addressing PTY double-newline issues that can occur with some
terminal implementations.
The function is applied to all test output before comparison, eliminating
platform-specific newline issues.
Includes a unit test to verify the normalization behavior.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Diffstat (limited to 'tests/micropython/test_normalize_newlines.py')
| -rw-r--r-- | tests/micropython/test_normalize_newlines.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/micropython/test_normalize_newlines.py b/tests/micropython/test_normalize_newlines.py new file mode 100644 index 000000000..f19aaa69a --- /dev/null +++ b/tests/micropython/test_normalize_newlines.py @@ -0,0 +1,14 @@ +# Test for normalize_newlines functionality +# This test verifies that test framework handles various newline combinations correctly + +# Note: This is more of an integration test since normalize_newlines is in the test framework +# The actual testing happens when this test is run through run-tests.py + +print("Testing newline handling") +print("Line 1\r\nLine 2") # Windows-style line ending - should be normalized +print("Line 3") # Normal line +print("Line 4") # Normal line +print("Line 5\nLine 6") # Unix-style line ending - already normalized + +# Test that literal \r in strings is preserved +print(repr("test\rstring")) # Should show 'test\rstring' not 'test\nstring' |
