We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7bfe001 commit 428619dCopy full SHA for 428619d
crates/data/build.rs
@@ -1,5 +1,11 @@
1
fn main() {
2
- if std::env::var("PROFILE").as_deref() == Ok("release") {
+ let is_release = std::env::var("PROFILE").as_deref() == Ok("release");
3
+ // CARGO_PRIMARY_PACKAGE is only set for the crate being directly compiled,
4
+ // not for its (dev-)dependencies. A non-primary crate compiled in release
5
+ // mode is a dev-dependency of `cargo test --release`, which is fine.
6
+ let is_primary = std::env::var("CARGO_PRIMARY_PACKAGE").is_ok();
7
+
8
+ if is_release && is_primary {
9
panic!(
10
"\n\nhypr-data is a test-only crate.\nDo not add it to [dependencies]; use [dev-dependencies] instead.\n"
11
);
0 commit comments