Skip to content

transpile: tests: Run test_translator.py from cargo nextest with the currently built transpiler path#1731

Open
chiragdhawan24 wants to merge 5 commits intoimmunant:masterfrom
chiragdhawan24:chirag/auto-compile-before-tests
Open

transpile: tests: Run test_translator.py from cargo nextest with the currently built transpiler path#1731
chiragdhawan24 wants to merge 5 commits intoimmunant:masterfrom
chiragdhawan24:chirag/auto-compile-before-tests

Conversation

@chiragdhawan24
Copy link
Copy Markdown

When running the tests, test_translator.py could end up using a stale c2rust/c2rust-transpile binary unless cargo build --release had been run manually beforehand.

This change updates the test flow so repo tests use the latest version of c2rust-transpile binary built by cargo test, by passing the current transpiler path into test_translator.py and overriding the configured transpiler path for that test run.

This removes the manual pre-build requirement and makes local test execution less error-prone.

Testing:

  • ran cargo test -- --nocapture
  • verified that test_translator.py was invoked, and it received the expected c2rust-transpile path
  • confirmed the tests ran successfully without manually running cargo build --release

@kkysen kkysen self-requested a review April 5, 2026 04:27
Comment thread c2rust/tests/test_translator_uses_current_transpiler.rs Outdated
Comment thread c2rust/tests/test_translator_uses_current_transpiler.rs Outdated
Comment thread scripts/test_translator.py
Comment thread scripts/test_translator.py Outdated
Comment on lines +17 to +18
"test_translator.py failed with status: {}",
status
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
"test_translator.py failed with status: {}",
status
"test_translator.py failed with status: {status}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you also print the whole command that failed? Like this

let mut cmd = Command::new("../scripts/test_translator.py");
cmd.args(["../tests/unit", "--transpiler"]);
cmd.arg(transpile_path);
let status = cmd.status().unwrap_or_else(|e| panic!("{cmd:?} failed: {e}");
assert!(status.success(), "{cmd:?} failed with {status}");

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I have addressed this in the latest commit.

Comment thread c2rust/tests/test_translator_uses_current_transpiler.rs Outdated
@kkysen kkysen changed the title Allow test_translator.py to use an explicit transpiler path (the latest debug build of c2rust-transpile) transpile: tests: Run test_translator.py from cargo nextest with the currently built transpiler path Apr 7, 2026
Copy link
Copy Markdown
Contributor

@kkysen kkysen left a comment

Choose a reason for hiding this comment

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

Thanks for this! A few other things:

We use cargo nextest run instead of cargo test, so run that locally instead.

Can you update the README and anywhere else that references test_translator.py to say you can also just run cargo nextest run?

@chiragdhawan24 chiragdhawan24 requested a review from kkysen April 9, 2026 01:32
Comment thread c2rust/tests/test_translator.rs Outdated
Comment thread c2rust/tests/test_translator.rs
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.

3 participants