Skip to content

Commit

Permalink
store sys
Browse files Browse the repository at this point in the history
  • Loading branch information
nayeemrmn committed Jan 27, 2025
1 parent c3a06e3 commit 315518b
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 54 deletions.
41 changes: 37 additions & 4 deletions src/workspace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,11 +556,11 @@ impl Workspace {
})
}

pub fn create_resolver(
pub fn create_resolver<TSys: FsMetadata + FsRead>(
&self,
sys: &impl FsRead,
sys: TSys,
options: CreateResolverOptions,
) -> Result<WorkspaceResolver, WorkspaceResolverCreateError> {
) -> Result<WorkspaceResolver<TSys>, WorkspaceResolverCreateError> {
WorkspaceResolver::from_workspace(self, sys, options)
}

Expand Down Expand Up @@ -2095,8 +2095,41 @@ mod test {

use super::*;

#[derive(Debug)]
struct UnreachableMetadata;

impl sys_traits::FsMetadataValue for UnreachableMetadata {
fn file_type(&self) -> sys_traits::FileType {
unreachable!()
}

fn modified(&self) -> std::io::Result<std::time::SystemTime> {
unreachable!()
}
}

struct UnreachableSys;

impl sys_traits::BaseFsMetadata for UnreachableSys {
type Metadata = UnreachableMetadata;

#[doc(hidden)]
fn base_fs_metadata(
&self,
_path: &Path,
) -> std::io::Result<Self::Metadata> {
unreachable!()
}

#[doc(hidden)]
fn base_fs_symlink_metadata(
&self,
_path: &Path,
) -> std::io::Result<Self::Metadata> {
unreachable!()
}
}

impl sys_traits::BaseFsRead for UnreachableSys {
fn base_fs_read(
&self,
Expand Down Expand Up @@ -2687,7 +2720,7 @@ mod test {
);
let resolver = workspace_dir
.workspace
.create_resolver(&UnreachableSys, Default::default())
.create_resolver(UnreachableSys, Default::default())
.unwrap();
assert_eq!(
serde_json::from_str::<serde_json::Value>(
Expand Down
Loading

0 comments on commit 315518b

Please sign in to comment.