Translate HTTP and network tests

This commit is contained in:
2026-08-08 18:30:51 +02:00
parent de6e611ef0
commit 6d4d9adaf4
13 changed files with 1793 additions and 1051 deletions

30
tests/compat/build.rs Normal file
View File

@@ -0,0 +1,30 @@
use std::path::Path;
const KEYS: [&str; 3] = ["GRID_USER", "GRID_PASSWORD", "GRID_LOGIN_URL"];
fn dotenv_has(path: &Path, key: &str) -> bool {
std::fs::read_to_string(path).is_ok_and(|contents| {
contents.lines().any(|line| {
let line = line.trim().strip_prefix("export ").unwrap_or(line.trim());
line.split_once('=').is_some_and(|(name, value)| {
name.trim() == key && !value.trim().trim_matches(['\'', '"']).is_empty()
})
})
})
}
fn main() {
let dotenv = Path::new(&std::env::var("CARGO_MANIFEST_DIR").expect("manifest directory"))
.join("../..")
.join(".env");
println!("cargo:rustc-check-cfg=cfg(live_grid_credentials)");
println!("cargo:rerun-if-changed={}", dotenv.display());
for key in KEYS {
println!("cargo:rerun-if-env-changed={key}");
}
if KEYS.iter().all(|key| {
std::env::var(key).is_ok_and(|value| !value.trim().is_empty()) || dotenv_has(&dotenv, key)
}) {
println!("cargo:rustc-cfg=live_grid_credentials");
}
}