Skip to content

[ENHANCEMENT] Transitive keyword usage lookup #616

@vargbahu

Description

@vargbahu

We run a CI pipeline that selectively executes only the test cases affected by a pull request. When a shared keyword in a .resource file or a Python library changes, we need to find every test case that (transitively) calls it across the whole workspace.

We currently do this with a custom static-analysis module built on top of robot.api.
robotcode's language server already resolves imports correctly and maintains an inverse reference index (ProjectIndex), but there is no CLI surface to query it.

Proposed solution

A new filter for robotcode discover tests that performs a transitive search to find out which test case calls a specific keyword:

robotcode discover tests --uses-keyword "Keyword Name"
  • a test is only included if the file containing the named keyword is actually imported (directly or transitively) by that test's suite.
  • the search walks backwards through the full call graph, so tests that reach the keyword through one or more wrapper keywords are also included.

Alternatively, if we could specify the file and the keyword as well would be useful:

robotcode discover tests --uses-keyword "path/to/file.resource::Keyword Name"

This way we could avoid false positives caused by similar keyword names defined in different (unrelated) resource files. This is a rare case and maybe not that important, but theoretically possible.

Analogous options for variables and libraries would also be valuable:

robotcode discover tests --uses-variable "${VarName}"
robotcode discover tests --uses-library  "MyLibrary"

The output should follow the same JSON format as the existing discover tests command so it can be consumed by CI scripts without post-processing.

Alternatives we've considered

  • robotcode discover tests --search "Keyword Name"— performs a text match inside test bodies, not a semantic call-graph traversal. It misses tests that call a wrapper keyword which in turn calls the changed one, and has no import-scope awareness.
  • Maintaining our own call-graph module — the current approach that we use, which works but requires us to reimplement logic (import resolution, call-graph building, BFS) that robotcode already contains internally.

Additional context

git diff / git show is used to determine the changed content
robot.api is used to parse RF files and to find keywords related to changes

robotcode version: 2.6.0
Robot Framework: 7.4.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions