How to invoke one crate's executable target from another crate's integration tests?

In a workspace with multiple crates, how can one crates's integration tests depend on and invoke the executable target (not lib target) of another crate?

My workspace looks like this:

workspace/
├── a/
│   └── tests/integration.rs
└── b/
    ├── src/lib.rs
    └── src/main.rs

Crate a depends on b as a dev-dependency. And its tests need to be able to invoke b's executable target. In the past, that worked. But rust-nightly's build-layout-v2 moved things around, and assert_cmd-2.1.3 can no longer find b's executable target. With assert_cmd-2.2.2, the error message is more explicit: CARGO_BIN_EXE_b is unset. That error suggests to me that maybe assert_cmd isn't capable of doing what I need. Surely I'm not the only person who has encountered this problem. Has anybody solved it?

I am afraid these are the only way

  1. Move all code from main.rs to lib.rs as much as possible (afaik this is already the normal way of serious project). Main.rs is just the caller. If needed, makes main.rs only call 1 liner code :v so other project can call the code more

  2. Manual test via building the binary, running it, reading the error with std::command

If requiring nightly Rust is acceptable, then you should be able to use artifact dependencies for this purpose, to explicitly depend on the binary you need.

Very cool! This is exactly what I want. And I'm fine with this particular integration test requiring nightly. However, I want the rest of the crate to still compile on stable Rust. So I just need to figure out how to skip that test when using the stable compiler. I may have to move the entire test into its own crate. That's not ideal, but it'll do. I like this approach better than moving the entire contents of my bin into my lib.

artifact dependency is a unstable feature of cargo, not the compiler rustc.

unfortunately, since we don't have quivalent of conditional compilation flag for cargo manifest file, it's impossible to enable the unstable feature only for a single integration test while keep other crates in the same package compatible with stable cargo, because stable cargo can't load the manifest file at all.

so, if you want to use artifact dependencies, this integration test crate needs to be in its own package (or rather, it's own workspace) so it has a separate Cargo.toml from the other packages.