test_global_opts: extract --version to its own test

This commit is contained in:
Ilya Grigoriev 2024-02-02 22:03:26 -08:00
parent 42c85b33c7
commit 42e6132771

View file

@ -42,6 +42,19 @@ fn test_non_utf8_arg() {
"###);
}
#[test]
fn test_version() {
let test_env = TestEnvironment::default();
let stdout = test_env.jj_cmd_success(test_env.env_root(), &["--version"]);
let sanitized = stdout.replace(|c: char| c.is_ascii_hexdigit(), "?");
assert!(
sanitized == "jj ?.??.?\n"
|| sanitized == "jj ?.??.?-????????????????????????????????????????\n",
"{sanitized}"
);
}
#[test]
fn test_no_subcommand() {
let test_env = TestEnvironment::default();
@ -65,14 +78,6 @@ fn test_no_subcommand() {
let stdout = test_env.jj_cmd_success(test_env.env_root(), &["--help"]);
insta::assert_snapshot!(stdout.lines().next().unwrap(), @"Jujutsu (An experimental VCS)");
let stdout = test_env.jj_cmd_success(test_env.env_root(), &["--version"]);
let sanitized = stdout.replace(|c: char| c.is_ascii_hexdigit(), "?");
assert!(
sanitized == "jj ?.??.?\n"
|| sanitized == "jj ?.??.?-????????????????????????????????????????\n",
"{sanitized}"
);
let stdout = test_env.jj_cmd_success(test_env.env_root(), &["-R", "repo"]);
assert_eq!(stdout, test_env.jj_cmd_success(&repo_path, &["log"]));