-
Notifications
You must be signed in to change notification settings - Fork 35
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
main_binary
takes ~300ms per invocation
#6
Comments
From killercup: cargo issue: rust-lang/cargo#5315 |
So a user can work around this in assert_cmd by accessing lazy_static! {
const BIN_UNDER_TEST = assert-cmd::cargo_bin_path("bin_fixture");
}
#[test]
fn test_bin() {
Command::new(BIN_UNDER_TEST).assert().success();
} Should we provide an API on to simplify this? Example lazy_static!{
const BIN_FIXTURE = assert_cmd::cargo_bin("bin_fixture");
}
...
println!("{:?}", BIN_FIXTURE.path());
BIN_FIXTURE.cmd().arg("stdout", 42).unwrap(); |
main_binary
takes ~300ms to run 1 invocation
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. Also, a working example, freshly ~copypasted from a test for anyone else who's interested: use std::path::PathBuf;
lazy_static! {
static ref BIN_PATH: PathBuf = assert_cmd::cargo::main_binary_path().unwrap();
}
#[test]
fn test_bin() {
Command::new(&*BIN_PATH).assert().success();
} |
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 |
This helps with assert-rs#6.
This helps with assert-rs#6.
This helps with assert-rs#6.
According to this issue: assert-rs/assert_cmd#6. This also potentially solves lock issue in Travis.
According to this issue: assert-rs/assert_cmd#6. This also potentially solves lock issue in Travis.
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. |
Have we ever measured this again with newer cargo versions? I recall them
adding some caching for this, too.
…On Sun, 7 Oct 2018, 00:56 Ed Page, ***@***.***> wrote:
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.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#6 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABOX9lsA8jsePQJ2AkErzGU37rEu00Xks5uiTUogaJpZM4UQkyB>
.
|
@killercup , I just reran the original example that started everything. On the same laptop with nightly, it takes 125ms, so twice as fast as before. A big enough change that it actually feels way faster 👍
|
Good idea. I should add a benchmark that compares running the underlying program against running it via cargo. |
More data
|
I think we might have run into a related issue in |
@sharkdp sorry, I have been maintaining the work around in the docs but forgot to update this issue. I've done so now. |
@epage Thank you very much! Sorry for not checking the documentation. If I understand this correctly, this will still potentially compile (part of) the project in the first unit test, right? (link to my current implementation: sharkdp/bat#398) |
To get the path, it will still need to call into I recommend passing in |
@epage Thank you very much for the explanation. |
On Windows, for my program https://ci.appveyor.com/project/sourcefrog/conserve/builds/20036005 I think it'd at least be nice if this was more prominent in the docs top-level page, where there are examples of using the crate. |
main_binary
takes ~300ms to run 1 invocationmain_binary
takes ~300ms per invocation
@sourcefrog looking at your log, it looks like you are more so having problems with #57 (realized I should create a dedicated issue rather than pointing people to #4). #57 does need to be mentioned in the docs but I'm unsure if the top-level docs are appropriate for each workaround or special case. I also noticed that this issue's workaround is only mentioned in the I've created #58 to document the workaround and try to find a way to improve visibility. |
This is an experiemnt in a new direction in trying to resolve - Cargo overhead (assert-rs#6) - Compile times from mismatched `--target` (assert-rs#57) - Suprising behavior if `--target <triplet>` isn't specified (assert-rs#4) The new downsides this introduces - No `main_binary` or `cargo_example` - Can only work within integration tests We're recommending the use of `escargot` in these cases which I think might be reasonable because instead of making policy decisions for the user, and no one ever being happy, the user can choose which policy they want. Plus, in more complex cases they should already be using `escargot` so they can cache. Fixes assert-rs#6 Fixes assert-rs#57
This is an experiemnt in a new direction in trying to resolve - Cargo overhead (assert-rs#6) - Compile times from mismatched `--target` (assert-rs#57) - Suprising behavior if `--target <triplet>` isn't specified (assert-rs#4) The new downsides this introduces - No `main_binary` or `cargo_example` - Can only work within integration tests We're recommending the use of `escargot` in these cases which I think might be reasonable because instead of making policy decisions for the user, and no one ever being happy, the user can choose which policy they want. Plus, in more complex cases they should already be using `escargot` so they can cache. Fixes assert-rs#6 Fixes assert-rs#57 BREAKING CHANGE: `main_binary` / `cargo_example` no longer exist. Also, successfully running `cargo_bin` has been restricted to integration tests.
…holder README.md 'Crates Status' icon link
From @rcoh assert-rs/assert_cli#100
assert_cli
version: 0.5Unfortunately,
cargo run
takes at minimum about 300ms on my computer: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?
Workaround
See assert_cmd::cargo's docs
The text was updated successfully, but these errors were encountered: