forked from mirrors/jj
tests: use dotted notation in TOML when it saves lines
This commit is contained in:
parent
d771c12637
commit
e1d49cc67f
8 changed files with 16 additions and 76 deletions
|
@ -169,15 +169,7 @@ impl TestEnvironment {
|
|||
// Simplified TOML escaping, hoping that there are no '"' or control characters
|
||||
// in it
|
||||
let escaped_diff_editor_path = diff_editor_path.to_str().unwrap().replace('\\', r"\\");
|
||||
self.add_config(
|
||||
format!(
|
||||
r###"
|
||||
[ui]
|
||||
diff-editor = "{escaped_diff_editor_path}"
|
||||
"###
|
||||
)
|
||||
.as_bytes(),
|
||||
);
|
||||
self.add_config(format!(r#"ui.diff-editor = "{escaped_diff_editor_path}""#).as_bytes());
|
||||
let edit_script = self.env_root().join("diff_edit_script");
|
||||
std::fs::write(&edit_script, "").unwrap();
|
||||
self.add_env_var("DIFF_EDIT_SCRIPT", edit_script.to_str().unwrap());
|
||||
|
|
|
@ -24,11 +24,7 @@ fn test_alias_basic() {
|
|||
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
|
||||
test_env.add_config(
|
||||
br#"[alias]
|
||||
b = ["log", "-r", "@", "-T", "branches"]
|
||||
"#,
|
||||
);
|
||||
test_env.add_config(br#"alias.b = ["log", "-r", "@", "-T", "branches"]"#);
|
||||
test_env.jj_cmd_success(&repo_path, &["branch", "create", "my-branch"]);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["b"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
|
@ -59,11 +55,7 @@ fn test_alias_calls_unknown_command() {
|
|||
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
|
||||
test_env.add_config(
|
||||
br#"[alias]
|
||||
foo = ["nonexistent"]
|
||||
"#,
|
||||
);
|
||||
test_env.add_config(br#"alias.foo = ["nonexistent"]"#);
|
||||
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["foo"]);
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
error: The subcommand 'nonexistent' wasn't recognized
|
||||
|
@ -80,11 +72,7 @@ fn test_alias_calls_command_with_invalid_option() {
|
|||
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
|
||||
test_env.add_config(
|
||||
br#"[alias]
|
||||
foo = ["log", "--nonexistent"]
|
||||
"#,
|
||||
);
|
||||
test_env.add_config(br#"alias.foo = ["log", "--nonexistent"]"#);
|
||||
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["foo"]);
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
error: Found argument '--nonexistent' which wasn't expected, or isn't valid in this context
|
||||
|
@ -102,11 +90,7 @@ fn test_alias_calls_help() {
|
|||
let test_env = TestEnvironment::default();
|
||||
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
test_env.add_config(
|
||||
br#"[alias]
|
||||
h = ["--help"]
|
||||
"#,
|
||||
);
|
||||
test_env.add_config(br#"alias.h = ["--help"]"#);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["h"]);
|
||||
insta::assert_snapshot!(stdout.lines().take(5).join("\n"), @r###"
|
||||
Jujutsu (An experimental VCS)
|
||||
|
@ -123,11 +107,7 @@ fn test_alias_cannot_override_builtin() {
|
|||
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
|
||||
test_env.add_config(
|
||||
br#"[alias]
|
||||
log = ["rebase"]
|
||||
"#,
|
||||
);
|
||||
test_env.add_config(br#"alias.log = ["rebase"]"#);
|
||||
// Alias should be ignored
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "root"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
|
@ -166,11 +146,7 @@ fn test_alias_global_args_before_and_after() {
|
|||
let test_env = TestEnvironment::default();
|
||||
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
test_env.add_config(
|
||||
br#"[alias]
|
||||
l = ["log", "-T", "commit_id", "-r", "all()"]
|
||||
"#,
|
||||
);
|
||||
test_env.add_config(br#"alias.l = ["log", "-T", "commit_id", "-r", "all()"]"#);
|
||||
// Test the setup
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["l"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
|
@ -205,10 +181,8 @@ fn test_alias_global_args_in_definition() {
|
|||
let test_env = TestEnvironment::default();
|
||||
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
test_env.add_config(
|
||||
br#"[alias]
|
||||
l = ["log", "-T", "commit_id", "--at-op", "@-", "-r", "all()", "--color=always"]
|
||||
"#,
|
||||
test_env.add_config(
|
||||
br#"alias.l = ["log", "-T", "commit_id", "--at-op", "@-", "-r", "all()", "--color=always"]"#,
|
||||
);
|
||||
|
||||
// The global argument in the alias is respected
|
||||
|
|
|
@ -125,10 +125,7 @@ fn test_describe() {
|
|||
assert!(get_stderr_string(&assert).contains("bad-editor-from-visual-env"));
|
||||
|
||||
// `ui.editor` config overrides `$VISUAL`
|
||||
test_env.add_config(
|
||||
br#"[ui]
|
||||
editor = "bad-editor-from-config""#,
|
||||
);
|
||||
test_env.add_config(br#"ui.editor = "bad-editor-from-config""#);
|
||||
let assert = test_env
|
||||
.jj_cmd(&repo_path, &["describe"])
|
||||
.env("VISUAL", "bad-editor-from-visual-env")
|
||||
|
|
|
@ -187,10 +187,7 @@ fn test_color_config() {
|
|||
"###);
|
||||
|
||||
// Test that color is used if it's requested in the config file
|
||||
test_env.add_config(
|
||||
br#"[ui]
|
||||
color="always""#,
|
||||
);
|
||||
test_env.add_config(br#"ui.color="always""#);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-T", "commit_id"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
@ [1m[38;5;12m230dd059e1b059aefc0da06a2e5a7dbf22362f22[0m
|
||||
|
|
|
@ -196,11 +196,7 @@ fn test_init_local_disallowed() {
|
|||
#[test]
|
||||
fn test_init_local() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config(
|
||||
br#"[ui]
|
||||
allow-init-native = true
|
||||
"#,
|
||||
);
|
||||
test_env.add_config(br#"ui.allow-init-native = true"#);
|
||||
let stdout = test_env.jj_cmd_success(test_env.env_root(), &["init", "repo"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
Initialized repo in "repo"
|
||||
|
|
|
@ -603,11 +603,7 @@ fn test_default_revset() {
|
|||
test_env.jj_cmd_success(&repo_path, &["describe", "-m", "add a file"]);
|
||||
|
||||
// Set configuration to only show the root commit.
|
||||
test_env.add_config(
|
||||
br#"[ui]
|
||||
default-revset = "root"
|
||||
"#,
|
||||
);
|
||||
test_env.add_config(br#"ui.default-revset = "root""#);
|
||||
|
||||
// Log should only contain one line (for the root commit), and not show the
|
||||
// commit created above.
|
||||
|
|
|
@ -41,11 +41,7 @@ fn test_show_relative_timestamps() {
|
|||
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
|
||||
test_env.add_config(
|
||||
br#"[ui]
|
||||
relative-timestamps = true
|
||||
"#,
|
||||
);
|
||||
test_env.add_config(br#"ui.relative-timestamps = true"#);
|
||||
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["show"]);
|
||||
let timestamp_re = Regex::new(r"\([0-9]+ years ago\)").unwrap();
|
||||
|
|
|
@ -21,11 +21,7 @@ pub mod common;
|
|||
#[test]
|
||||
fn test_untrack() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config(
|
||||
br#"[ui]
|
||||
allow-init-native = true
|
||||
"#,
|
||||
);
|
||||
test_env.add_config(br#"ui.allow-init-native = true"#);
|
||||
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
|
||||
|
@ -105,11 +101,7 @@ fn test_untrack() {
|
|||
#[test]
|
||||
fn test_untrack_sparse() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config(
|
||||
br#"[ui]
|
||||
allow-init-native = true
|
||||
"#,
|
||||
);
|
||||
test_env.add_config(br#"ui.allow-init-native = true"#);
|
||||
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
|
||||
|
|
Loading…
Reference in a new issue