Integration tests for cdylib targets

Hello,
in a project with a cdylib target, I'd like to build the library and use it in integration tests, similarly to what happens with CARGO_BIN_EXE_<name>, but apparently it is not set for cdylib targets, only for binaries.

Without a proper variable like CARGO_BIN_EXE_<name>, the only solution I found was to explicitly write the path somewhere, but this is a bit flaky because the output directory can be in non standard paths (e.g. build.target-dir can be set in .cargo/config.toml). Unless there is a method to reliably get the target dir when running tests, but even OUT_DIR` doesn't seem appropriate here.

Moreover, while binaries are automatically built for integration tests, the method I'm using relies on the cdylib being built manually - which is also not great.

Is there a way to fix this?
Thank you!

PS
I just realized that maybe CARGO_TARGET_TMPDIR could be used as a target directory for building the cdylib when integration tests start; I don't love this because it would involve invoking cargo during the tests.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.