Repository navigation
Enable embedding tests/tasks to Markdown files #5603 - #5633
Conversation
|
Thanks for the PR! I don't have time for a proper review now, but based on a quick look at the implementation I have one request. Could you move the code related to reading Markdown data from I know there's |
|
Hello Pekka, thanks for the quick look! |
|
Refactoring complete! Moved the Markdown reading logic into All utest and atest are passing locally. Let me know if it looks good to you! |
There was a problem hiding this comment.
Pull request overview
Adds Markdown (.md, .markdown, .robot.md) as a supported data format for Robot Framework suite/resource parsing, updating extension handling across runtime builder/import logic and introducing acceptance + unit coverage for the new behavior.
Changes:
- Introduces
MarkdownParserto extract Robot Framework fenced code blocks from Markdown sources. - Extends suite/resource extension handling to recognize Markdown-based files (including
.robot.mdby default for suites). - Adds acceptance test data and test cases covering Markdown parsing, resource importing, and CLI/extension behaviors.
Reviewed changes
Copilot reviewed 20 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| utest/running/test_markdownparser.py | Unit tests for Markdown fenced-block extraction logic. |
| src/robot/running/importer.py | Allows .md/.markdown as valid resource file extensions. |
| src/robot/running/builder/parsers.py | Adds MarkdownParser implementation for extracting Robot data from Markdown fences. |
| src/robot/running/builder/builders.py | Wires MarkdownParser into suite/resource builder parser selection and extension mapping. |
| src/robot/parsing/suitestructure.py | Adds .robot.md to default suite structure extensions. |
| src/robot/conf/settings.py | Adds .robot.md to default CLI --extension setting. |
| atest/testdata/parsing/data_formats/resources/markdown_resource.md | New Markdown resource test data. |
| atest/testdata/parsing/data_formats/resource_extensions/tests.robot | Extends resource extension test to include .md/.markdown. |
| atest/testdata/parsing/data_formats/resource_extensions/resource.md | New Markdown resource file test data (.md). |
| atest/testdata/parsing/data_formats/resource_extensions/resource.markdown | New Markdown resource file test data (.markdown). |
| atest/testdata/parsing/data_formats/markdown/with_init/sub_suite2.robot.md | New .robot.md suite test data. |
| atest/testdata/parsing/data_formats/markdown/with_init/sub_suite1.MD | New uppercase .MD suite test data. |
| atest/testdata/parsing/data_formats/markdown/with_init/init.md | New Markdown init file test data. |
| atest/testdata/parsing/data_formats/markdown/sample.md | Comprehensive Markdown suite sample with multiple robot blocks + ignored content. |
| atest/testdata/parsing/data_formats/markdown/invalid.markdown | Markdown file with no robot blocks for “no tests/tasks” behavior. |
| atest/robot/parsing/data_formats/resource_extensions.robot | Updates expected supported extensions and line references for resource extension tests. |
| atest/robot/parsing/data_formats/markdown.robot | New acceptance tests validating Markdown parsing, directory behavior, and error sources. |
| atest/robot/parsing/data_formats/formats_resource.robot | Adds ${MARKDOWN DIR} used by new Markdown acceptance tests. |
| atest/robot/cli/runner/included_files.robot | Updates expected counts/line refs impacted by added parsing test coverage. |
| atest/robot/cli/runner/extension.robot | Updates expected counts/line refs impacted by new Markdown-related coverage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
pekkaklarck
left a comment
There was a problem hiding this comment.
I only reviewed the code changes now. They look good in general and most of my comments were somewhat nitpickey. We do need to think about detecting starting code blocks, though, but I'll comment the original issue about that.
…tframework#5603) - Added .robot.md to default extensions in RobotSettings. - Registered MarkdownParser in TestSuiteBuilder and ResourceFileBuilder. - Updated SuiteStructureBuilder to recognize Markdown files. - Added read_markdown_data to robot.utils and a placeholder in markdownreader.
- Added .md and .markdown to RESOURCE_EXTENSIONS in Importer.
…otframework#5603) - Integrated a new MarkdownParser using a lightweight FSM. - Added support for both ```robotframework and ```robot code blocks. - Implemented line-synchronization logic by preserving empty lines for non-robot content, ensuring accurate error reporting.
…#5603) - Followed the existing reStructuredText (RST) test structure to ensure parity. - Added test cases for parsing suites from .md and .robot.md files.
…#5603) - Reverted vertical formatting for included_extensions to maintain horizontal density.
…code blocks - Updated unit tests to cover related edge cases.
…amework#5603) - Use Regex for code fence detection (supports ``` and ~~~). - Handle variable fence lengths and info strings. - Use textwrap.dedent for robust indentation management. - Remove redundant string stripping and pending separators.
ccfcd7c to
c530937
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 23 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I've updated the PR with the following changes:
All local unit tests and acceptance tests are passing on my end. |
|
I took a quick look at the code and it looks great! There are some nitpickey things that could be changed, but I believe it's best I merge this PR and do such changes myself. I also need to take a more closer look at the test. The main thing missing seems to be documentation. It can be added after this PR is merged, but certainly needs to be done before closing #5603. Do you @seto have interest to look at the docs as well? |
| # ``` | ||
| md = ( | ||
| "```robotframework\n*** Test Cases ***\nMy Test Log Hello, RF!\n```\n" | ||
| ) |
There was a problem hiding this comment.
Formatting input strings using triple-quoted strings like
md = """
```robotframework
*** Test Cases ***
My Test Log Hello, RF!
"""
would make tests easier to read and avoid the need to have the comment with same data.
|
Tests look great as well! It seems you used acceptance tests for other formats as a base which is great for consistency and maintainability. The only thing that I noticed that could/should be changed is how input data is formatted with unit tests. I can do that after I've merged this PR along with small code changes. |
This pull request introduces support for parsing test data and resource files written in Markdown format (
.md,.markdown,.robot.md) in addition to the existing formats. It adds new parser logic, updates file extension handling throughout the codebase, and provides comprehensive acceptance tests to ensure correct behavior for Markdown files.Markdown file format support
MarkdownParserclass inparsers.pyto handle.md,.markdown, and.robot.mdfiles, utilizing theprivate methodread_markdown_datautility_read_markdown_datainsideMarkdownParserfor parsing.MarkdownParserfor Markdown file extensions in both test suite and resource file parsing..robot.md.Acceptance and Unit tests for Markdown support
atest/testdata/parsing/data_formats/markdown/to verify correct parsing, error reporting, and suite structure for Markdown files, including edge cases and directory handling..mdand.markdownresources are parsed and imported correctly.utest/parsing/test_markdownreader.pyutest/parsing/test_markdownparser.pyto validate the state-machine logic and edge cases (empty blocks, unclosed fences, etc.).These changes ensure that Robot Framework can now seamlessly parse and execute tests and resources written in Markdown, with robust test coverage for the new functionality.