fix tests
This commit is contained in:
parent
ca458cc529
commit
a9a23251b7
6 changed files with 21 additions and 14 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -11475,6 +11475,7 @@ name = "paths"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dirs 4.0.0",
|
||||
"ignore",
|
||||
"util",
|
||||
"workspace-hack",
|
||||
]
|
||||
|
|
|
@ -13,5 +13,6 @@ path = "src/paths.rs"
|
|||
|
||||
[dependencies]
|
||||
dirs.workspace = true
|
||||
ignore.workspace = true
|
||||
util.workspace = true
|
||||
workspace-hack.workspace = true
|
||||
|
|
|
@ -507,3 +507,16 @@ fn add_vscode_user_data_paths(paths: &mut Vec<PathBuf>, product_name: &str) {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub fn global_gitignore_path() -> Option<PathBuf> {
|
||||
Some(Path::new(util::path!("/home/zed/.config/git/ignore")).into())
|
||||
}
|
||||
|
||||
#[cfg(not(any(test, feature = "test-support")))]
|
||||
pub fn global_gitignore_path() -> Option<PathBuf> {
|
||||
static GLOBAL_GITIGNORE_PATH: OnceLock<Option<PathBuf>> = OnceLock::new();
|
||||
GLOBAL_GITIGNORE_PATH
|
||||
.get_or_init(|| ::ignore::gitignore::gitconfig_excludes_path())
|
||||
.clone()
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ use lsp::{
|
|||
WillRenameFiles, notification::DidRenameFiles,
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use paths::{config_dir, tasks_file};
|
||||
use paths::{config_dir, global_gitignore_path, tasks_file};
|
||||
use postage::stream::Stream as _;
|
||||
use pretty_assertions::{assert_eq, assert_matches};
|
||||
use rand::{Rng as _, rngs::StdRng};
|
||||
|
@ -1179,7 +1179,9 @@ async fn test_reporting_fs_changes_to_language_servers(cx: &mut gpui::TestAppCon
|
|||
assert_eq!(fs.read_dir_call_count() - prev_read_dir_count, 5);
|
||||
|
||||
let mut new_watched_paths = fs.watched_paths();
|
||||
new_watched_paths.retain(|path| !path.starts_with(config_dir()));
|
||||
new_watched_paths.retain(|path| {
|
||||
!path.starts_with(config_dir()) && !path.starts_with(global_gitignore_path().unwrap())
|
||||
});
|
||||
assert_eq!(
|
||||
&new_watched_paths,
|
||||
&[
|
||||
|
|
|
@ -17,7 +17,7 @@ use crate::NumericPrefixWithSuffix;
|
|||
pub fn home_dir() -> &'static PathBuf {
|
||||
static HOME_DIR: OnceLock<PathBuf> = OnceLock::new();
|
||||
HOME_DIR.get_or_init(|| {
|
||||
if cfg!(test) {
|
||||
if cfg!(any(test, feature = "test-support")) {
|
||||
PathBuf::from("/home/zed")
|
||||
} else {
|
||||
dirs::home_dir().expect("failed to determine home directory")
|
||||
|
|
|
@ -3846,7 +3846,7 @@ impl BackgroundScanner {
|
|||
|
||||
log::trace!("containing git repository: {containing_git_repository:?}");
|
||||
|
||||
let global_gitignore_path = global_gitignore_path();
|
||||
let global_gitignore_path = paths::global_gitignore_path();
|
||||
self.state.lock().snapshot.global_gitignore =
|
||||
if let Some(global_gitignore_path) = global_gitignore_path.as_ref() {
|
||||
build_gitignore(global_gitignore_path, self.fs.as_ref())
|
||||
|
@ -5708,13 +5708,3 @@ fn discover_git_paths(dot_git_abs_path: &Arc<Path>, fs: &dyn Fs) -> (Arc<Path>,
|
|||
|
||||
(repository_dir_abs_path, common_dir_abs_path)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn global_gitignore_path() -> Option<Arc<Path>> {
|
||||
Some(Path::new(util::path!("/home/zed/.config/git/ignore")).into())
|
||||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
fn global_gitignore_path() -> Option<Arc<Path>> {
|
||||
::ignore::gitignore::gitconfig_excludes_path().map(Into::into)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue