Skip to content
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

Allow passing additional arguments to cargo test and cargo bench in rust-script #146

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

leemars
Copy link
Contributor

@leemars leemars commented Dec 22, 2024

Based on the information from Stack Overflow, when executing tests with cargo test, the --nocapture flag is required to display the output of println! in Rust tests. However, the current implementation of rust-script ignores all additional arguments when executing scripts with the --test flag (and likely also with the --bench mode, based on the code).

To fix this, I propose a minor change: when the build_kind is not Normal (i.e., when it's Test or Bench), we append script_args to the command line.

Although this is a small change, considering the complexity of real-world environments, I am not certain whether supporting the passing of additional arguments to cargo test, cargo bench, and the tested programs will introduce any additional security issues (hopefully not).

Welcome any feedback or suggestions for improvement.

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