Skip to content

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

Open
chiragdhawan24 wants to merge 7 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 7 commits intoimmunant:masterfrom
chiragdhawan24:chirag/auto-compile-before-tests

Conversation

@chiragdhawan24
Copy link
Copy Markdown

@chiragdhawan24 chiragdhawan24 commented Apr 5, 2026

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 nextest run, 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 nextest run locally
  • 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 thread c2rust/tests/test_translator_uses_current_transpiler.rs Outdated
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
@chiragdhawan24 chiragdhawan24 requested a review from kkysen April 22, 2026 01:15
@chiragdhawan24
Copy link
Copy Markdown
Author

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?

I have updated README and other files where test_translator.py was mentioned. Kindly review the changes and let me know if they're alright.

Comment thread docs/README-developers.md Outdated
Comment on lines +78 to +92
*Note*: These run integration tests that invoke `c2rust transpile`.
`cargo test` only runs unit tests and doc tests as of now.

*Note*: The tests executed by `test_translator.py` can also be invoked simply by running `cargo nextest run` in the main c2rust workspace. `cargo nextest run` even ensures that the repo tests use the latest version of `c2rust-transpile` binary.
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
*Note*: The tests executed by `test_translator.py` can also be invoked simply by running `cargo nextest run` in the main c2rust workspace. `cargo nextest run` even ensures that the repo tests use the latest version of `c2rust-transpile` binary.
Most tests are found in the [`tests`](../tests/) folder.
Most tests can also be run with
```sh
cargo nextest run

which includes running the tests/unit tests.
The tests/unit tests can also be run manually using

./scripts/test_translator.py tests/unit

which also allows you to run with other options.

The tests/integration tests
aren't run automatically by cargo nextest run.
To run them, run

# Needs to be run from `tests/integration/` (or further inside)
# to correctly load the `pyproject.toml`.
cargo build --release
(export PATH=$PWD/target/release:$PATH && export C2RUST_DIR=$PWD && cd tests/integration && ./test.py curl json-c lua nginx zstd li
bxml2 python2 libmcs)

Copy link
Copy Markdown
Author

@chiragdhawan24 chiragdhawan24 May 5, 2026

Choose a reason for hiding this comment

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

I have changed the docs/README-developers.md as per the said changes in the latest commit.

Kindly re-review the same. Would really appreciate if this could now be merged into the master branch.

@chiragdhawan24 chiragdhawan24 requested a review from kkysen May 5, 2026 02:12
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