fix(test): running test as root (#1817)

* fix(test): running test as root

The dummy root path /root conflicts with root user's home directory on Linux and redacts incorrectly. Our downstream CI environment builds tinymist in docker as root and encounters the problem. Change the path to `/dummy-root` fixes it. To ensure consistency, other similar occurences are also prefixed with `dummy-`.

* dev: deduplicate a bit

---------

Co-authored-by: Myriad-Dreamin <camiyoru@gmail.com>
This commit is contained in:
Eric Long 2025-06-16 13:01:25 +08:00 committed by GitHub
parent c0d5f0c800
commit 9d9d360db9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 32 additions and 40 deletions

View file

@ -446,9 +446,9 @@ pub(crate) fn file_path(uri: &str) -> String {
pub(crate) fn file_path_(uri: &lsp_types::Url) -> String {
let root = if cfg!(windows) {
PathBuf::from("C:\\root")
PathBuf::from("C:\\dummy-root")
} else {
PathBuf::from("/root")
PathBuf::from("/dummy-root")
};
let uri = uri.to_file_path().unwrap();
let abs_path = Path::new(&uri).strip_prefix(root).map(|p| p.to_owned());