I wonder if this can be done with a build script. Putting the java probe from above in the build script:
fn main() {
println!("cargo::rerun-if-changed=build.rs");
println!("cargo::rustc-check-cfg=cfg(java)");
match std::process::Command::new("which").arg("java").status() {
Ok(s) if s.success() => {
println!("cargo::rustc-cfg=java");
},
_ => {}
}
}
may allow you to ignore your java-specific tests like this:
#[cfg(all(test, java))]
mod java_tests {
// ...
}
or if you want to show the tests as ignored in your console:
#[test]
#[cfg_attr(not(java), ignore)]
fn test_that_needs_java() {}