Allow passing additional arguments to cargo test
and cargo bench
in rust-script
#146
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Based on the information from Stack Overflow, when executing tests with
cargo test
, the--nocapture
flag is required to display the output ofprintln!
in Rust tests. However, the current implementation ofrust-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 notNormal
(i.e., when it'sTest
orBench
), we appendscript_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.