@@ -229,7 +229,8 @@ struct FixtureSnapshot {
229229
230230#[ cfg( windows) ]
231231impl FixtureSnapshot {
232- fn capture ( fixture : & Fixture ) -> Self {
232+ fn capture ( fixture : & mut Fixture ) -> Self {
233+ fixture. stop_daemon ( ) ;
233234 let dir = TempDir :: new ( ) . expect ( "fixture snapshot tempdir" ) ;
234235 let profile_path = dir. path ( ) . join ( ".tracedecay" ) ;
235236 std:: fs:: create_dir_all ( & profile_path) . unwrap_or_else ( |e| {
@@ -239,13 +240,15 @@ impl FixtureSnapshot {
239240 )
240241 } ) ;
241242 copy_dir_contents ( & fixture. home_path . join ( ".tracedecay" ) , & profile_path) ;
243+ fixture. start_daemon ( ) ;
242244 Self {
243245 _dir : dir,
244246 profile_path,
245247 }
246248 }
247249
248- fn restore_into ( & self , fixture : & Fixture ) {
250+ fn restore_into ( & self , fixture : & mut Fixture ) {
251+ fixture. stop_daemon ( ) ;
249252 let profile_path = fixture. home_path . join ( ".tracedecay" ) ;
250253 if profile_path. exists ( ) {
251254 std:: fs:: remove_dir_all ( & profile_path) . unwrap_or_else ( |e| {
@@ -262,10 +265,21 @@ impl FixtureSnapshot {
262265 )
263266 } ) ;
264267 copy_dir_contents ( & self . profile_path , & profile_path) ;
268+ fixture. start_daemon ( ) ;
265269 }
266270}
267271
268272impl Fixture {
273+ fn start_daemon ( & mut self ) {
274+ assert ! ( self . _daemon. is_none( ) , "fixture daemon already running" ) ;
275+ self . _daemon = Some ( common:: spawn_tracedecay_daemon ( & self . home_path ) ) ;
276+ }
277+
278+ #[ cfg( windows) ]
279+ fn stop_daemon ( & mut self ) {
280+ drop ( self . _daemon . take ( ) ) ;
281+ }
282+
269283 fn db_path ( & self ) -> PathBuf {
270284 tracedecay:: storage:: resolve_layout ( & self . project_path , & self . home_path . join ( ".tracedecay" ) )
271285 . expect ( "resolve fixture storage layout" )
@@ -534,7 +548,7 @@ fn build_fixture(setup: &Setup) -> Fixture {
534548 }
535549 initialize_fixture_project ( & fixture) ;
536550 seed_setup_facts ( & fixture, & setup. facts ) ;
537- fixture. _daemon = Some ( common :: spawn_tracedecay_daemon ( & fixture . home_path ) ) ;
551+ fixture. start_daemon ( ) ;
538552 fixture
539553}
540554
@@ -816,7 +830,7 @@ fn run_scenario(id: &str) {
816830 #[ cfg( windows) ]
817831 let baseline_snapshot =
818832 if !well_behaved_steps. is_empty ( ) && scenario. deterministic . violation . is_some ( ) {
819- Some ( FixtureSnapshot :: capture ( & fixture) )
833+ Some ( FixtureSnapshot :: capture ( & mut fixture) )
820834 } else {
821835 None
822836 } ;
@@ -854,7 +868,7 @@ fn run_scenario(id: &str) {
854868 if !well_behaved_steps. is_empty ( ) {
855869 #[ cfg( windows) ]
856870 if let Some ( snapshot) = & baseline_snapshot {
857- snapshot. restore_into ( & fixture) ;
871+ snapshot. restore_into ( & mut fixture) ;
858872 }
859873 #[ cfg( not( windows) ) ]
860874 {
0 commit comments