@@ -11,11 +11,13 @@ pub(crate) fn prepare(dirs: &Dirs) {
1111 std:: fs:: create_dir_all ( & dirs. download_dir ) . unwrap ( ) ;
1212 crate :: tests:: RAND_REPO . fetch ( dirs) ;
1313 crate :: tests:: REGEX_REPO . fetch ( dirs) ;
14+ crate :: tests:: GRAVIOLA_REPO . fetch ( dirs) ;
1415}
1516
1617pub ( crate ) struct GitRepo {
1718 url : GitRepoUrl ,
1819 rev : & ' static str ,
20+ submodules : & ' static [ & ' static str ] ,
1921 content_hash : & ' static str ,
2022 patch_name : & ' static str ,
2123}
@@ -71,10 +73,17 @@ impl GitRepo {
7173 user : & ' static str ,
7274 repo : & ' static str ,
7375 rev : & ' static str ,
76+ submodules : & ' static [ & ' static str ] ,
7477 content_hash : & ' static str ,
7578 patch_name : & ' static str ,
7679 ) -> GitRepo {
77- GitRepo { url : GitRepoUrl :: Github { user, repo } , rev, content_hash, patch_name }
80+ GitRepo {
81+ url : GitRepoUrl :: Github { user, repo } ,
82+ rev,
83+ submodules,
84+ content_hash,
85+ patch_name,
86+ }
7887 }
7988
8089 fn download_dir ( & self , dirs : & Dirs ) -> PathBuf {
@@ -132,6 +141,7 @@ impl GitRepo {
132141 & download_dir,
133142 & format ! ( "https://github.com/{}/{}.git" , user, repo) ,
134143 self . rev ,
144+ self . submodules ,
135145 ) ;
136146 }
137147 }
@@ -160,7 +170,7 @@ impl GitRepo {
160170 }
161171}
162172
163- fn clone_repo ( download_dir : & Path , repo : & str , rev : & str ) {
173+ fn clone_repo ( download_dir : & Path , repo : & str , rev : & str , submodules : & [ & str ] ) {
164174 eprintln ! ( "[CLONE] {}" , repo) ;
165175
166176 match fs:: remove_dir_all ( download_dir) {
@@ -180,6 +190,13 @@ fn clone_repo(download_dir: &Path, repo: &str, rev: &str) {
180190 checkout_cmd. arg ( "-q" ) . arg ( rev) ;
181191 spawn_and_wait ( checkout_cmd) ;
182192
193+ if !submodules. is_empty ( ) {
194+ let mut submodule_cmd = git_command ( download_dir, "submodule" ) ;
195+ submodule_cmd. arg ( "update" ) . arg ( "--init" ) ;
196+ submodule_cmd. args ( submodules) ;
197+ spawn_and_wait ( submodule_cmd) ;
198+ }
199+
183200 std:: fs:: remove_dir_all ( download_dir. join ( ".git" ) ) . unwrap ( ) ;
184201}
185202
0 commit comments