Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 2, 2026

The RE_MEM_INFO_START regex in memoryinfo.py only matched logs with space separators (*** Memory info name ***), failing on decorator formats using colons (*** Memory info: name ***).

Changes

Updated regex pattern (src/micropython_magic/memoryinfo.py:32)

  • Pattern now handles optional colon with flexible whitespace: \s*:?\s*
  • Uses [^*]* capture group (names cannot contain asterisks)
  • Trims leading/trailing whitespace from captured names
# Before
RE_MEM_INFO_START = re.compile(r"\*\*\* Memory info (.*) \*\*\*")

# After  
RE_MEM_INFO_START = re.compile(r"\*\*\* Memory info\s*:?\s*([^*]*?)\s*\*\*\*")

Test coverage (tests/test_memoryinfo_parser.py)

  • 19 parametrized test cases covering format variations
  • 4 integration tests for full log parsing with mixed formats
  • Validates backward compatibility with existing standard format

Supported formats

"*** Memory info test ***"           # Standard (space)
"*** Memory info: test ***"          # Decorator (colon + space)  
"*** Memory info:test ***"           # Decorator (no space)
"*** Memory info : test ***"         # Space before colon
"*** Memory info  test ***"          # Multiple spaces
Original prompt

On setup_meminfologger.ipynb, The log format used bij this decorator is not properly parsed bij the parser in https://github.com/Josverl/micropython-magic/blob/mpremoteboard/src%2Fmicropython_magic%2Fmemoryinfo.py


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 2, 2026 14:06
- Updated RE_MEM_INFO_START regex to handle colon separator
- Regex now matches both "*** Memory info test ***" and "*** Memory info: test ***"
- Added comprehensive tests for various punctuation patterns
- All existing tests pass with no regressions

Co-authored-by: Josverl <[email protected]>
- Changed regex to use [^*]* instead of .*? for semantic correctness
- Refactored tests to use pytest.parametrize for better maintainability
- Each test case now runs independently with clear failure reporting
- All 30 unit tests pass

Co-authored-by: Josverl <[email protected]>
Copilot AI changed the title [WIP] Fix log format parsing issue in memoryinfo Fix memoryinfo parser to handle decorator log format with colon separator Jan 2, 2026
Copilot AI requested a review from Josverl January 2, 2026 14:12
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.

2 participants