You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been attempting to run Diesel's test suite on Windows, and can't seem to find a way to link a C library. Specifically what I want to be able to do is cargo test -- -LC:\PostgreSQL\lib, but that argument is silently ignored, as is cargo test -- -C link-args="C:\PostgreSQL\lib". cargo rustc -- -LC:\PostgreSQL\lib works fine (though isn't helpful), but cargo rustc --test -- -LC:\PostgreSQL\lib complains that it doesn't know what -L is, and cargo rustc -- --test -LC:\PostgreSQL\lib doesn't include dev-dependencies.
As such, there appears to be no way to test a crate with cargo on Windows if the crate has C libraries that need to be linked, as there doesn't appear to be an environment variable that can be set either.
The text was updated successfully, but these errors were encountered:
Ah, I think that the crux of this issue is a dupe of #2120, so I'm going to close in favor of that, but there's a few other things in play here:
First, to link a C library, it's generally recommended to use a build script which can do any form of dynamic detection of the OS, runtime, etc. This build script is then generally shipped in the form of a library which is then reusable by everyone!
cargo test -- -LC:\PostgreSQL\lib - this command is actually saying to pass the -L argument to the test binary which is generated (e.g. the arguments after -- are just passed through). It may be the case that our test binaries just ignore unknown flags (like -L)
cargo test -- -C link-args="C:\PostgreSQL\lib - as the previous one, this is just passing an argument to the test binary, no the compiler itself.
cargo rustc -- -LC:\PostgreSQL\lib - this actually will pass the argument to the compiler, but as you've found it wasn't building your test so not too useful.
cargo rustc --test -- -LC:\PostgreSQL\lib - this is actually an interesting one! So when you pass --test to the cargo rustc command (not the underlying rustc), then you're selecting which test to compile. So what this is actually doing is compiling the test named -- (the first thing after the --test argument). The -L flag is then being interpreted as an argument to cargo rustc itself, which is an unknown flag (hence the error)
cargo rustc -- --test -LC:\PostgreSQL\lib - aha, and now we run into build test binary with cargo rustc #2120! This should definitely work, but that issue means there's no way for cargo rustc to include dev-dependencies right now unfortunately.
I've been attempting to run Diesel's test suite on Windows, and can't seem to find a way to link a C library. Specifically what I want to be able to do is
cargo test -- -LC:\PostgreSQL\lib
, but that argument is silently ignored, as iscargo test -- -C link-args="C:\PostgreSQL\lib"
.cargo rustc -- -LC:\PostgreSQL\lib
works fine (though isn't helpful), butcargo rustc --test -- -LC:\PostgreSQL\lib
complains that it doesn't know what-L
is, andcargo rustc -- --test -LC:\PostgreSQL\lib
doesn't include dev-dependencies.As such, there appears to be no way to test a crate with cargo on Windows if the crate has C libraries that need to be linked, as there doesn't appear to be an environment variable that can be set either.
The text was updated successfully, but these errors were encountered: