Robin Stocker
2d9c72ffb1
cli/tests: Prevent git.subprocess from reading outside git config
...
A subset of cli tests could fail if the system /etc/gitconfig had
configuration interfering with the tests. The cause seems to be running
of `jj` commands that would in turn use a `git` subprocess.
Fix this by setting `GIT_CONFIG_SYSTEM` and `GIT_CONFIG_GLOBAL`, like
in `hermetic_git`.
Fixes #6159
2025-03-31 10:46:57 +00:00
Yuya Nishihara
b000c94a7a
tests: add work_dir.dir(path), make create_dir*() return helper for sub dir
...
I found this pattern is common.
2025-03-18 01:25:08 +00:00
Yuya Nishihara
7ab62ab865
tests: extract CommandOutput types to sub module
...
These types don't depend on TestEnvironment.
2025-03-18 01:25:08 +00:00
Emily
a56b78bdb6
git: make git2
support optional
...
This helps us prepare for removing the functionality down the line and
makes things easier for people building or packaging their own Jujutsu.
2025-03-16 06:07:28 +00:00
Caleb White
7e944f0d11
cli: config {edit,set,unset}: prompt when multiple files exist
...
This allows the user to select a particular file when using multiple
configs. In the event that a prompt cannot be displayed, the first
file will be automatically selected.
2025-03-13 03:51:52 +00:00
Yuya Nishihara
d5d4c7fe79
tests: port test_absorb_command.rs to TestWorkDir API, add read_file() helper
...
read_file() returns BString as it implements Display.
2025-03-12 02:18:56 +00:00
Yuya Nishihara
e802c4b8fe
tests: move current_operation_id() to TestWorkDir
2025-03-11 01:23:13 +00:00
Emily
eeb34146ca
tests: remove libgit2
test performance hack
...
I think we should only initialize the library for the fetch/push
tests now, so it should be okay to drop this.
2025-03-10 15:08:08 +00:00
Yuya Nishihara
16028245d6
tests: add workspace test helper, use it in test_global_opts.rs
...
It's super common to pair test_env with repo_path.
Some of the tests still use absolute paths because it seemed rather confusing
to mix paths relative to the repo_root and to the env_root.
2025-03-10 07:50:18 +00:00
Yuya Nishihara
7fa8420908
tests: resolve directory path to run_jj_in() relative to env_root
...
Suppose we'll add test_env.init_workspace(path) or something, this will probably
make sense.
2025-02-25 15:40:14 +00:00
Yuya Nishihara
3634ff298c
tests: simplify jj_cmd() interface, rename to new_jj_cmd()
2025-02-25 15:40:14 +00:00
Yuya Nishihara
28803eef94
tests: rewrite remaining callers of jj_cmd() to use run_jj_in/with()
2025-02-25 15:40:14 +00:00
Yuya Nishihara
ad6985fd9c
tests: migrate unusual patterns of jj_cmd_ok() to run_jj_in()
...
These callers are manually ported to run_jj_in().
2025-02-24 15:39:11 +00:00
Yuya Nishihara
c9926eae4c
tests: implement Debug and Eq for CommandOutput
...
This helps assert that two command invocations generate exactly the same
results.
2025-02-24 00:57:24 +00:00
Yuya Nishihara
a1270f0149
tests: remove stale comment about CommandOutput wrapper
2025-02-24 00:57:24 +00:00
Yuya Nishihara
c83abc9dec
tests: migrate non-snapshot users of jj_cmd_success() to run_jj_in().success()
2025-02-23 13:34:17 +00:00
Yuya Nishihara
2543329c78
tests: remove unused jj_cmd_panic()
2025-02-23 03:06:59 +00:00
Yuya Nishihara
79a0867050
tests: migrate callers of jj_cmd_internal_error() to run_jj_in()
2025-02-23 03:06:59 +00:00
Yuya Nishihara
b79b29c288
tests: migrate callers of jj_cmd_cli_error() to run_jj_in()
2025-02-23 03:06:59 +00:00
Yuya Nishihara
d19e58f591
tests: migrate callers of jj_cmd_failure() to run_jj_in()
2025-02-23 03:06:59 +00:00
Yuya Nishihara
696cfee55f
tests: stop using assert_eq!() in cli tests where possible
...
Normalize the output instead.
2025-02-23 03:06:59 +00:00
Yuya Nishihara
18ea718113
tests: migrate some helper functions that uses jj_cmd_*() to run_jj_in()
...
Snapshotted operation IDs are changed because this patch reorders "jj new"
command arguments.
2025-02-22 01:23:04 +00:00
Yuya Nishihara
2581cd82be
tests: migrate users of normalize_with() to run_jj_in() function
2025-02-21 01:49:41 +00:00
Yuya Nishihara
cf7f1dfc88
tests: migrate users of normalize_exit_status() to run_jj_in() function
2025-02-21 01:49:41 +00:00
Yuya Nishihara
53664ce2a4
tests: migrate jj_cmd_stdin*() to run_jj*() functions
2025-02-21 01:49:41 +00:00
Yuya Nishihara
de462a6268
tests: add helper to snapshot command output and exit status all at once
...
It's easier to review insta snapshot diffs than scanning panic log containing
lengthy output. I think this will also help printf debugging.
test_global_opts.rs is migrated to new API as an example.
2025-02-20 05:22:32 +00:00
Yuya Nishihara
740d8a2b1b
tests: add #[must_use] to helper functions that return value to be tested
2025-02-20 05:22:32 +00:00
Yuya Nishihara
630036eeb0
tests: add [EOF] marker to command output when displaying
...
It's important to test that command output is (usually) terminated with newline,
but insta::assert_snapshot!() is lax about that.
2025-02-19 02:31:59 +00:00
Yuya Nishihara
a54165230a
tests: add CommandOutputString wrapper
...
I'm going to add "[EOF]" marker to test that command output is terminated by
newline char. This patch ensures that callers who expect a raw output string
would never be affected by any normalization passes.
Some common normalization functions are extracted as CommandOutputString
methods.
2025-02-19 02:31:59 +00:00
Yuya Nishihara
0eddf5f3d6
tests: extract helper function that substitutes $TEST_ENV
...
I'm going to add wrapper type for normalized output, and this change makes
porting a bit easier.
2025-02-19 02:31:59 +00:00
Baltasar Dinis
769dbd8f5f
cli/tests: move test environment to its own file
...
The `mod.rs` was becoming crowded and this makes way for unrelated
additions to the test utilities module
2025-02-11 13:46:25 +00:00