Skip to content

Fix the exported run command - #2004

Merged
diemol merged 1 commit into
trunkfrom
export-run-command
Oct 30, 2026
Merged

diemol merged 1 commit into
trunkfrom
export-run-command

Conversation

@diemol

@diemol diemol commented Oct 30, 2026

Copy link
Copy Markdown
Member

Description

  • run in Python, Ruby and JavaScript calls the reused test by the same name its method is declared with (first letter lowercase). Before, run | Login called Login() while the method was login.
  • JavaScript run awaits the reused test (its method is async).
  • run with a test name from a variable is exported as a comment, e.g. # Cannot export run with a test name from a variable: self.vars["runCMD"]. The name is only known during playback. Before, it called a method that doesn't exist (runCMD()).
  • New hasVariable helper in side-code-export.
  • Tests for a capitalized test name and a variable test name in five language packages.

Motivation and Context

tests/examples/simple-parent.side uses run | ${runCMD}. Every project in tests/examples still exports to Python, Ruby and JavaScript that compiles.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

🤖 Generated with Claude Code

- Python, Ruby and JavaScript declare a reused test with a lowercase first
  letter, but run called it with the test's own case (Login() for a method
  named login). run now uses the same name.
- JavaScript run awaits the reused test, which is async.
- A test name from a variable is only known during playback, so run with
  one is exported as a comment that shows the variable, instead of a call
  to a method that doesn't exist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@diemol

diemol commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

/agentic_review

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix exported run calls and handle variable test names

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Match exported run calls to reused-test method names in Python, Ruby, and JavaScript.
• Await reused tests in JavaScript so asynchronous commands finish before execution continues.
• Export variable-based run targets as explanatory comments instead of calls to nonexistent methods.
Diagram

graph TD
  A["Run target"] --> B["Preprocess target"] --> C{"Variable?"}
  C -->|Yes| D["Emit comment"]
  C -->|No| E["Match method name"] --> F["Invoke test"] -->|JavaScript| G["Await call"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Generate runtime test dispatch
  • ➕ Variable-based run commands could retain their playback behavior in exported code.
  • ➖ Requires a generated test registry or equivalent lookup in every language.
  • ➖ Adds substantially more cross-language complexity than the static-call fix.

Recommendation: Use the PR's static-call fix and explicit comment for variable targets. Runtime dispatch would preserve more behavior, but its cross-language cost is disproportionate to this focused bug fix; the comment makes the export limitation visible.

Files changed (17) +147 / -16

Bug fix (6) +79 / -8
command.tsComment out C# runs with variable test names +12/-1

Comment out C# runs with variable test names

• Detects variable-based run targets and emits an explanatory comment instead of a method call. Static targets retain the existing sanitized call.

packages/code-export-csharp-commons/src/command.ts

command.tsComment out Java runs with variable test names +12/-1

Comment out Java runs with variable test names

• Emits an explanatory comment for variable-based run targets instead of a call to a nonexistent method. Static calls remain unchanged.

packages/code-export-java-junit/src/command.ts

command.tsAwait correctly named JavaScript reused tests +17/-2

Await correctly named JavaScript reused tests

• Matches static run calls to the lowercased-first-letter method declaration and awaits the async call. Variable-based targets produce an explanatory comment.

packages/code-export-javascript-mocha/src/command.ts

command.tsMatch Python run calls to reused-test methods +17/-2

Match Python run calls to reused-test methods

• Lowercases the first letter of static run method names to match their declarations. Variable-based targets produce an explanatory comment.

packages/code-export-python-pytest/src/command.ts

command.tsMatch Ruby run calls to reused-test methods +17/-2

Match Ruby run calls to reused-test methods

• Lowercases the first letter of static run method names to match their declarations. Variable-based targets produce an explanatory comment.

packages/code-export-ruby-rspec/src/command.ts

preprocessor.tsExpose detection of preprocessed variable references +4/-0

Expose detection of preprocessed variable references

• Adds a shared hasVariable helper that identifies the variable marker in a preprocessed parameter for language exporters.

packages/side-code-export/src/code-export/preprocessor.ts

Tests (11) +68 / -8
command.spec.js.snapRecord C# run output for capitalized and variable targets +4/-0

Record C# run output for capitalized and variable targets

• Adds snapshots for a capitalized static method call and a comment containing the resolved variable lookup.

packages/code-export-csharp-nunit/test/src/snapshots/command.spec.js.snap

command.spec.jsTest C# run targets with capitalization and variables +8/-0

Test C# run targets with capitalization and variables

• Adds command-emitter cases for a capitalized test name and a variable-based test name.

packages/code-export-csharp-nunit/test/src/command.spec.js

command.spec.js.snapRecord Java run output for capitalized and variable targets +4/-0

Record Java run output for capitalized and variable targets

• Adds snapshots for the existing capitalized static call and the new variable-target comment.

packages/code-export-java-junit/test/src/snapshots/command.spec.js.snap

command.spec.jsTest Java run targets with capitalization and variables +8/-0

Test Java run targets with capitalization and variables

• Adds command-emitter cases for a capitalized test name and a variable-based test name.

packages/code-export-java-junit/test/src/command.spec.js

command.spec.js.snapRecord awaited JavaScript runs and variable-target comments +5/-1

Record awaited JavaScript runs and variable-target comments

• Updates the static run snapshot to include await and adds snapshots for a capitalized test name and a variable-target comment.

packages/code-export-javascript-mocha/test/src/snapshots/command.spec.js.snap

index.spec.js.snapRecord awaited reused tests in exported JavaScript suites +7/-7

Record awaited reused tests in exported JavaScript suites

• Updates suite-level export snapshots so run commands await reused-test calls.

packages/code-export-javascript-mocha/test/src/snapshots/index.spec.js.snap

command.spec.jsTest JavaScript run targets with capitalization and variables +8/-0

Test JavaScript run targets with capitalization and variables

• Adds command-emitter cases for a capitalized test name and a variable-based test name.

packages/code-export-javascript-mocha/test/src/command.spec.js

command.spec.js.snapRecord Python naming and variable-target run output +4/-0

Record Python naming and variable-target run output

• Adds snapshots showing the lowercased-first-letter reused method call and a comment for a variable target.

packages/code-export-python-pytest/test/src/snapshots/command.spec.js.snap

command.spec.jsTest Python run targets with capitalization and variables +8/-0

Test Python run targets with capitalization and variables

• Adds command-emitter cases for a capitalized test name and a variable-based test name.

packages/code-export-python-pytest/test/src/command.spec.js

command.spec.js.snapRecord Ruby naming and variable-target run output +4/-0

Record Ruby naming and variable-target run output

• Adds snapshots showing the lowercased-first-letter reused method call and a comment for a variable target.

packages/code-export-ruby-rspec/test/src/snapshots/command.spec.js.snap

command.spec.jsTest Ruby run targets with capitalization and variables +8/-0

Test Ruby run targets with capitalization and variables

• Adds command-emitter cases for a capitalized test name and a variable-based test name.

packages/code-export-ruby-rspec/test/src/command.spec.js

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can route each severity your way: inline, summary, both, or drop

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@diemol
diemol merged commit 9410180 into trunk Oct 30, 2026
5 checks passed
@diemol
diemol deleted the export-run-command branch October 30, 2026 18:04
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.

1 participant