build: mold linker gate and nextest config-warning gate
e1a4fab037163c9c8c9973b09ac32fe67b0f0efd
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
- Parent 1: 3cc45b62452b
There are many coding harnesses - but this one is fast
e1a4fab037163c9c8c9973b09ac32fe67b0f0efd
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
+69 / −2 text lines
+4 / −0 text lines
+65 / −2 text lines
ensure_mold, cargo(&["nextest", "run", "--workspace", "--all-features"]) nextest_run(&["--workspace", "--all-features"])}/// nextest has no warning-deny flag, so config-drift warnings are turned into/// a gate failure by scanning its stderr.fn nextest_run(args: &[&str]) -> ExitCode { let mut child = match Command::new("cargo") .arg("nextest") .arg("run") .args(args) .stdout(std::process::Stdio::inherit()) .stderr(std::process::Stdio::piped()) .spawn() { Ok(child) => child, Err(error) => return fail(&format!("failed to run cargo nextest: {error}\n")), }; let mut warned = false; if let Some(stderr) = child.stderr.take() { let reader = std::io::BufReader::new(stderr); for line in reader.lines() { let Ok(line) = line else { break; }; if line.contains("warning: in config file") { warned = true; } let _ = std::io::stderr().write_all(format!("{line}\n").as_bytes()); } } match child.wait() { Ok(status) if status.success() && !warned => ExitCode::SUCCESS, Ok(status) if status.success() => fail("nextest produced config file warnings\n"), Ok(status) => fail(&format!( "cargo exited with exit status: {}\n", status.code().unwrap_or_default() )), Err(error) => fail(&format!("failed to wait for cargo nextest: {error}\n")), }/// mold is a build prerequisite on linux-gnu `x86_64`; xtask verifies it, the/// system package manager installs it.fn ensure_mold() -> ExitCode { if cfg!(all( target_arch = "x86_64", target_os = "linux", target_env = "gnu" )) { match Command::new("mold") .arg("--version") .stdout(std::process::Stdio::null()) .stderr(std::process::Stdio::null()) .status() { Ok(status) if status.success() => ExitCode::SUCCESS, _ => fail( "mold linker missing: install it with the system package manager (e.g. pacman -S mold)\n", ), } } else { ExitCode::SUCCESS }}