@@ -8,8 +8,8 @@ use crate::{
88use md5:: Context ;
99use serde:: { Deserialize , Serialize } ;
1010use serde_yaml:: Mapping ;
11- use std:: io:: Write ;
1211use std:: path:: { Path , PathBuf } ;
12+ use std:: { io:: Write , time:: Duration } ;
1313use tmc_langs_framework:: { command:: TmcCommand , file_util, subprocess:: Redirection } ;
1414use walkdir:: WalkDir ;
1515
@@ -200,7 +200,10 @@ fn initialize_new_cache_clone(
200200 log:: info!( "initializing repository at {}" , new_clone_path. display( ) ) ;
201201
202202 if old_clone_path. join ( ".git" ) . exists ( ) {
203- log:: info!( "trying to copy clone from previous cache" ) ;
203+ log:: info!(
204+ "trying to copy clone from previous cache at {}" ,
205+ old_clone_path. display( )
206+ ) ;
204207
205208 // closure to collect any error that occurs during the process
206209 let copy_and_update_repository = || -> Result < ( ) , UtilError > {
@@ -214,7 +217,7 @@ fn initialize_new_cache_clone(
214217 . stdout ( Redirection :: Pipe )
215218 . stderr ( Redirection :: Pipe )
216219 } )
217- . output_checked ( )
220+ . output_with_timeout_checked ( Duration :: from_secs ( 60 * 2 ) )
218221 } ;
219222
220223 run_git ( & [ "remote" , "set-url" , "origin" , course_source_url] ) ?;
@@ -249,7 +252,7 @@ fn initialize_new_cache_clone(
249252 . stdout ( Redirection :: Pipe )
250253 . stderr ( Redirection :: Pipe )
251254 } )
252- . output_checked ( ) ?;
255+ . output_with_timeout_checked ( Duration :: from_secs ( 60 * 2 ) ) ?;
253256 Ok ( ( ) )
254257}
255258
@@ -440,52 +443,6 @@ mod test {
440443 target
441444 }
442445
443- /*
444- #[test]
445- #[ignore = "uses git"]
446- fn updates_repository() {
447- init();
448-
449- let cache = tempfile::TempDir::new().unwrap();
450- file_util::create_dir_all(cache.path().join("clone")).unwrap();
451- let run_git = |args: &[&str], cwd: &Path| {
452- TmcCommand::new("git")
453- .with(|e| {
454- e.args(args)
455- .cwd(cwd)
456- .stdout(Redirection::Pipe)
457- .stderr(Redirection::Pipe)
458- })
459- .output_checked()
460- .unwrap()
461- };
462- run_git(&["init"], &cache.path().join("clone"));
463- assert!(cache.path().join("clone/.git").exists());
464-
465- let clone = tempfile::TempDir::new().unwrap();
466- run_git(&["init"], &clone.path());
467- run_git(&["remote", "add", "origin", ""], &clone.path());
468-
469- update_or_clone_repository(clone.path(), Path::new(GIT_REPO), "master", cache.path())
470- .unwrap();
471- assert!(clone.path().join("texts").exists());
472- }
473-
474- #[test]
475- #[ignore = "uses git"]
476- fn clones_repository() {
477- init();
478-
479- let clone = tempfile::TempDir::new().unwrap();
480- assert!(!clone.path().join(".git").exists());
481- let old_cache_path = Path::new("nonexistent");
482-
483- update_or_clone_repository(clone.path(), Path::new(GIT_REPO), "master", old_cache_path)
484- .unwrap();
485- assert!(clone.path().join("texts").exists());
486- }
487- */
488-
489446 #[ test]
490447 fn checks_directory_names ( ) {
491448 init ( ) ;
0 commit comments