Skip to content

Robot Framework part 1: Source Reader #2247

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

Merged
merged 1 commit into from
May 15, 2025

Conversation

haxtibal
Copy link
Contributor

This adds language aware reading of test cases from *.robot files. Each Robot Framework test case is represented as Function object in the internal StrictDoc model.

We gain following features compared to language agnostic text reading:

  • sdoc can now have forward relations to specific test cases by test case name.
  • Relation markers with scope=function will automatically cover the range from test case start line to test case end line, and are linked with the function object.
  • An upcoming test result (output.xml) reader can automatically link test results with the related robot framework test cases.

For parsing we use the public parsing API provided by the upstream project. Thus "robotframework" becomes a dependency of strictdoc.

Note: Language aware reading is turned on by SOURCE_FILE_LANGUAGE_PARSERS in strictdoc.toml.

@haxtibal haxtibal force-pushed the tdmg/robot_src_reader branch from 13a4751 to c3df206 Compare May 14, 2025 17:28
Copy link
Collaborator

@stanislaw stanislaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot check your branch to run your tests locally today but it looks great overall.

I left only 2 minor comments.

This adds language aware reading of test cases from *.robot files. Each
Robot Framework test case gets represented as Function object in the
internal StrictDoc model.

We gain following features compared to language agnostic text reading:
- sdoc can now have forward relations to specific test cases by test
  case name.
- Relation markers with scope=function will automatically cover the
  range from test case start line to test case end line, and are linked
  with the function object.
- An upcoming test result (output.xml) reader can automatically link
  test results with the related robot framework test cases.

For parsing we use the public parsing API provided by the upstream
project [1]. Thus "robotframework" becomes a dependency of strictdoc.

Note: Language aware reading is turned on by
SOURCE_FILE_LANGUAGE_PARSERS in strictdoc.toml.

[1] https://robot-framework.readthedocs.io/en/latest/autodoc/robot.api.html
@haxtibal haxtibal force-pushed the tdmg/robot_src_reader branch from c3df206 to 0647af5 Compare May 15, 2025 05:41
@stanislaw stanislaw merged commit 90434d8 into strictdoc-project:main May 15, 2025
14 checks passed
@stanislaw
Copy link
Collaborator

Checked the itests quickly. Everything looks great. Thanks for contributing strongly.

@stanislaw stanislaw added this to the 2025-Q2 milestone May 15, 2025
@haxtibal
Copy link
Contributor Author

I wonder if we should automatically add a role to the new test case function relations. I see similar already happens for test reports, where strictdoc automatically adds role "IsSatisfiedBy/Satisfies".

@stanislaw @nicpappler How about this:

  • Auto assign roles for links to test case source code. Auto assigned roles shall be named hasTestCase. Rationale: That's what's currently in SPDX 3. I'd really like if we followed a standard vocabulary, and SPDX is probably the best bet (given the meaning behind SPDX:hasTestCase actually matches our use case).
  • If user opted to define the role explicitly, as for example in @relation(scope=function, role=foo), don't auto assign, but use the user supplied value.

@stanislaw
Copy link
Collaborator

I wonder if we should automatically add a role to the new test case function relations. I see similar already happens for test reports, where strictdoc automatically adds role "IsSatisfiedBy/Satisfies".

This was a quick coding placeholder. Feel free to change it to a more matching name.

@stanislaw
Copy link
Collaborator

hasTestCase sounds reasonable.

@stanislaw
Copy link
Collaborator

hasTestCase sounds reasonable.

What is then the reverse name for this relation?

@haxtibal
Copy link
Contributor Author

hasTestCase sounds reasonable.

What is then the reverse name for this relation?

That could best be answered by @nicpappler. If I understand correctly, there is no reverse name. SPDX assumes a from-end and a to-end, and clarifies the reverse by documentation:

Every to Element is a test case for the from Element

@haxtibal
Copy link
Contributor Author

[...] test reports, where strictdoc automatically adds role "IsSatisfiedBy/Satisfies".

This was a quick coding placeholder. Feel free to change it to a more matching name.

No better idea at the moment. I merely mentioned it to ask "if we do auto-assignment already in test report parsing, should we do it also in source code parsing?".

@stanislaw
Copy link
Collaborator

hasTestCase sounds reasonable.

What is then the reverse name for this relation?

That could best be answered by @nicpappler. If I understand correctly, there is no reverse name. SPDX assumes a from-end and a to-end, and clarifies the reverse by documentation:

Every to Element is a test case for the from Element

We never discussed this in detail until now.

One way of doing this would be to do hasTestCase and maybe testCaseFor (writing this I am not sure I am onboard with the camelCase but that is a separate topic).

Another approach could just be saying TestCase and have both the forward and backward relations be named the same. I think @haxtibal you did something similar in your itests for markers/roles.

It is a great discussion point overall when it comes to synchronizing between what the SDoc does with its Parent/Child relations (forward and backward links) and what the SPDX does (I am not fully in the picture).

@haxtibal At the same time, your implementation should not be blocked by this naming issue, so you could proceed without changing this aspect just yet.

@nicpappler
Copy link

We currently do not have a SPDX relationship for a reverse trace from test to source or requirements yet. Also did not discuss it. The one that comes closest at the moment is hasInput. Please feel free to suggest a link/relationship name, I can take this to the SPDX meeting to get it into the SPDX version 3.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants