Closed
Description
From @rcoh assert-rs/assert_cli#100
assert_cli
version: 0.5- Rust version: 1.25.0
- OS and version: Ubuntu 16.04
Unfortunately,cargo run
takes at minimum about 300ms on my computer:
➜ angle-grinder git:(master) ✗ time cargo run --bin agrind -- '* | json | count' --file test_files/empty
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Running `target/debug/agrind '* | json | count' --file test_files/empty`
No data
cargo run --bin agrind -- '* | json | count' --file test_files/empty 0.22s user 0.06s system 92% cpu 0.307 total
It makes it impractical to run hundreds of integration tests with assert_cli.
I'm not positive what a better way would be -- I guess running the binary in dist directly if it exists?
Activity
epage commentedon May 28, 2018
From killercup: cargo issue: rust-lang/cargo#5315
epage commentedon May 29, 2018
So a user can work around this in assert_cmd by accessing
cargo_bin_path
, etc. This causes the 300ms to only be hit once instead of on every run.Should we provide an API on to simplify this?
Example
[-]Takes ~300ms to run 1 invocation[/-][+]`main_binary` takes ~300ms to run 1 invocation[/+]zetok commentedon Jul 24, 2018
Additions to API aren't needed, but docs that would point out this functionality would be really helpful. Since right now one needs to go to the issue tracker of the crate to find the solution, which is suboptimal.
As for why an additional API is not needed – e.g.
regex
crate doesn't have an additional API for creating a static regexp, but it has a great documentation where it shows on the "main" page of its docs an example on how to uselazy_static
to reduce unnecessary computations. It's nice.Also, a working example, freshly ~copypasted from a test for anyone else who's interested:
epage commentedon Jul 25, 2018
The difference is the main purpose of this crate is running programs. Its a bit of a wart in the API to have functions that provide paths to programs you could run. It'd be nice if
Command
supportedclone
.docs(cargo): Provide pointers on how to cache
docs(cargo): Provide pointers on how to cache
docs(cargo): Provide pointers on how to cache
assert_cmd
mesalock-linux/mesabox#24tests: use static command binary name to increase startup time
tests: use static command binary name to reduce startup time
epage commentedon Oct 6, 2018
I think at this point this is mostly kept open to track and be aware of the slow down. We have workarounds but thats all they are.
killercup commentedon Oct 7, 2018
20 remaining items