just playing with tangled
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

tests: port test_log_command.rs to TestWorkDir API

+305 -481
+305 -481
cli/tests/test_log_command.rs
··· 19 19 fn test_log_with_empty_revision() { 20 20 let test_env = TestEnvironment::default(); 21 21 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 22 - let repo_path = test_env.env_root().join("repo"); 22 + let work_dir = test_env.work_dir("repo"); 23 23 24 - let output = test_env.run_jj_in(&repo_path, ["log", "-r="]); 24 + let output = work_dir.run_jj(["log", "-r="]); 25 25 insta::assert_snapshot!(output, @r" 26 26 ------- stderr ------- 27 27 error: a value is required for '--revisions <REVSETS>' but none was supplied ··· 36 36 fn test_log_with_no_template() { 37 37 let test_env = TestEnvironment::default(); 38 38 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 39 - let repo_path = test_env.env_root().join("repo"); 39 + let work_dir = test_env.work_dir("repo"); 40 40 41 - let output = test_env.run_jj_in(&repo_path, ["log", "-T"]); 41 + let output = work_dir.run_jj(["log", "-T"]); 42 42 insta::assert_snapshot!(output, @r" 43 43 ------- stderr ------- 44 44 error: a value is required for '--template <TEMPLATE>' but none was supplied ··· 73 73 fn test_log_with_or_without_diff() { 74 74 let test_env = TestEnvironment::default(); 75 75 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 76 - let repo_path = test_env.env_root().join("repo"); 76 + let work_dir = test_env.work_dir("repo"); 77 77 78 - std::fs::write(repo_path.join("file1"), "foo\n").unwrap(); 79 - test_env 80 - .run_jj_in(&repo_path, ["describe", "-m", "add a file"]) 81 - .success(); 82 - test_env 83 - .run_jj_in(&repo_path, ["new", "-m", "a new commit"]) 84 - .success(); 85 - std::fs::write(repo_path.join("file1"), "foo\nbar\n").unwrap(); 78 + work_dir.write_file("file1", "foo\n"); 79 + work_dir.run_jj(["describe", "-m", "add a file"]).success(); 80 + work_dir.run_jj(["new", "-m", "a new commit"]).success(); 81 + work_dir.write_file("file1", "foo\nbar\n"); 86 82 87 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", "description"]); 83 + let output = work_dir.run_jj(["log", "-T", "description"]); 88 84 insta::assert_snapshot!(output, @r" 89 85 @ a new commit 90 86 ○ add a file ··· 92 88 [EOF] 93 89 "); 94 90 95 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", "description", "-p"]); 91 + let output = work_dir.run_jj(["log", "-T", "description", "-p"]); 96 92 insta::assert_snapshot!(output, @r" 97 93 @ a new commit 98 94 │ Modified regular file file1: ··· 105 101 [EOF] 106 102 "); 107 103 108 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", "description", "--no-graph"]); 104 + let output = work_dir.run_jj(["log", "-T", "description", "--no-graph"]); 109 105 insta::assert_snapshot!(output, @r" 110 106 a new commit 111 107 add a file ··· 113 109 "); 114 110 115 111 // `-p` for default diff output, `-s` for summary 116 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", "description", "-p", "-s"]); 112 + let output = work_dir.run_jj(["log", "-T", "description", "-p", "-s"]); 117 113 insta::assert_snapshot!(output, @r" 118 114 @ a new commit 119 115 │ M file1 ··· 129 125 "); 130 126 131 127 // `-s` for summary, `--git` for git diff (which implies `-p`) 132 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", "description", "-s", "--git"]); 128 + let output = work_dir.run_jj(["log", "-T", "description", "-s", "--git"]); 133 129 insta::assert_snapshot!(output, @r" 134 130 @ a new commit 135 131 │ M file1 ··· 154 150 "); 155 151 156 152 // `-p` for default diff output, `--stat` for diff-stat 157 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", "description", "-p", "--stat"]); 153 + let output = work_dir.run_jj(["log", "-T", "description", "-p", "--stat"]); 158 154 insta::assert_snapshot!(output, @r" 159 155 @ a new commit 160 156 │ file1 | 1 + ··· 173 169 "); 174 170 175 171 // `--stat` is short format, which should be printed first 176 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", "description", "--git", "--stat"]); 172 + let output = work_dir.run_jj(["log", "-T", "description", "--git", "--stat"]); 177 173 insta::assert_snapshot!(output, @r" 178 174 @ a new commit 179 175 │ file1 | 1 + ··· 201 197 "); 202 198 203 199 // `-p` enables default "summary" output, so `-s` is noop 204 - let output = test_env.run_jj_in( 205 - &repo_path, 206 - [ 207 - "log", 208 - "-T", 209 - "description", 210 - "-p", 211 - "-s", 212 - "--config=ui.diff.format=summary", 213 - ], 214 - ); 200 + let output = work_dir.run_jj([ 201 + "log", 202 + "-T", 203 + "description", 204 + "-p", 205 + "-s", 206 + "--config=ui.diff.format=summary", 207 + ]); 215 208 insta::assert_snapshot!(output, @r" 216 209 @ a new commit 217 210 │ M file1 ··· 222 215 "); 223 216 224 217 // `-p` enables default "color-words" diff output, so `--color-words` is noop 225 - let output = test_env.run_jj_in( 226 - &repo_path, 227 - ["log", "-T", "description", "-p", "--color-words"], 228 - ); 218 + let output = work_dir.run_jj(["log", "-T", "description", "-p", "--color-words"]); 229 219 insta::assert_snapshot!(output, @r" 230 220 @ a new commit 231 221 │ Modified regular file file1: ··· 239 229 "); 240 230 241 231 // `--git` enables git diff, so `-p` is noop 242 - let output = test_env.run_jj_in( 243 - &repo_path, 244 - ["log", "-T", "description", "--no-graph", "-p", "--git"], 245 - ); 232 + let output = work_dir.run_jj(["log", "-T", "description", "--no-graph", "-p", "--git"]); 246 233 insta::assert_snapshot!(output, @r" 247 234 a new commit 248 235 diff --git a/file1 b/file1 ··· 264 251 "); 265 252 266 253 // Cannot use both `--git` and `--color-words` 267 - let output = test_env.run_jj_in( 268 - &repo_path, 269 - [ 270 - "log", 271 - "-T", 272 - "description", 273 - "--no-graph", 274 - "-p", 275 - "--git", 276 - "--color-words", 277 - ], 278 - ); 254 + let output = work_dir.run_jj([ 255 + "log", 256 + "-T", 257 + "description", 258 + "--no-graph", 259 + "-p", 260 + "--git", 261 + "--color-words", 262 + ]); 279 263 insta::assert_snapshot!(output, @r" 280 264 ------- stderr ------- 281 265 error: the argument '--git' cannot be used with '--color-words' ··· 288 272 "); 289 273 290 274 // `-s` with or without graph 291 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", "description", "-s"]); 275 + let output = work_dir.run_jj(["log", "-T", "description", "-s"]); 292 276 insta::assert_snapshot!(output, @r" 293 277 @ a new commit 294 278 │ M file1 ··· 297 281 298 282 [EOF] 299 283 "); 300 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", "description", "--no-graph", "-s"]); 284 + let output = work_dir.run_jj(["log", "-T", "description", "--no-graph", "-s"]); 301 285 insta::assert_snapshot!(output, @r" 302 286 a new commit 303 287 M file1 ··· 307 291 "); 308 292 309 293 // `--git` implies `-p`, with or without graph 310 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", "description", "-r", "@", "--git"]); 294 + let output = work_dir.run_jj(["log", "-T", "description", "-r", "@", "--git"]); 311 295 insta::assert_snapshot!(output, @r" 312 296 @ a new commit 313 297 │ diff --git a/file1 b/file1 ··· 319 303 +bar 320 304 [EOF] 321 305 "); 322 - let output = test_env.run_jj_in( 323 - &repo_path, 324 - ["log", "-T", "description", "-r", "@", "--no-graph", "--git"], 325 - ); 306 + let output = work_dir.run_jj(["log", "-T", "description", "-r", "@", "--no-graph", "--git"]); 326 307 insta::assert_snapshot!(output, @r" 327 308 a new commit 328 309 diff --git a/file1 b/file1 ··· 336 317 "); 337 318 338 319 // `--color-words` implies `-p`, with or without graph 339 - let output = test_env.run_jj_in( 340 - &repo_path, 341 - ["log", "-T", "description", "-r", "@", "--color-words"], 342 - ); 320 + let output = work_dir.run_jj(["log", "-T", "description", "-r", "@", "--color-words"]); 343 321 insta::assert_snapshot!(output, @r" 344 322 @ a new commit 345 323 │ Modified regular file file1: ··· 347 325 2: bar 348 326 [EOF] 349 327 "); 350 - let output = test_env.run_jj_in( 351 - &repo_path, 352 - [ 353 - "log", 354 - "-T", 355 - "description", 356 - "-r", 357 - "@", 358 - "--no-graph", 359 - "--color-words", 360 - ], 361 - ); 328 + let output = work_dir.run_jj([ 329 + "log", 330 + "-T", 331 + "description", 332 + "-r", 333 + "@", 334 + "--no-graph", 335 + "--color-words", 336 + ]); 362 337 insta::assert_snapshot!(output, @r" 363 338 a new commit 364 339 Modified regular file file1: ··· 372 347 fn test_log_null_terminate_multiline_descriptions() { 373 348 let test_env = TestEnvironment::default(); 374 349 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 375 - let repo_path = test_env.env_root().join("repo"); 350 + let work_dir = test_env.work_dir("repo"); 376 351 377 - test_env 378 - .run_jj_in( 379 - &repo_path, 380 - ["commit", "-m", "commit 1 line 1", "-m", "commit 1 line 2"], 381 - ) 352 + work_dir 353 + .run_jj(["commit", "-m", "commit 1 line 1", "-m", "commit 1 line 2"]) 382 354 .success(); 383 - test_env 384 - .run_jj_in( 385 - &repo_path, 386 - ["commit", "-m", "commit 2 line 1", "-m", "commit 2 line 2"], 387 - ) 355 + work_dir 356 + .run_jj(["commit", "-m", "commit 2 line 1", "-m", "commit 2 line 2"]) 388 357 .success(); 389 - test_env 390 - .run_jj_in( 391 - &repo_path, 392 - ["describe", "-m", "commit 3 line 1", "-m", "commit 3 line 2"], 393 - ) 358 + work_dir 359 + .run_jj(["describe", "-m", "commit 3 line 1", "-m", "commit 3 line 2"]) 394 360 .success(); 395 361 396 - let output = test_env 397 - .run_jj_in( 398 - &repo_path, 399 - [ 400 - "log", 401 - "-r", 402 - "~root()", 403 - "-T", 404 - r#"description ++ "\0""#, 405 - "--no-graph", 406 - ], 407 - ) 362 + let output = work_dir 363 + .run_jj([ 364 + "log", 365 + "-r", 366 + "~root()", 367 + "-T", 368 + r#"description ++ "\0""#, 369 + "--no-graph", 370 + ]) 408 371 .success(); 409 372 insta::assert_debug_snapshot!( 410 373 output.stdout.normalized(), ··· 416 379 fn test_log_shortest_accessors() { 417 380 let test_env = TestEnvironment::default(); 418 381 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 419 - let repo_path = test_env.env_root().join("repo"); 420 - let render = |rev, template| { 421 - test_env.run_jj_in(&repo_path, ["log", "--no-graph", "-r", rev, "-T", template]) 422 - }; 382 + let work_dir = test_env.work_dir("repo"); 383 + let render = |rev, template| work_dir.run_jj(["log", "--no-graph", "-r", rev, "-T", template]); 423 384 test_env.add_config( 424 385 r#" 425 386 [template-aliases] ··· 427 388 "#, 428 389 ); 429 390 430 - std::fs::write(repo_path.join("file"), "original file\n").unwrap(); 431 - test_env 432 - .run_jj_in(&repo_path, ["describe", "-m", "initial"]) 433 - .success(); 434 - test_env 435 - .run_jj_in(&repo_path, ["bookmark", "c", "-r@", "original"]) 391 + work_dir.write_file("file", "original file\n"); 392 + work_dir.run_jj(["describe", "-m", "initial"]).success(); 393 + work_dir 394 + .run_jj(["bookmark", "c", "-r@", "original"]) 436 395 .success(); 437 396 insta::assert_snapshot!( 438 397 render("original", r#"format_id(change_id) ++ " " ++ format_id(commit_id)"#), ··· 440 399 441 400 // Create a chain of 10 commits 442 401 for i in 1..10 { 443 - test_env 444 - .run_jj_in(&repo_path, ["new", "-m", &format!("commit{i}")]) 402 + work_dir 403 + .run_jj(["new", "-m", &format!("commit{i}")]) 445 404 .success(); 446 - std::fs::write(repo_path.join("file"), format!("file {i}\n")).unwrap(); 405 + work_dir.write_file("file", format!("file {i}\n")); 447 406 } 448 407 // Create 2^3 duplicates of the chain 449 408 for _ in 0..3 { 450 - test_env 451 - .run_jj_in(&repo_path, ["duplicate", "description(commit)"]) 409 + work_dir 410 + .run_jj(["duplicate", "description(commit)"]) 452 411 .success(); 453 412 } 454 413 ··· 529 488 fn test_log_bad_short_prefixes() { 530 489 let test_env = TestEnvironment::default(); 531 490 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 532 - let repo_path = test_env.env_root().join("repo"); 491 + let work_dir = test_env.work_dir("repo"); 533 492 534 493 // Suppress warning in the commit summary template 535 494 test_env.add_config("template-aliases.'format_short_id(id)' = 'id.short(8)'"); 536 495 537 496 // Error on bad config of short prefixes 538 497 test_env.add_config(r#"revsets.short-prefixes = "!nval!d""#); 539 - let output = test_env.run_jj_in(&repo_path, ["status"]); 498 + let output = work_dir.run_jj(["status"]); 540 499 insta::assert_snapshot!(output, @r" 541 500 ------- stderr ------- 542 501 Config error: Invalid `revsets.short-prefixes` ··· 553 512 554 513 // Warn on resolution of short prefixes 555 514 test_env.add_config("revsets.short-prefixes = 'missing'"); 556 - let output = test_env.run_jj_in(&repo_path, ["log", "-Tcommit_id.shortest()"]); 515 + let output = work_dir.run_jj(["log", "-Tcommit_id.shortest()"]); 557 516 insta::assert_snapshot!(output, @r" 558 517 @ 2 559 518 ◆ 0 ··· 573 532 574 533 // Error on resolution of short prefixes 575 534 test_env.add_config("revsets.short-prefixes = 'missing'"); 576 - let output = test_env.run_jj_in(&repo_path, ["log", "-r0"]); 535 + let output = work_dir.run_jj(["log", "-r0"]); 577 536 insta::assert_snapshot!(output, @r" 578 537 ------- stderr ------- 579 538 Error: Failed to resolve short-prefixes disambiguation revset ··· 587 546 fn test_log_prefix_highlight_styled() { 588 547 let test_env = TestEnvironment::default(); 589 548 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 590 - let repo_path = test_env.env_root().join("repo"); 549 + let work_dir = test_env.work_dir("repo"); 591 550 592 551 fn prefix_format(len: Option<usize>) -> String { 593 552 format!( ··· 604 563 ) 605 564 } 606 565 607 - std::fs::write(repo_path.join("file"), "original file\n").unwrap(); 608 - test_env 609 - .run_jj_in(&repo_path, ["describe", "-m", "initial"]) 610 - .success(); 611 - test_env 612 - .run_jj_in(&repo_path, ["bookmark", "c", "-r@", "original"]) 566 + work_dir.write_file("file", "original file\n"); 567 + work_dir.run_jj(["describe", "-m", "initial"]).success(); 568 + work_dir 569 + .run_jj(["bookmark", "c", "-r@", "original"]) 613 570 .success(); 614 571 insta::assert_snapshot!( 615 - test_env.run_jj_in(&repo_path, ["log", "-r", "original", "-T", &prefix_format(Some(12))]), @r" 572 + work_dir.run_jj(["log", "-r", "original", "-T", &prefix_format(Some(12))]), @r" 616 573 @ Change qpvuntsmwlqt initial e0e22b9fae75 original 617 574 618 575 ~ ··· 621 578 622 579 // Create a chain of 10 commits 623 580 for i in 1..10 { 624 - test_env 625 - .run_jj_in(&repo_path, ["new", "-m", &format!("commit{i}")]) 581 + work_dir 582 + .run_jj(["new", "-m", &format!("commit{i}")]) 626 583 .success(); 627 - std::fs::write(repo_path.join("file"), format!("file {i}\n")).unwrap(); 584 + work_dir.write_file("file", format!("file {i}\n")); 628 585 } 629 586 // Create 2^3 duplicates of the chain 630 587 for _ in 0..3 { 631 - test_env 632 - .run_jj_in(&repo_path, ["duplicate", "description(commit)"]) 588 + work_dir 589 + .run_jj(["duplicate", "description(commit)"]) 633 590 .success(); 634 591 } 635 592 636 593 insta::assert_snapshot!( 637 - test_env.run_jj_in(&repo_path, ["log", "-r", "original", "-T", &prefix_format(Some(12))]), @r" 594 + work_dir.run_jj(["log", "-r", "original", "-T", &prefix_format(Some(12))]), @r" 638 595 ○ Change qpvuntsmwlqt initial e0e22b9fae75 original 639 596 640 597 ~ 641 598 [EOF] 642 599 "); 643 - let output = test_env.run_jj_in( 644 - &repo_path, 645 - [ 646 - "--color=always", 647 - "log", 648 - "-r", 649 - "@-----------..@", 650 - "-T", 651 - &prefix_format(Some(12)), 652 - ], 653 - ); 600 + let output = work_dir.run_jj([ 601 + "--color=always", 602 + "log", 603 + "-r", 604 + "@-----------..@", 605 + "-T", 606 + &prefix_format(Some(12)), 607 + ]); 654 608 insta::assert_snapshot!(output, @r" 655 609 @ Change wqnwkozpkust commit9 ede204633421 656 610 ○ Change kmkuslswpqwq commit8 ef3d013266cd ··· 665 619 ◆ Change zzzzzzzzzzzz 000000000000 666 620 [EOF] 667 621 "); 668 - let output = test_env.run_jj_in( 669 - &repo_path, 670 - [ 671 - "--color=always", 672 - "log", 673 - "-r", 674 - "@-----------..@", 675 - "-T", 676 - &prefix_format(Some(3)), 677 - ], 678 - ); 622 + let output = work_dir.run_jj([ 623 + "--color=always", 624 + "log", 625 + "-r", 626 + "@-----------..@", 627 + "-T", 628 + &prefix_format(Some(3)), 629 + ]); 679 630 insta::assert_snapshot!(output, @r" 680 631 @ Change wqn commit9 ede 681 632 ○ Change kmk commit8 ef3 ··· 690 641 ◆ Change zzz 000 691 642 [EOF] 692 643 "); 693 - let output = test_env.run_jj_in( 694 - &repo_path, 695 - [ 696 - "--color=always", 697 - "log", 698 - "-r", 699 - "@-----------..@", 700 - "-T", 701 - &prefix_format(None), 702 - ], 703 - ); 644 + let output = work_dir.run_jj([ 645 + "--color=always", 646 + "log", 647 + "-r", 648 + "@-----------..@", 649 + "-T", 650 + &prefix_format(None), 651 + ]); 704 652 insta::assert_snapshot!(output, @r" 705 653 @ Change wq commit9 ed 706 654 ○ Change km commit8 ef3 ··· 721 669 fn test_log_prefix_highlight_counts_hidden_commits() { 722 670 let test_env = TestEnvironment::default(); 723 671 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 724 - let repo_path = test_env.env_root().join("repo"); 672 + let work_dir = test_env.work_dir("repo"); 725 673 test_env.add_config( 726 674 r#" 727 675 [revsets] ··· 741 689 ) 742 690 "#; 743 691 744 - std::fs::write(repo_path.join("file"), "original file\n").unwrap(); 745 - test_env 746 - .run_jj_in(&repo_path, ["describe", "-m", "initial"]) 747 - .success(); 748 - test_env 749 - .run_jj_in(&repo_path, ["bookmark", "c", "-r@", "original"]) 692 + work_dir.write_file("file", "original file\n"); 693 + work_dir.run_jj(["describe", "-m", "initial"]).success(); 694 + work_dir 695 + .run_jj(["bookmark", "c", "-r@", "original"]) 750 696 .success(); 751 - insta::assert_snapshot!( 752 - test_env.run_jj_in(&repo_path, ["log", "-r", "all()", "-T", prefix_format]), @r" 697 + insta::assert_snapshot!(work_dir.run_jj(["log", "-r", "all()", "-T", prefix_format]), @r" 753 698 @ Change q[pvuntsmwlqt] initial e0[e22b9fae75] original 754 699 ◆ Change z[zzzzzzzzzzz] 0[00000000000] 755 700 [EOF] 756 701 "); 757 702 758 703 // Create 2^7 hidden commits 759 - test_env 760 - .run_jj_in(&repo_path, ["new", "root()", "-m", "extra"]) 761 - .success(); 704 + work_dir.run_jj(["new", "root()", "-m", "extra"]).success(); 762 705 for _ in 0..7 { 763 - test_env 764 - .run_jj_in(&repo_path, ["duplicate", "description(extra)"]) 706 + work_dir 707 + .run_jj(["duplicate", "description(extra)"]) 765 708 .success(); 766 709 } 767 - test_env 768 - .run_jj_in(&repo_path, ["abandon", "description(extra)"]) 769 - .success(); 710 + work_dir.run_jj(["abandon", "description(extra)"]).success(); 770 711 771 712 // The unique prefixes became longer. 772 - insta::assert_snapshot!( 773 - test_env.run_jj_in(&repo_path, ["log", "-T", prefix_format]), @r" 713 + insta::assert_snapshot!(work_dir.run_jj(["log", "-T", prefix_format]), @r" 774 714 @ Change wq[nwkozpkust] 44[4c3c5066d3] 775 715 │ ○ Change qpv[untsmwlqt] initial e0e[22b9fae75] original 776 716 ├─╯ 777 717 ◆ Change zzz[zzzzzzzzz] 00[0000000000] 778 718 [EOF] 779 719 "); 780 - insta::assert_snapshot!( 781 - test_env.run_jj_in(&repo_path, ["log", "-r", "4", "-T", prefix_format]), @r" 720 + insta::assert_snapshot!(work_dir.run_jj(["log", "-r", "4", "-T", prefix_format]), @r" 782 721 ------- stderr ------- 783 722 Error: Commit ID prefix `4` is ambiguous 784 723 [EOF] 785 724 [exit status: 1] 786 725 "); 787 - insta::assert_snapshot!( 788 - test_env.run_jj_in(&repo_path, ["log", "-r", "44", "-T", prefix_format]), @r" 726 + insta::assert_snapshot!(work_dir.run_jj(["log", "-r", "44", "-T", prefix_format]), @r" 789 727 @ Change wq[nwkozpkust] 44[4c3c5066d3] 790 728 791 729 ~ ··· 797 735 fn test_log_short_shortest_length_parameter() { 798 736 let test_env = TestEnvironment::default(); 799 737 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 800 - let repo_path = test_env.env_root().join("repo"); 801 - let render = |template| test_env.run_jj_in(&repo_path, ["log", "-T", template]); 738 + let work_dir = test_env.work_dir("repo"); 739 + let render = |template| work_dir.run_jj(["log", "-T", template]); 802 740 803 741 insta::assert_snapshot!( 804 742 render(r#"commit_id.short(0) ++ "|" ++ commit_id.shortest(0)"#), @r" ··· 830 768 fn test_log_author_format() { 831 769 let test_env = TestEnvironment::default(); 832 770 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 833 - let repo_path = test_env.env_root().join("repo"); 771 + let work_dir = test_env.work_dir("repo"); 834 772 835 - insta::assert_snapshot!( 836 - test_env.run_jj_in(&repo_path, ["log", "--revisions=@"]), @r" 773 + insta::assert_snapshot!(work_dir.run_jj(["log", "--revisions=@"]), @r" 837 774 @ qpvuntsm test.user@example.com 2001-02-03 08:05:07 230dd059 838 775 │ (empty) (no description set) 839 776 ~ ··· 841 778 "); 842 779 843 780 let decl = "template-aliases.'format_short_signature(signature)'"; 844 - insta::assert_snapshot!( 845 - test_env.run_jj_in( 846 - &repo_path, 847 - [ 848 - "--config", 849 - &format!("{decl}='signature.email().local()'"), 850 - "log", 851 - "--revisions=@", 852 - ], 853 - ), @r" 781 + insta::assert_snapshot!(work_dir.run_jj([ 782 + "--config", 783 + &format!("{decl}='signature.email().local()'"), 784 + "log", 785 + "--revisions=@", 786 + ]), @r" 854 787 @ qpvuntsm test.user 2001-02-03 08:05:07 230dd059 855 788 │ (empty) (no description set) 856 789 ~ ··· 862 795 fn test_log_divergence() { 863 796 let test_env = TestEnvironment::default(); 864 797 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 865 - let repo_path = test_env.env_root().join("repo"); 798 + let work_dir = test_env.work_dir("repo"); 866 799 let template = r#"description.first_line() ++ if(divergent, " !divergence!")"#; 867 800 868 - std::fs::write(repo_path.join("file"), "foo\n").unwrap(); 869 - test_env 870 - .run_jj_in(&repo_path, ["describe", "-m", "description 1"]) 801 + work_dir.write_file("file", "foo\n"); 802 + work_dir 803 + .run_jj(["describe", "-m", "description 1"]) 871 804 .success(); 872 805 // No divergence 873 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", template]); 806 + let output = work_dir.run_jj(["log", "-T", template]); 874 807 insta::assert_snapshot!(output, @r" 875 808 @ description 1 876 809 ··· 878 811 "); 879 812 880 813 // Create divergence 881 - test_env 882 - .run_jj_in( 883 - &repo_path, 884 - ["describe", "-m", "description 2", "--at-operation", "@-"], 885 - ) 814 + work_dir 815 + .run_jj(["describe", "-m", "description 2", "--at-operation", "@-"]) 886 816 .success(); 887 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", template]); 817 + let output = work_dir.run_jj(["log", "-T", template]); 888 818 insta::assert_snapshot!(output, @r" 889 819 @ description 1 !divergence! 890 820 │ ○ description 2 !divergence! ··· 901 831 fn test_log_reversed() { 902 832 let test_env = TestEnvironment::default(); 903 833 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 904 - let repo_path = test_env.env_root().join("repo"); 834 + let work_dir = test_env.work_dir("repo"); 905 835 906 - test_env 907 - .run_jj_in(&repo_path, ["describe", "-m", "first"]) 908 - .success(); 909 - test_env 910 - .run_jj_in(&repo_path, ["new", "-m", "second"]) 911 - .success(); 836 + work_dir.run_jj(["describe", "-m", "first"]).success(); 837 + work_dir.run_jj(["new", "-m", "second"]).success(); 912 838 913 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", "description", "--reversed"]); 839 + let output = work_dir.run_jj(["log", "-T", "description", "--reversed"]); 914 840 insta::assert_snapshot!(output, @r" 915 841 916 842 ○ first ··· 918 844 [EOF] 919 845 "); 920 846 921 - let output = test_env.run_jj_in( 922 - &repo_path, 923 - ["log", "-T", "description", "--reversed", "--no-graph"], 924 - ); 847 + let output = work_dir.run_jj(["log", "-T", "description", "--reversed", "--no-graph"]); 925 848 insta::assert_snapshot!(output, @r" 926 849 first 927 850 second ··· 933 856 fn test_log_filtered_by_path() { 934 857 let test_env = TestEnvironment::default(); 935 858 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 936 - let repo_path = test_env.env_root().join("repo"); 859 + let work_dir = test_env.work_dir("repo"); 937 860 938 - std::fs::write(repo_path.join("file1"), "foo\n").unwrap(); 939 - test_env 940 - .run_jj_in(&repo_path, ["describe", "-m", "first"]) 941 - .success(); 942 - test_env 943 - .run_jj_in(&repo_path, ["new", "-m", "second"]) 944 - .success(); 945 - std::fs::write(repo_path.join("file1"), "foo\nbar\n").unwrap(); 946 - std::fs::write(repo_path.join("file2"), "baz\n").unwrap(); 861 + work_dir.write_file("file1", "foo\n"); 862 + work_dir.run_jj(["describe", "-m", "first"]).success(); 863 + work_dir.run_jj(["new", "-m", "second"]).success(); 864 + work_dir.write_file("file1", "foo\nbar\n"); 865 + work_dir.write_file("file2", "baz\n"); 947 866 948 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", "description", "file1"]); 867 + let output = work_dir.run_jj(["log", "-T", "description", "file1"]); 949 868 insta::assert_snapshot!(output, @r" 950 869 @ second 951 870 ○ first ··· 954 873 [EOF] 955 874 "); 956 875 957 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", "description", "file2"]); 876 + let output = work_dir.run_jj(["log", "-T", "description", "file2"]); 958 877 insta::assert_snapshot!(output, @r" 959 878 @ second 960 879 ··· 962 881 [EOF] 963 882 "); 964 883 965 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", "description", "-s", "file1"]); 884 + let output = work_dir.run_jj(["log", "-T", "description", "-s", "file1"]); 966 885 insta::assert_snapshot!(output, @r" 967 886 @ second 968 887 │ M file1 ··· 972 891 [EOF] 973 892 "); 974 893 975 - let output = test_env.run_jj_in( 976 - &repo_path, 977 - ["log", "-T", "description", "-s", "file2", "--no-graph"], 978 - ); 894 + let output = work_dir.run_jj(["log", "-T", "description", "-s", "file2", "--no-graph"]); 979 895 insta::assert_snapshot!(output, @r" 980 896 second 981 897 A file2 ··· 983 899 "); 984 900 985 901 // empty revisions are filtered out by "all()" fileset. 986 - let output = test_env.run_jj_in(&repo_path, ["log", "-Tdescription", "-s", "all()"]); 902 + let output = work_dir.run_jj(["log", "-Tdescription", "-s", "all()"]); 987 903 insta::assert_snapshot!(output, @r" 988 904 @ second 989 905 │ M file1 ··· 1000 916 [ 1001 917 "log", 1002 918 "-R", 1003 - repo_path.to_str().unwrap(), 919 + work_dir.root().to_str().unwrap(), 1004 920 "-Tdescription", 1005 921 "-s", 1006 922 "root:file1", ··· 1016 932 "); 1017 933 1018 934 // files() revset doesn't filter the diff. 1019 - let output = test_env.run_jj_in( 1020 - &repo_path, 1021 - [ 1022 - "log", 1023 - "-T", 1024 - "description", 1025 - "-s", 1026 - "-rfiles(file2)", 1027 - "--no-graph", 1028 - ], 1029 - ); 935 + let output = work_dir.run_jj([ 936 + "log", 937 + "-T", 938 + "description", 939 + "-s", 940 + "-rfiles(file2)", 941 + "--no-graph", 942 + ]); 1030 943 insta::assert_snapshot!(output, @r" 1031 944 second 1032 945 M file1 ··· 1039 952 fn test_log_limit() { 1040 953 let test_env = TestEnvironment::default(); 1041 954 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 1042 - let repo_path = test_env.env_root().join("repo"); 955 + let work_dir = test_env.work_dir("repo"); 1043 956 1044 - test_env 1045 - .run_jj_in(&repo_path, ["describe", "-m", "a"]) 957 + work_dir.run_jj(["describe", "-m", "a"]).success(); 958 + work_dir.write_file("a", ""); 959 + work_dir.run_jj(["new", "-m", "b"]).success(); 960 + work_dir.write_file("b", ""); 961 + work_dir 962 + .run_jj(["new", "-m", "c", "description(a)"]) 1046 963 .success(); 1047 - std::fs::write(repo_path.join("a"), "").unwrap(); 1048 - test_env.run_jj_in(&repo_path, ["new", "-m", "b"]).success(); 1049 - std::fs::write(repo_path.join("b"), "").unwrap(); 1050 - test_env 1051 - .run_jj_in(&repo_path, ["new", "-m", "c", "description(a)"]) 1052 - .success(); 1053 - std::fs::write(repo_path.join("c"), "").unwrap(); 1054 - test_env 1055 - .run_jj_in( 1056 - &repo_path, 1057 - ["new", "-m", "d", "description(c)", "description(b)"], 1058 - ) 964 + work_dir.write_file("c", ""); 965 + work_dir 966 + .run_jj(["new", "-m", "d", "description(c)", "description(b)"]) 1059 967 .success(); 1060 968 1061 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", "description", "--limit=3"]); 969 + let output = work_dir.run_jj(["log", "-T", "description", "--limit=3"]); 1062 970 insta::assert_snapshot!(output, @r" 1063 971 @ d 1064 972 ├─╮ ··· 1069 977 "); 1070 978 1071 979 // Applied on sorted DAG 1072 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", "description", "--limit=2"]); 980 + let output = work_dir.run_jj(["log", "-T", "description", "--limit=2"]); 1073 981 insta::assert_snapshot!(output, @r" 1074 982 @ d 1075 983 ├─╮ ··· 1077 985 [EOF] 1078 986 "); 1079 987 1080 - let output = test_env.run_jj_in( 1081 - &repo_path, 1082 - ["log", "-T", "description", "--limit=2", "--no-graph"], 1083 - ); 988 + let output = work_dir.run_jj(["log", "-T", "description", "--limit=2", "--no-graph"]); 1084 989 insta::assert_snapshot!(output, @r" 1085 990 d 1086 991 c ··· 1089 994 1090 995 // Applied on reversed DAG: Because the node "a" is omitted, "b" and "c" are 1091 996 // rendered as roots. 1092 - let output = test_env.run_jj_in( 1093 - &repo_path, 1094 - ["log", "-T", "description", "--limit=3", "--reversed"], 1095 - ); 997 + let output = work_dir.run_jj(["log", "-T", "description", "--limit=3", "--reversed"]); 1096 998 insta::assert_snapshot!(output, @r" 1097 999 ○ c 1098 1000 │ ○ b ··· 1100 1002 @ d 1101 1003 [EOF] 1102 1004 "); 1103 - let output = test_env.run_jj_in( 1104 - &repo_path, 1105 - [ 1106 - "log", 1107 - "-T", 1108 - "description", 1109 - "--limit=3", 1110 - "--reversed", 1111 - "--no-graph", 1112 - ], 1113 - ); 1005 + let output = work_dir.run_jj([ 1006 + "log", 1007 + "-T", 1008 + "description", 1009 + "--limit=3", 1010 + "--reversed", 1011 + "--no-graph", 1012 + ]); 1114 1013 insta::assert_snapshot!(output, @r" 1115 1014 b 1116 1015 c ··· 1119 1018 "); 1120 1019 1121 1020 // Applied on filtered commits 1122 - let output = test_env.run_jj_in( 1123 - &repo_path, 1124 - ["log", "-T", "description", "--limit=1", "b", "c"], 1125 - ); 1021 + let output = work_dir.run_jj(["log", "-T", "description", "--limit=1", "b", "c"]); 1126 1022 insta::assert_snapshot!(output, @r" 1127 1023 ○ c 1128 1024 ··· 1135 1031 fn test_log_warn_path_might_be_revset() { 1136 1032 let test_env = TestEnvironment::default(); 1137 1033 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 1138 - let repo_path = test_env.env_root().join("repo"); 1034 + let work_dir = test_env.work_dir("repo"); 1139 1035 1140 - std::fs::write(repo_path.join("file1"), "foo\n").unwrap(); 1036 + work_dir.write_file("file1", "foo\n"); 1141 1037 1142 1038 // Don't warn if the file actually exists. 1143 - let output = test_env.run_jj_in(&repo_path, ["log", "file1", "-T", "description"]); 1039 + let output = work_dir.run_jj(["log", "file1", "-T", "description"]); 1144 1040 insta::assert_snapshot!(output, @r" 1145 1041 @ 1146 1042 ··· 1149 1045 "); 1150 1046 1151 1047 // Warn for `jj log .` specifically, for former Mercurial users. 1152 - let output = test_env.run_jj_in(&repo_path, ["log", ".", "-T", "description"]); 1048 + let output = work_dir.run_jj(["log", ".", "-T", "description"]); 1153 1049 insta::assert_snapshot!(output, @r#" 1154 1050 @ 1155 1051 ··· 1161 1057 "#); 1162 1058 1163 1059 // ...but checking `jj log .` makes sense in a subdirectory. 1164 - let subdir = repo_path.join("dir"); 1165 - std::fs::create_dir_all(&subdir).unwrap(); 1166 - let output = test_env.run_jj_in(&subdir, ["log", "."]); 1060 + let sub_dir = work_dir.create_dir_all("dir"); 1061 + let output = sub_dir.run_jj(["log", "."]); 1167 1062 insta::assert_snapshot!(output, @""); 1168 1063 1169 1064 // Warn for `jj log @` instead of `jj log -r @`. 1170 - let output = test_env.run_jj_in(&repo_path, ["log", "@", "-T", "description"]); 1065 + let output = work_dir.run_jj(["log", "@", "-T", "description"]); 1171 1066 insta::assert_snapshot!(output, @r#" 1172 1067 ------- stderr ------- 1173 1068 Warning: The argument "@" is being interpreted as a fileset expression. To specify a revset, pass -r "@" instead. ··· 1175 1070 "#); 1176 1071 1177 1072 // Warn when there's no path with the provided name. 1178 - let output = test_env.run_jj_in(&repo_path, ["log", "file2", "-T", "description"]); 1073 + let output = work_dir.run_jj(["log", "file2", "-T", "description"]); 1179 1074 insta::assert_snapshot!(output, @r#" 1180 1075 ------- stderr ------- 1181 1076 Warning: The argument "file2" is being interpreted as a fileset expression. To specify a revset, pass -r "file2" instead. ··· 1183 1078 "#); 1184 1079 1185 1080 // If an explicit revision is provided, then suppress the warning. 1186 - let output = test_env.run_jj_in(&repo_path, ["log", "@", "-r", "@", "-T", "description"]); 1081 + let output = work_dir.run_jj(["log", "@", "-r", "@", "-T", "description"]); 1187 1082 insta::assert_snapshot!(output, @""); 1188 1083 } 1189 1084 ··· 1191 1086 fn test_default_revset() { 1192 1087 let test_env = TestEnvironment::default(); 1193 1088 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 1194 - let repo_path = test_env.env_root().join("repo"); 1089 + let work_dir = test_env.work_dir("repo"); 1195 1090 1196 - std::fs::write(repo_path.join("file1"), "foo\n").unwrap(); 1197 - test_env 1198 - .run_jj_in(&repo_path, ["describe", "-m", "add a file"]) 1199 - .success(); 1091 + work_dir.write_file("file1", "foo\n"); 1092 + work_dir.run_jj(["describe", "-m", "add a file"]).success(); 1200 1093 1201 1094 // Set configuration to only show the root commit. 1202 1095 test_env.add_config(r#"revsets.log = "root()""#); 1203 1096 1204 1097 // Log should only contain one line (for the root commit), and not show the 1205 1098 // commit created above. 1206 - insta::assert_snapshot!( 1207 - test_env.run_jj_in(&repo_path, ["log", "-T", "commit_id"]), @r" 1099 + insta::assert_snapshot!(work_dir.run_jj(["log", "-T", "commit_id"]), @r" 1208 1100 ◆ 0000000000000000000000000000000000000000 1209 1101 [EOF] 1210 1102 "); 1211 1103 1212 1104 // The default revset is not used if a path is specified 1213 - insta::assert_snapshot!( 1214 - test_env.run_jj_in(&repo_path, ["log", "file1", "-T", "description"]), @r" 1105 + insta::assert_snapshot!(work_dir.run_jj(["log", "file1", "-T", "description"]), @r" 1215 1106 @ add a file 1216 1107 1217 1108 ~ ··· 1223 1114 fn test_default_revset_per_repo() { 1224 1115 let test_env = TestEnvironment::default(); 1225 1116 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 1226 - let repo_path = test_env.env_root().join("repo"); 1117 + let work_dir = test_env.work_dir("repo"); 1227 1118 1228 - std::fs::write(repo_path.join("file1"), "foo\n").unwrap(); 1229 - test_env 1230 - .run_jj_in(&repo_path, ["describe", "-m", "add a file"]) 1231 - .success(); 1119 + work_dir.write_file("file1", "foo\n"); 1120 + work_dir.run_jj(["describe", "-m", "add a file"]).success(); 1232 1121 1233 1122 // Set configuration to only show the root commit. 1234 - std::fs::write( 1235 - repo_path.join(".jj/repo/config.toml"), 1236 - r#"revsets.log = "root()""#, 1237 - ) 1238 - .unwrap(); 1123 + work_dir.write_file(".jj/repo/config.toml", r#"revsets.log = "root()""#); 1239 1124 1240 1125 // Log should only contain one line (for the root commit), and not show the 1241 1126 // commit created above. 1242 - insta::assert_snapshot!( 1243 - test_env.run_jj_in(&repo_path, ["log", "-T", "commit_id"]), @r" 1127 + insta::assert_snapshot!(work_dir.run_jj(["log", "-T", "commit_id"]), @r" 1244 1128 ◆ 0000000000000000000000000000000000000000 1245 1129 [EOF] 1246 1130 "); ··· 1250 1134 fn test_multiple_revsets() { 1251 1135 let test_env = TestEnvironment::default(); 1252 1136 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 1253 - let repo_path = test_env.env_root().join("repo"); 1137 + let work_dir = test_env.work_dir("repo"); 1254 1138 for name in ["foo", "bar", "baz"] { 1255 - test_env 1256 - .run_jj_in(&repo_path, ["new", "-m", name]) 1257 - .success(); 1258 - test_env 1259 - .run_jj_in(&repo_path, ["bookmark", "create", "-r@", name]) 1139 + work_dir.run_jj(["new", "-m", name]).success(); 1140 + work_dir 1141 + .run_jj(["bookmark", "create", "-r@", name]) 1260 1142 .success(); 1261 1143 } 1262 1144 ··· 1264 1146 test_env.add_config(r#"revsets.log = "root()""#); 1265 1147 1266 1148 insta::assert_snapshot!( 1267 - test_env.run_jj_in(&repo_path, ["log", "-T", "bookmarks", "-rfoo"]), @r" 1149 + work_dir.run_jj(["log", "-T", "bookmarks", "-rfoo"]), @r" 1268 1150 ○ foo 1269 1151 1270 1152 ~ 1271 1153 [EOF] 1272 1154 "); 1273 1155 insta::assert_snapshot!( 1274 - test_env.run_jj_in(&repo_path, ["log", "-T", "bookmarks", "-rfoo", "-rbar", "-rbaz"]), @r" 1156 + work_dir.run_jj(["log", "-T", "bookmarks", "-rfoo", "-rbar", "-rbaz"]), @r" 1275 1157 @ baz 1276 1158 ○ bar 1277 1159 ○ foo ··· 1280 1162 [EOF] 1281 1163 "); 1282 1164 insta::assert_snapshot!( 1283 - test_env.run_jj_in(&repo_path, ["log", "-T", "bookmarks", "-rfoo", "-rfoo"]), @r" 1165 + work_dir.run_jj(["log", "-T", "bookmarks", "-rfoo", "-rfoo"]), @r" 1284 1166 ○ foo 1285 1167 1286 1168 ~ ··· 1293 1175 // Test that color codes from a multi-line template don't span the graph lines. 1294 1176 let test_env = TestEnvironment::default(); 1295 1177 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 1296 - let repo_path = test_env.env_root().join("repo"); 1178 + let work_dir = test_env.work_dir("repo"); 1297 1179 1298 - test_env 1299 - .run_jj_in( 1300 - &repo_path, 1301 - ["describe", "-m", "first line\nsecond line\nthird line"], 1302 - ) 1303 - .success(); 1304 - test_env 1305 - .run_jj_in(&repo_path, ["new", "-m", "single line"]) 1180 + work_dir 1181 + .run_jj(["describe", "-m", "first line\nsecond line\nthird line"]) 1306 1182 .success(); 1183 + work_dir.run_jj(["new", "-m", "single line"]).success(); 1307 1184 1308 1185 test_env.add_config( 1309 1186 r#"[colors] ··· 1314 1191 1315 1192 // First test without color for comparison 1316 1193 let template = r#"label(if(current_working_copy, "working_copy"), description)"#; 1317 - let output = test_env.run_jj_in(&repo_path, ["log", "-T", template]); 1194 + let output = work_dir.run_jj(["log", "-T", template]); 1318 1195 insta::assert_snapshot!(output, @r" 1319 1196 @ single line 1320 1197 ○ first line ··· 1323 1200 1324 1201 [EOF] 1325 1202 "); 1326 - let output = test_env.run_jj_in(&repo_path, ["--color=always", "log", "-T", template]); 1203 + let output = work_dir.run_jj(["--color=always", "log", "-T", template]); 1327 1204 insta::assert_snapshot!(output, @r" 1328 1205 @ single line 1329 1206 ○ first line ··· 1332 1209 ◆ 1333 1210 [EOF] 1334 1211 "); 1335 - let output = test_env.run_jj_in(&repo_path, ["--color=debug", "log", "-T", template]); 1212 + let output = work_dir.run_jj(["--color=debug", "log", "-T", template]); 1336 1213 insta::assert_snapshot!(output, @r" 1337 1214 <<node working_copy::@>> <<log working_copy description::single line>> 1338 1215 <<node::○>> <<log description::first line>> ··· 1348 1225 // Test that different graph styles are available. 1349 1226 let test_env = TestEnvironment::default(); 1350 1227 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 1351 - let repo_path = test_env.env_root().join("repo"); 1228 + let work_dir = test_env.work_dir("repo"); 1352 1229 1353 - test_env 1354 - .run_jj_in(&repo_path, ["commit", "-m", "initial"]) 1230 + work_dir.run_jj(["commit", "-m", "initial"]).success(); 1231 + work_dir 1232 + .run_jj(["commit", "-m", "main bookmark 1"]) 1355 1233 .success(); 1356 - test_env 1357 - .run_jj_in(&repo_path, ["commit", "-m", "main bookmark 1"]) 1234 + work_dir 1235 + .run_jj(["describe", "-m", "main bookmark 2"]) 1358 1236 .success(); 1359 - test_env 1360 - .run_jj_in(&repo_path, ["describe", "-m", "main bookmark 2"]) 1237 + work_dir 1238 + .run_jj(["new", "-m", "side bookmark\nwith\nlong\ndescription"]) 1361 1239 .success(); 1362 - test_env 1363 - .run_jj_in( 1364 - &repo_path, 1365 - ["new", "-m", "side bookmark\nwith\nlong\ndescription"], 1366 - ) 1367 - .success(); 1368 - test_env 1369 - .run_jj_in( 1370 - &repo_path, 1371 - [ 1372 - "new", 1373 - "-m", 1374 - "merge", 1375 - r#"description("main bookmark 1")"#, 1376 - "@", 1377 - ], 1378 - ) 1240 + work_dir 1241 + .run_jj([ 1242 + "new", 1243 + "-m", 1244 + "merge", 1245 + r#"description("main bookmark 1")"#, 1246 + "@", 1247 + ]) 1379 1248 .success(); 1380 1249 1381 1250 // Default (curved) style 1382 - let output = test_env.run_jj_in(&repo_path, ["log", "-T=description"]); 1251 + let output = work_dir.run_jj(["log", "-T=description"]); 1383 1252 insta::assert_snapshot!(output, @r" 1384 1253 @ merge 1385 1254 ├─╮ ··· 1397 1266 1398 1267 // ASCII style 1399 1268 test_env.add_config(r#"ui.graph.style = "ascii""#); 1400 - let output = test_env.run_jj_in(&repo_path, ["log", "-T=description"]); 1269 + let output = work_dir.run_jj(["log", "-T=description"]); 1401 1270 insta::assert_snapshot!(output, @r" 1402 1271 @ merge 1403 1272 |\ ··· 1415 1284 1416 1285 // Large ASCII style 1417 1286 test_env.add_config(r#"ui.graph.style = "ascii-large""#); 1418 - let output = test_env.run_jj_in(&repo_path, ["log", "-T=description"]); 1287 + let output = work_dir.run_jj(["log", "-T=description"]); 1419 1288 insta::assert_snapshot!(output, @r" 1420 1289 @ merge 1421 1290 |\ ··· 1435 1304 1436 1305 // Curved style 1437 1306 test_env.add_config(r#"ui.graph.style = "curved""#); 1438 - let output = test_env.run_jj_in(&repo_path, ["log", "-T=description"]); 1307 + let output = work_dir.run_jj(["log", "-T=description"]); 1439 1308 insta::assert_snapshot!(output, @r" 1440 1309 @ merge 1441 1310 ├─╮ ··· 1453 1322 1454 1323 // Square style 1455 1324 test_env.add_config(r#"ui.graph.style = "square""#); 1456 - let output = test_env.run_jj_in(&repo_path, ["log", "-T=description"]); 1325 + let output = work_dir.run_jj(["log", "-T=description"]); 1457 1326 insta::assert_snapshot!(output, @r" 1458 1327 @ merge 1459 1328 ├─┐ ··· 1470 1339 "); 1471 1340 1472 1341 // Invalid style name 1473 - let output = test_env.run_jj_in(&repo_path, ["log", "--config=ui.graph.style=unknown"]); 1342 + let output = work_dir.run_jj(["log", "--config=ui.graph.style=unknown"]); 1474 1343 insta::assert_snapshot!(output, @r" 1475 1344 ------- stderr ------- 1476 1345 Config error: Invalid type or value for ui.graph.style ··· 1486 1355 fn test_log_word_wrap() { 1487 1356 let test_env = TestEnvironment::default(); 1488 1357 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 1489 - let repo_path = test_env.env_root().join("repo"); 1358 + let work_dir = test_env.work_dir("repo"); 1490 1359 let render = |args: &[&str], columns: u32, word_wrap: bool| { 1491 1360 let word_wrap = to_toml_value(word_wrap); 1492 - test_env.run_jj_with(|cmd| { 1493 - cmd.current_dir(&repo_path) 1494 - .args(args) 1361 + work_dir.run_jj_with(|cmd| { 1362 + cmd.args(args) 1495 1363 .arg(format!("--config=ui.log-word-wrap={word_wrap}")) 1496 1364 .env("COLUMNS", columns.to_string()) 1497 1365 }) 1498 1366 }; 1499 1367 1500 - test_env 1501 - .run_jj_in(&repo_path, ["commit", "-m", "main bookmark 1"]) 1368 + work_dir 1369 + .run_jj(["commit", "-m", "main bookmark 1"]) 1502 1370 .success(); 1503 - test_env 1504 - .run_jj_in(&repo_path, ["describe", "-m", "main bookmark 2"]) 1371 + work_dir 1372 + .run_jj(["describe", "-m", "main bookmark 2"]) 1505 1373 .success(); 1506 - test_env 1507 - .run_jj_in(&repo_path, ["new", "-m", "side"]) 1508 - .success(); 1509 - test_env 1510 - .run_jj_in(&repo_path, ["new", "-m", "merge", "@--", "@"]) 1374 + work_dir.run_jj(["new", "-m", "side"]).success(); 1375 + work_dir 1376 + .run_jj(["new", "-m", "merge", "@--", "@"]) 1511 1377 .success(); 1512 1378 1513 1379 // ui.log-word-wrap option applies to both graph/no-graph outputs ··· 1594 1460 fn test_log_diff_stat_width() { 1595 1461 let test_env = TestEnvironment::default(); 1596 1462 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 1597 - let repo_path = test_env.env_root().join("repo"); 1463 + let work_dir = test_env.work_dir("repo"); 1598 1464 let render = |args: &[&str], columns: u32| { 1599 - test_env.run_jj_with(|cmd| { 1600 - cmd.current_dir(&repo_path) 1601 - .args(args) 1602 - .env("COLUMNS", columns.to_string()) 1603 - }) 1465 + work_dir.run_jj_with(|cmd| cmd.args(args).env("COLUMNS", columns.to_string())) 1604 1466 }; 1605 1467 1606 - std::fs::write(repo_path.join("file1"), "foo\n".repeat(100)).unwrap(); 1607 - test_env.run_jj_in(&repo_path, ["new", "root()"]).success(); 1608 - std::fs::write(repo_path.join("file2"), "foo\n".repeat(100)).unwrap(); 1468 + work_dir.write_file("file1", "foo\n".repeat(100)); 1469 + work_dir.run_jj(["new", "root()"]).success(); 1470 + work_dir.write_file("file2", "foo\n".repeat(100)); 1609 1471 1610 1472 insta::assert_snapshot!(render(&["log", "--stat", "--no-graph"], 30), @r" 1611 1473 rlvkpnrz test.user@example.com 2001-02-03 08:05:09 287520bf ··· 1642 1504 // Test that elided commits are shown as synthetic nodes. 1643 1505 let test_env = TestEnvironment::default(); 1644 1506 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 1645 - let repo_path = test_env.env_root().join("repo"); 1507 + let work_dir = test_env.work_dir("repo"); 1646 1508 1647 - test_env 1648 - .run_jj_in(&repo_path, ["describe", "-m", "initial"]) 1649 - .success(); 1650 - test_env 1651 - .run_jj_in(&repo_path, ["new", "-m", "main bookmark 1"]) 1652 - .success(); 1653 - test_env 1654 - .run_jj_in(&repo_path, ["new", "-m", "main bookmark 2"]) 1655 - .success(); 1656 - test_env 1657 - .run_jj_in(&repo_path, ["new", "@--", "-m", "side bookmark 1"]) 1658 - .success(); 1659 - test_env 1660 - .run_jj_in(&repo_path, ["new", "-m", "side bookmark 2"]) 1509 + work_dir.run_jj(["describe", "-m", "initial"]).success(); 1510 + work_dir.run_jj(["new", "-m", "main bookmark 1"]).success(); 1511 + work_dir.run_jj(["new", "-m", "main bookmark 2"]).success(); 1512 + work_dir 1513 + .run_jj(["new", "@--", "-m", "side bookmark 1"]) 1661 1514 .success(); 1662 - test_env 1663 - .run_jj_in( 1664 - &repo_path, 1665 - [ 1666 - "new", 1667 - "-m", 1668 - "merge", 1669 - r#"description("main bookmark 2")"#, 1670 - "@", 1671 - ], 1672 - ) 1515 + work_dir.run_jj(["new", "-m", "side bookmark 2"]).success(); 1516 + work_dir 1517 + .run_jj([ 1518 + "new", 1519 + "-m", 1520 + "merge", 1521 + r#"description("main bookmark 2")"#, 1522 + "@", 1523 + ]) 1673 1524 .success(); 1674 1525 1675 - let get_log = |revs: &str| { 1676 - test_env.run_jj_in( 1677 - &repo_path, 1678 - ["log", "-T", r#"description ++ "\n""#, "-r", revs], 1679 - ) 1680 - }; 1526 + let get_log = |revs: &str| work_dir.run_jj(["log", "-T", r#"description ++ "\n""#, "-r", revs]); 1681 1527 1682 1528 // Test the setup 1683 1529 insta::assert_snapshot!(get_log("::"), @r" ··· 1764 1610 // Test that elided commits are shown as synthetic nodes. 1765 1611 let test_env = TestEnvironment::default(); 1766 1612 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 1767 - let repo_path = test_env.env_root().join("repo"); 1613 + let work_dir = test_env.work_dir("repo"); 1768 1614 1769 - test_env 1770 - .run_jj_in(&repo_path, ["describe", "-m", "initial"]) 1771 - .success(); 1772 - test_env 1773 - .run_jj_in(&repo_path, ["new", "-m", "main bookmark 1"]) 1774 - .success(); 1775 - test_env 1776 - .run_jj_in(&repo_path, ["new", "-m", "main bookmark 2"]) 1777 - .success(); 1778 - test_env 1779 - .run_jj_in(&repo_path, ["new", "@--", "-m", "side bookmark 1"]) 1780 - .success(); 1781 - test_env 1782 - .run_jj_in(&repo_path, ["new", "-m", "side bookmark 2"]) 1615 + work_dir.run_jj(["describe", "-m", "initial"]).success(); 1616 + work_dir.run_jj(["new", "-m", "main bookmark 1"]).success(); 1617 + work_dir.run_jj(["new", "-m", "main bookmark 2"]).success(); 1618 + work_dir 1619 + .run_jj(["new", "@--", "-m", "side bookmark 1"]) 1783 1620 .success(); 1784 - test_env 1785 - .run_jj_in( 1786 - &repo_path, 1787 - [ 1788 - "new", 1789 - "-m", 1790 - "merge", 1791 - r#"description("main bookmark 2")"#, 1792 - "@", 1793 - ], 1794 - ) 1621 + work_dir.run_jj(["new", "-m", "side bookmark 2"]).success(); 1622 + work_dir 1623 + .run_jj([ 1624 + "new", 1625 + "-m", 1626 + "merge", 1627 + r#"description("main bookmark 2")"#, 1628 + "@", 1629 + ]) 1795 1630 .success(); 1796 1631 1797 - let get_log = |revs: &str| { 1798 - test_env.run_jj_in( 1799 - &repo_path, 1800 - ["log", "-T", r#"description ++ "\n""#, "-r", revs], 1801 - ) 1802 - }; 1632 + let get_log = |revs: &str| work_dir.run_jj(["log", "-T", r#"description ++ "\n""#, "-r", revs]); 1803 1633 1804 1634 // Simple test with showing default and elided nodes. 1805 1635 test_env.add_config( ··· 1853 1683 fn test_log_full_description_template() { 1854 1684 let test_env = TestEnvironment::default(); 1855 1685 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 1856 - let repo_path = test_env.env_root().join("repo"); 1686 + let work_dir = test_env.work_dir("repo"); 1857 1687 1858 - test_env 1859 - .run_jj_in( 1860 - &repo_path, 1861 - [ 1862 - "describe", 1863 - "-m", 1864 - "this is commit with a multiline description\n\n<full description>", 1865 - ], 1866 - ) 1688 + work_dir 1689 + .run_jj([ 1690 + "describe", 1691 + "-m", 1692 + "this is commit with a multiline description\n\n<full description>", 1693 + ]) 1867 1694 .success(); 1868 1695 1869 - let output = test_env.run_jj_in( 1870 - &repo_path, 1871 - ["log", "-T", "builtin_log_compact_full_description"], 1872 - ); 1696 + let output = work_dir.run_jj(["log", "-T", "builtin_log_compact_full_description"]); 1873 1697 insta::assert_snapshot!(output, @r" 1874 1698 @ qpvuntsm test.user@example.com 2001-02-03 08:05:08 1c504ec6 1875 1699 │ (empty) this is commit with a multiline description