mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-14 11:44:27 +00:00
Set up tests using `taplo check --schema` to validate the default configs. Install taplo in GitHub CI and in the Nix flake. Fixes #5670.
72 lines
1.7 KiB
Rust
72 lines
1.7 KiB
Rust
use std::process::Command;
|
|
use std::process::Stdio;
|
|
|
|
fn taplo_check_config(file: &str) {
|
|
if Command::new("taplo")
|
|
.arg("--version")
|
|
.stdout(Stdio::null())
|
|
.status()
|
|
.is_err()
|
|
{
|
|
eprintln!("Skipping test because taplo is not installed on the system");
|
|
return;
|
|
}
|
|
|
|
// Taplo requires an absolute URL to the schema :/
|
|
let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
|
let taplo_res = Command::new("taplo")
|
|
.args([
|
|
"check",
|
|
"--schema",
|
|
&format!("file://{}/src/config-schema.json", root.display()),
|
|
file,
|
|
])
|
|
.stdout(Stdio::piped())
|
|
.stderr(Stdio::piped())
|
|
.spawn()
|
|
.unwrap()
|
|
.wait_with_output()
|
|
.unwrap();
|
|
|
|
if !taplo_res.status.success() {
|
|
eprintln!("Failed to validate {file}:");
|
|
eprintln!("{}", String::from_utf8_lossy(&taplo_res.stderr));
|
|
panic!("Validation failed");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_taplo_check_colors_config() {
|
|
taplo_check_config("src/config/colors.toml");
|
|
}
|
|
|
|
#[test]
|
|
fn test_taplo_check_merge_tools_config() {
|
|
taplo_check_config("src/config/merge_tools.toml");
|
|
}
|
|
|
|
#[test]
|
|
fn test_taplo_check_misc_config() {
|
|
taplo_check_config("src/config/misc.toml");
|
|
}
|
|
|
|
#[test]
|
|
fn test_taplo_check_revsets_config() {
|
|
taplo_check_config("src/config/revsets.toml");
|
|
}
|
|
|
|
#[test]
|
|
fn test_taplo_check_templates_config() {
|
|
taplo_check_config("src/config/templates.toml");
|
|
}
|
|
|
|
#[test]
|
|
fn test_taplo_check_unix_config() {
|
|
taplo_check_config("src/config/unix.toml");
|
|
}
|
|
|
|
#[test]
|
|
fn test_taplo_check_windows_config() {
|
|
taplo_check_config("src/config/windows.toml");
|
|
}
|