just playing with tangled
0
fork

Configure Feed

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

tests: port test_interdiff_command.rs to TestWorkDir API

+57 -72
+57 -72
cli/tests/test_interdiff_command.rs
··· 18 18 fn test_interdiff_basic() { 19 19 let test_env = TestEnvironment::default(); 20 20 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 21 - let repo_path = test_env.env_root().join("repo"); 21 + let work_dir = test_env.work_dir("repo"); 22 22 23 - std::fs::write(repo_path.join("file1"), "foo\n").unwrap(); 24 - test_env.run_jj_in(&repo_path, ["new"]).success(); 25 - std::fs::write(repo_path.join("file2"), "foo\n").unwrap(); 26 - test_env 27 - .run_jj_in(&repo_path, ["bookmark", "create", "-r@", "left"]) 23 + work_dir.write_file("file1", "foo\n"); 24 + work_dir.run_jj(["new"]).success(); 25 + work_dir.write_file("file2", "foo\n"); 26 + work_dir 27 + .run_jj(["bookmark", "create", "-r@", "left"]) 28 28 .success(); 29 29 30 - test_env.run_jj_in(&repo_path, ["new", "root()"]).success(); 31 - std::fs::write(repo_path.join("file3"), "foo\n").unwrap(); 32 - test_env.run_jj_in(&repo_path, ["new"]).success(); 33 - std::fs::write(repo_path.join("file2"), "foo\nbar\n").unwrap(); 34 - test_env 35 - .run_jj_in(&repo_path, ["bookmark", "create", "-r@", "right"]) 30 + work_dir.run_jj(["new", "root()"]).success(); 31 + work_dir.write_file("file3", "foo\n"); 32 + work_dir.run_jj(["new"]).success(); 33 + work_dir.write_file("file2", "foo\nbar\n"); 34 + work_dir 35 + .run_jj(["bookmark", "create", "-r@", "right"]) 36 36 .success(); 37 37 38 38 // implicit --to 39 - let output = test_env.run_jj_in(&repo_path, ["interdiff", "--from", "left"]); 39 + let output = work_dir.run_jj(["interdiff", "--from", "left"]); 40 40 insta::assert_snapshot!(output, @r" 41 41 Modified regular file file2: 42 42 1 1: foo ··· 45 45 "); 46 46 47 47 // explicit --to 48 - test_env.run_jj_in(&repo_path, ["new", "@-"]).success(); 49 - let output = test_env.run_jj_in(&repo_path, ["interdiff", "--from", "left", "--to", "right"]); 48 + work_dir.run_jj(["new", "@-"]).success(); 49 + let output = work_dir.run_jj(["interdiff", "--from", "left", "--to", "right"]); 50 50 insta::assert_snapshot!(output, @r" 51 51 Modified regular file file2: 52 52 1 1: foo 53 53 2: bar 54 54 [EOF] 55 55 "); 56 - test_env.run_jj_in(&repo_path, ["undo"]).success(); 56 + work_dir.run_jj(["undo"]).success(); 57 57 58 58 // formats specifiers 59 - let output = test_env.run_jj_in( 60 - &repo_path, 61 - ["interdiff", "--from", "left", "--to", "right", "-s"], 62 - ); 59 + let output = work_dir.run_jj(["interdiff", "--from", "left", "--to", "right", "-s"]); 63 60 insta::assert_snapshot!(output, @r" 64 61 M file2 65 62 [EOF] 66 63 "); 67 64 68 - let output = test_env.run_jj_in( 69 - &repo_path, 70 - ["interdiff", "--from", "left", "--to", "right", "--git"], 71 - ); 65 + let output = work_dir.run_jj(["interdiff", "--from", "left", "--to", "right", "--git"]); 72 66 insta::assert_snapshot!(output, @r" 73 67 diff --git a/file2 b/file2 74 68 index 257cc5642c..3bd1f0e297 100644 ··· 85 79 fn test_interdiff_paths() { 86 80 let test_env = TestEnvironment::default(); 87 81 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 88 - let repo_path = test_env.env_root().join("repo"); 82 + let work_dir = test_env.work_dir("repo"); 89 83 90 - std::fs::write(repo_path.join("file1"), "foo\n").unwrap(); 91 - std::fs::write(repo_path.join("file2"), "foo\n").unwrap(); 92 - test_env.run_jj_in(&repo_path, ["new"]).success(); 93 - std::fs::write(repo_path.join("file1"), "bar\n").unwrap(); 94 - std::fs::write(repo_path.join("file2"), "bar\n").unwrap(); 95 - test_env 96 - .run_jj_in(&repo_path, ["bookmark", "create", "-r@", "left"]) 84 + work_dir.write_file("file1", "foo\n"); 85 + work_dir.write_file("file2", "foo\n"); 86 + work_dir.run_jj(["new"]).success(); 87 + work_dir.write_file("file1", "bar\n"); 88 + work_dir.write_file("file2", "bar\n"); 89 + work_dir 90 + .run_jj(["bookmark", "create", "-r@", "left"]) 97 91 .success(); 98 92 99 - test_env.run_jj_in(&repo_path, ["new", "root()"]).success(); 100 - std::fs::write(repo_path.join("file1"), "foo\n").unwrap(); 101 - std::fs::write(repo_path.join("file2"), "foo\n").unwrap(); 102 - test_env.run_jj_in(&repo_path, ["new"]).success(); 103 - std::fs::write(repo_path.join("file1"), "baz\n").unwrap(); 104 - std::fs::write(repo_path.join("file2"), "baz\n").unwrap(); 105 - test_env 106 - .run_jj_in(&repo_path, ["bookmark", "create", "-r@", "right"]) 93 + work_dir.run_jj(["new", "root()"]).success(); 94 + work_dir.write_file("file1", "foo\n"); 95 + work_dir.write_file("file2", "foo\n"); 96 + work_dir.run_jj(["new"]).success(); 97 + work_dir.write_file("file1", "baz\n"); 98 + work_dir.write_file("file2", "baz\n"); 99 + work_dir 100 + .run_jj(["bookmark", "create", "-r@", "right"]) 107 101 .success(); 108 102 109 - let output = test_env.run_jj_in( 110 - &repo_path, 111 - ["interdiff", "--from", "left", "--to", "right", "file1"], 112 - ); 103 + let output = work_dir.run_jj(["interdiff", "--from", "left", "--to", "right", "file1"]); 113 104 insta::assert_snapshot!(output, @r" 114 105 Modified regular file file1: 115 106 1 1: barbaz 116 107 [EOF] 117 108 "); 118 109 119 - let output = test_env.run_jj_in( 120 - &repo_path, 121 - [ 122 - "interdiff", 123 - "--from", 124 - "left", 125 - "--to", 126 - "right", 127 - "file1", 128 - "file2", 129 - ], 130 - ); 110 + let output = work_dir.run_jj([ 111 + "interdiff", 112 + "--from", 113 + "left", 114 + "--to", 115 + "right", 116 + "file1", 117 + "file2", 118 + ]); 131 119 insta::assert_snapshot!(output, @r" 132 120 Modified regular file file1: 133 121 1 1: barbaz ··· 141 129 fn test_interdiff_conflicting() { 142 130 let test_env = TestEnvironment::default(); 143 131 test_env.run_jj_in(".", ["git", "init", "repo"]).success(); 144 - let repo_path = test_env.env_root().join("repo"); 132 + let work_dir = test_env.work_dir("repo"); 145 133 146 - std::fs::write(repo_path.join("file"), "foo\n").unwrap(); 147 - test_env.run_jj_in(&repo_path, ["new"]).success(); 148 - std::fs::write(repo_path.join("file"), "bar\n").unwrap(); 149 - test_env 150 - .run_jj_in(&repo_path, ["bookmark", "create", "-r@", "left"]) 134 + work_dir.write_file("file", "foo\n"); 135 + work_dir.run_jj(["new"]).success(); 136 + work_dir.write_file("file", "bar\n"); 137 + work_dir 138 + .run_jj(["bookmark", "create", "-r@", "left"]) 151 139 .success(); 152 140 153 - test_env.run_jj_in(&repo_path, ["new", "root()"]).success(); 154 - std::fs::write(repo_path.join("file"), "abc\n").unwrap(); 155 - test_env.run_jj_in(&repo_path, ["new"]).success(); 156 - std::fs::write(repo_path.join("file"), "def\n").unwrap(); 157 - test_env 158 - .run_jj_in(&repo_path, ["bookmark", "create", "-r@", "right"]) 141 + work_dir.run_jj(["new", "root()"]).success(); 142 + work_dir.write_file("file", "abc\n"); 143 + work_dir.run_jj(["new"]).success(); 144 + work_dir.write_file("file", "def\n"); 145 + work_dir 146 + .run_jj(["bookmark", "create", "-r@", "right"]) 159 147 .success(); 160 148 161 - let output = test_env.run_jj_in( 162 - &repo_path, 163 - ["interdiff", "--from", "left", "--to", "right", "--git"], 164 - ); 149 + let output = work_dir.run_jj(["interdiff", "--from", "left", "--to", "right", "--git"]); 165 150 insta::assert_snapshot!(output, @r" 166 151 diff --git a/file b/file 167 152 index 0000000000..24c5735c3e 100644