-
Notifications
You must be signed in to change notification settings - Fork 40
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 minutes on first run
#57
Comments
I noticed that, too. Workaround 3: Only pass |
Could you clarify this? The trade off is between when a user explicitly lists a As a possible hack in assert_cmd, even if I had a lookup table of default targets (keyed off of the current OS), there is still a trade off. Some people in their CI always pass I guess another hack is to have a build script that looks up |
My idea was to try and detect if cargo was run with a (Cargo also sets a TARGET env var, but only for build scripts it seems.) |
As far as I know, there is no direct way to detect |
Ah I see, sorry for the confusion. This a kinda unfortunate situation. I wonder how common the explicit |
If someone is creating a CLI using trust, its exclusively used in the CI while (I'm assuming) rarely used by the developer. Once I have time to get back to |
@matklad says the following should be guaranteed to work for bin targets // Adapted from
// https://github.com/rust-lang/cargo/blob/485670b3983b52289a2f353d589c57fae2f60f82/tests/testsuite/support/mod.rs#L507
fn target_dir() -> PathBuf {
env::current_exe().ok().map(|mut path| {
path.pop();
if path.ends_with("deps") {
path.pop();
}
path
}).unwrap()
}
fn cargo_review_deps_exe() -> PathBuf {
target_dir().join(format!("cargo-review-deps{}", env::consts::EXE_SUFFIX))
}
fn base_cmd() -> Assert {
Assert::command(&[&cargo_review_deps_exe()])
.with_args(&["review-deps"])
} Source: assert-rs/assert_cli#118 (comment) This would effectively give us auto-detection of Downsides
|
#67 is forcing me in making a decision I've been procastinating. Right now, we have a tension between #4 and #57. matklad's proposal resolves that tension but it would make cargo_bin function differently than main_binary and cargo_example such that I'm considering removing them both and telling people to use escargot if the want something besides cargo_bin. In summary, matklad's approach would
Any thoughts? |
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.
cargo test
takes a long time with because the first run ofmain_binary
takes a long time while holding thecargo
locking, blocking other testsExample
From https://ci.appveyor.com/project/sourcefrog/conserve/builds/20036005
Cause
cargo test
is run,cargo
usestarget/debug
for theOUT_DIR
main_binary
passes--target <TRIPLET>
tocargo
which changes theOUT_DIR
totarget/<TRIPLE>/debug
cargo test
s build artifacts cannot be reused and those parts need to be rebuiltBackground:
In Issue #4 we had to choose between performance and correctness (if you do specify
--target
,main_binary
should run that target'sbin
) and sided on correctnessWorkarounds
Call into escargot without passing in
current_target
Call
cargo test --target <TRIPLE>
The text was updated successfully, but these errors were encountered: