const BLESSED_RUSTC: &str = "rustc 1.99.0 ";
const OPTIONAL_FEATURES: bool = cfg!(any(
feature = "pg",
feature = "proptest",
feature = "migrate",
feature = "query",
feature = "sqlite",
feature = "audit",
feature = "repository",
feature = "mysql",
));
fn on_blessed_rustc(test: &str) -> bool {
if OPTIONAL_FEATURES && std::env::var_os("UI_FORCE").is_none() {
eprintln!("{test}: skipped with optional features on; snapshots are blessed with none");
return false;
}
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
let version = std::process::Command::new(rustc)
.arg("-V")
.output()
.map(|o| String::from_utf8_lossy(&o.stdout).into_owned())
.unwrap_or_default();
if version.starts_with(BLESSED_RUSTC) || std::env::var_os("UI_FORCE").is_some() {
return true;
}
eprintln!(
"{test}: skipped on `{}`; snapshots are blessed on `{BLESSED_RUSTC}` (UI_FORCE=1 runs it)",
version.trim()
);
false
}
#[test]
fn m16_query_with_string_does_not_compile() {
if !on_blessed_rustc("m16_query_with_string_does_not_compile") {
return;
}
trybuild::TestCases::new().compile_fail("tests/ui/m16_query_with_string_does_not_compile.rs");
}
#[test]
fn m16_query_raw_requires_capability() {
if !on_blessed_rustc("m16_query_raw_requires_capability") {
return;
}
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/m16_query_raw_requires_capability.rs");
t.compile_fail("tests/ui/m16_raw_capability_cannot_be_forged.rs");
}