@@ -28,29 +28,22 @@ impl Db {
2828 let rule_selection = RuleSelection :: from_registry ( default_lint_registry ( ) ) ;
2929
3030 Self {
31- system : MdtestSystem :: in_memory ( SystemPathBuf :: from ( "/" ) ) ,
31+ system : MdtestSystem :: in_memory ( ) ,
3232 storage : salsa:: Storage :: default ( ) ,
3333 vendored : red_knot_vendored:: file_system ( ) . clone ( ) ,
3434 files : Files :: default ( ) ,
3535 rule_selection : Arc :: new ( rule_selection) ,
3636 }
3737 }
3838
39- pub ( crate ) fn reset_fs ( & mut self ) {
40- match & * self . system . 0 {
41- MdtestSystemInner :: InMemory ( in_memory) => {
42- in_memory. fs ( ) . remove_all ( ) ;
43- }
44- MdtestSystemInner :: Os { .. } => {
45- self . system = MdtestSystem :: in_memory ( SystemPathBuf :: from ( "/" ) ) ;
46- }
47- }
48-
39+ pub ( crate ) fn use_os_system_with_temp_dir ( & mut self , cwd : SystemPathBuf , temp_dir : TempDir ) {
40+ self . system . with_os ( cwd, temp_dir) ;
4941 Files :: sync_all ( self ) ;
5042 }
5143
52- pub ( crate ) fn with_tempdir_fs ( & mut self , cwd : SystemPathBuf , temp_dir : TempDir ) {
53- self . system . with_os ( cwd, temp_dir) ;
44+ pub ( crate ) fn use_in_memory_system ( & mut self ) {
45+ self . system . with_in_memory ( ) ;
46+ Files :: sync_all ( self ) ;
5447 }
5548
5649 pub ( crate ) fn create_directory_all ( & self , path : & SystemPath ) -> ruff_db:: system:: Result < ( ) > {
@@ -122,10 +115,10 @@ enum MdtestSystemInner {
122115}
123116
124117impl MdtestSystem {
125- fn in_memory ( cwd : SystemPathBuf ) -> Self {
126- Self ( Arc :: new ( MdtestSystemInner :: InMemory ( InMemorySystem :: new (
127- cwd ,
128- ) ) ) )
118+ fn in_memory ( ) -> Self {
119+ Self ( Arc :: new ( MdtestSystemInner :: InMemory (
120+ InMemorySystem :: default ( ) ,
121+ ) ) )
129122 }
130123
131124 fn as_system ( & self ) -> & dyn WritableSystem {
@@ -142,6 +135,14 @@ impl MdtestSystem {
142135 } ) ;
143136 }
144137
138+ fn with_in_memory ( & mut self ) {
139+ if let MdtestSystemInner :: InMemory ( in_memory) = & * self . 0 {
140+ in_memory. fs ( ) . remove_all ( ) ;
141+ } else {
142+ self . 0 = Arc :: new ( MdtestSystemInner :: InMemory ( InMemorySystem :: default ( ) ) ) ;
143+ }
144+ }
145+
145146 fn normalize_path < ' a > ( & self , path : & ' a SystemPath ) -> Cow < ' a , SystemPath > {
146147 match & * self . 0 {
147148 MdtestSystemInner :: InMemory ( _) => Cow :: Borrowed ( path) ,
0 commit comments