mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-30 11:31:13 +00:00
tests: snapshot a few more colored outputs
This commit is contained in:
parent
53619359e2
commit
f7f85383bc
@ -1596,6 +1596,22 @@ fn test_bookmark_list() {
|
||||
[EOF]
|
||||
");
|
||||
|
||||
let output = local_dir.run_jj(["bookmark", "list", "--all-remotes", "--color=always"]);
|
||||
insta::assert_snapshot!(output, @r"
|
||||
[38;5;5mlocal-only[39m: [1m[38;5;5mw[0m[38;5;8mqnwkozp[39m [1m[38;5;4m03[0m[38;5;8m53dd35[39m [38;5;2m(empty)[39m local-only
|
||||
[38;5;5mremote-delete[39m (deleted)
|
||||
[38;5;5m@origin[39m: [1m[38;5;5mv[0m[38;5;8mruxwmqv[39m [1m[38;5;4mb[0m[38;5;8m32031cf[39m [38;5;2m(empty)[39m remote-delete
|
||||
[38;5;5mremote-sync[39m: [1m[38;5;5mr[0m[38;5;8mlvkpnrz[39m [1m[38;5;4m7[0m[38;5;8ma07dbee[39m [38;5;2m(empty)[39m remote-sync
|
||||
[38;5;5m@origin[39m: [1m[38;5;5mr[0m[38;5;8mlvkpnrz[39m [1m[38;5;4m7[0m[38;5;8ma07dbee[39m [38;5;2m(empty)[39m remote-sync
|
||||
[38;5;5mremote-unsync[39m: [1m[38;5;5mw[0m[38;5;8mqnwkozp[39m [1m[38;5;4m03[0m[38;5;8m53dd35[39m [38;5;2m(empty)[39m local-only
|
||||
[38;5;5m@origin[39m (ahead by 1 commits, behind by 1 commits): [1m[38;5;5mzs[0m[38;5;8muskuln[39m [1m[38;5;4m5[0m[38;5;8m53203ba[39m [38;5;2m(empty)[39m remote-unsync
|
||||
[38;5;5mremote-untrack@origin[39m: [1m[38;5;5mro[0m[38;5;8myxmykx[39m [1m[38;5;4m1[0m[38;5;8m49bc756[39m [38;5;2m(empty)[39m remote-untrack
|
||||
[EOF]
|
||||
------- stderr -------
|
||||
[1m[38;5;6mHint: [0m[39mBookmarks marked as deleted can be *deleted permanently* on the remote by running `jj git push --deleted`. Use `jj bookmark forget` if you don't want that.[39m
|
||||
[EOF]
|
||||
");
|
||||
|
||||
let template = r#"
|
||||
concat(
|
||||
"[" ++ name ++ if(remote, "@" ++ remote) ++ "]\n",
|
||||
|
@ -305,6 +305,61 @@ fn test_git_import_move_export_with_default_undo() {
|
||||
");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_git_import_export_stats_color() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.run_jj_in(".", ["git", "init", "repo"]).success();
|
||||
let work_dir = test_env.work_dir("repo");
|
||||
let git_repo = git::open(work_dir.root().join(".jj/repo/store/git"));
|
||||
|
||||
work_dir.run_jj(["bookmark", "set", "-r@", "foo"]).success();
|
||||
work_dir
|
||||
.run_jj(["bookmark", "set", "-r@", "'un:exportable'"])
|
||||
.success();
|
||||
work_dir.run_jj(["new", "--no-edit", "root()"]).success();
|
||||
let other_commit_id = work_dir
|
||||
.run_jj(&["log", "-Tcommit_id", "--no-graph", "-rvisible_heads() ~ @"])
|
||||
.success()
|
||||
.stdout
|
||||
.into_raw();
|
||||
|
||||
let output = work_dir
|
||||
.run_jj(["git", "export", "--color=always"])
|
||||
.success();
|
||||
insta::assert_snapshot!(output, @r#"
|
||||
------- stderr -------
|
||||
[1m[38;5;3mWarning: [39mFailed to export some bookmarks:[0m
|
||||
[38;5;5m"un:exportable"@git[39m: Failed to set: A reference must be a valid tag name as well: A ref must not contain invalid bytes or ascii control characters: ":"
|
||||
[1m[38;5;6mHint: [0m[39mGit doesn't allow a branch name that looks like a parent directory of[39m
|
||||
[39manother (e.g. `foo` and `foo/bar`). Try to rename the bookmarks that failed to[39m
|
||||
[39mexport or their "parent" bookmarks.[39m
|
||||
[EOF]
|
||||
"#);
|
||||
|
||||
let other_commit_id = gix::ObjectId::from_hex(other_commit_id.as_bytes()).unwrap();
|
||||
for name in ["refs/heads/foo", "refs/heads/bar", "refs/tags/baz"] {
|
||||
git_repo
|
||||
.reference(
|
||||
name,
|
||||
other_commit_id,
|
||||
gix::refs::transaction::PreviousValue::Any,
|
||||
"",
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let output = work_dir
|
||||
.run_jj(["git", "import", "--color=always"])
|
||||
.success();
|
||||
insta::assert_snapshot!(output, @r"
|
||||
------- stderr -------
|
||||
bookmark: [38;5;5mbar@git[39m [new] tracked
|
||||
bookmark: [38;5;5mfoo@git[39m [updated] tracked
|
||||
tag: [38;5;5mbaz@git[39m [new]
|
||||
[EOF]
|
||||
");
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
fn get_bookmark_output(work_dir: &TestWorkDir) -> CommandOutput {
|
||||
work_dir.run_jj(["bookmark", "list", "--all-remotes"])
|
||||
|
@ -318,6 +318,20 @@ fn test_git_push_forward_unexpectedly_moved() {
|
||||
[EOF]
|
||||
[exit status: 1]
|
||||
");
|
||||
|
||||
// The ref name should be colorized
|
||||
let output = work_dir.run_jj(["git", "push", "--color=always"]);
|
||||
insta::assert_snapshot!(output, @r"
|
||||
------- stderr -------
|
||||
Changes to push to origin:
|
||||
Move forward bookmark bookmark1 from 9b2e76de3920 to 624f94a35f00
|
||||
[1m[38;5;1mError: [39mFailed to push some bookmarks[0m
|
||||
[1m[38;5;6mHint: [0m[39mThe following references unexpectedly moved on the remote:[39m
|
||||
[39m [38;5;2mrefs/heads/bookmark1[39m (reason: stale info)[39m
|
||||
[1m[38;5;6mHint: [0m[39mTry fetching from the remote, then make the bookmark point to where you want it to be, and push again.[39m
|
||||
[EOF]
|
||||
[exit status: 1]
|
||||
");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -370,6 +384,20 @@ fn test_git_push_sideways_unexpectedly_moved() {
|
||||
[EOF]
|
||||
[exit status: 1]
|
||||
");
|
||||
|
||||
// The ref name should be colorized
|
||||
let output = work_dir.run_jj(["git", "push", "--color=always"]);
|
||||
insta::assert_snapshot!(output, @r"
|
||||
------- stderr -------
|
||||
Changes to push to origin:
|
||||
Move sideways bookmark bookmark1 from 9b2e76de3920 to 827b8a385853
|
||||
[1m[38;5;1mError: [39mFailed to push some bookmarks[0m
|
||||
[1m[38;5;6mHint: [0m[39mThe following references unexpectedly moved on the remote:[39m
|
||||
[39m [38;5;2mrefs/heads/bookmark1[39m (reason: stale info)[39m
|
||||
[1m[38;5;6mHint: [0m[39mTry fetching from the remote, then make the bookmark point to where you want it to be, and push again.[39m
|
||||
[EOF]
|
||||
[exit status: 1]
|
||||
");
|
||||
}
|
||||
|
||||
// This tests whether the push checks that the remote bookmarks are in expected
|
||||
|
@ -105,6 +105,32 @@ fn test_op_log() {
|
||||
[EOF]
|
||||
");
|
||||
|
||||
let output = work_dir.run_jj(["op", "log", "--op-diff", "--color=always"]);
|
||||
insta::assert_snapshot!(output, @r"
|
||||
[1m[38;5;2m@[0m [1m[38;5;12m09a518cf68a5[39m [38;5;3mtest-username@host.example.com[39m [38;5;14m2001-02-03 04:05:08.000 +07:00[39m - [38;5;14m2001-02-03 04:05:08.000 +07:00[39m[0m
|
||||
│ [1mdescribe commit e8849ae12c709f2321908879bc724fdb2ab8a781[0m
|
||||
│ [1m[38;5;5margs: jj describe -m 'description 0'[39m[0m
|
||||
│
|
||||
│ Changed commits:
|
||||
│ ○ [38;5;2m+[39m [1m[38;5;5mq[0m[38;5;8mpvuntsm[39m [1m[38;5;4m3[0m[38;5;8mae22e7f[39m [38;5;2m(empty)[39m description 0
|
||||
│ [38;5;1m-[39m [1m[39mq[0m[38;5;8mpvuntsm[39m hidden [1m[38;5;4me[0m[38;5;8m8849ae1[39m [38;5;2m(empty)[39m [38;5;2m(no description set)[39m
|
||||
│
|
||||
│ Changed working copy [38;5;2mdefault@[39m:
|
||||
│ [38;5;2m+[39m [1m[38;5;5mq[0m[38;5;8mpvuntsm[39m [1m[38;5;4m3[0m[38;5;8mae22e7f[39m [38;5;2m(empty)[39m description 0
|
||||
│ [38;5;1m-[39m [1m[39mq[0m[38;5;8mpvuntsm[39m hidden [1m[38;5;4me[0m[38;5;8m8849ae1[39m [38;5;2m(empty)[39m [38;5;2m(no description set)[39m
|
||||
○ [38;5;4m2affa7025254[39m [38;5;3mtest-username@host.example.com[39m [38;5;6m2001-02-03 04:05:07.000 +07:00[39m - [38;5;6m2001-02-03 04:05:07.000 +07:00[39m
|
||||
│ add workspace 'default'
|
||||
│
|
||||
│ Changed commits:
|
||||
│ ○ [38;5;2m+[39m [1m[38;5;5mq[0m[38;5;8mpvuntsm[39m [1m[38;5;4me[0m[38;5;8m8849ae1[39m [38;5;2m(empty)[39m [38;5;2m(no description set)[39m
|
||||
│
|
||||
│ Changed working copy [38;5;2mdefault@[39m:
|
||||
│ [38;5;2m+[39m [1m[38;5;5mq[0m[38;5;8mpvuntsm[39m [1m[38;5;4me[0m[38;5;8m8849ae1[39m [38;5;2m(empty)[39m [38;5;2m(no description set)[39m
|
||||
│ [38;5;1m-[39m (absent)
|
||||
○ [38;5;4m000000000000[39m [38;5;2mroot()[39m
|
||||
[EOF]
|
||||
");
|
||||
|
||||
work_dir
|
||||
.run_jj(["describe", "-m", "description 1"])
|
||||
.success();
|
||||
@ -120,7 +146,7 @@ fn test_op_log() {
|
||||
insta::assert_snapshot!(work_dir.run_jj(["log", "--at-op", "@-"]), @r#"
|
||||
------- stderr -------
|
||||
Error: The "@" expression resolved to more than one operation
|
||||
Hint: Try specifying one of the operations by ID: ad1b3bd7fb02, 9e17e47612d5
|
||||
Hint: Try specifying one of the operations by ID: ca1431ae8aca, f392182c5ff4
|
||||
[EOF]
|
||||
[exit status: 1]
|
||||
"#);
|
||||
|
Loading…
x
Reference in New Issue
Block a user