@@ -148,8 +148,7 @@ fn preboot(
148148/// Run a smoke test against a `spin new` http template
149149pub fn http_smoke_test_template (
150150 template_name : & str ,
151- template_url : Option < & str > ,
152- template_branch : Option < & str > ,
151+ template_url : Option < TemplateSource > ,
153152 plugins : & [ & str ] ,
154153 prebuild_hook : impl FnOnce ( & mut TestEnvironment < ( ) > ) -> anyhow:: Result < ( ) > ,
155154 build_env_vars : HashMap < String , String > ,
@@ -158,7 +157,6 @@ pub fn http_smoke_test_template(
158157 http_smoke_test_template_with_route (
159158 template_name,
160159 template_url,
161- template_branch,
162160 plugins,
163161 prebuild_hook,
164162 build_env_vars,
@@ -172,8 +170,7 @@ pub fn http_smoke_test_template(
172170#[ allow( clippy:: too_many_arguments) ]
173171pub fn http_smoke_test_template_with_route (
174172 template_name : & str ,
175- template_url : Option < & str > ,
176- template_branch : Option < & str > ,
173+ template_url : Option < TemplateSource > ,
177174 plugins : & [ & str ] ,
178175 prebuild_hook : impl FnOnce ( & mut TestEnvironment < ( ) > ) -> anyhow:: Result < ( ) > ,
179176 build_env_vars : HashMap < String , String > ,
@@ -183,7 +180,6 @@ pub fn http_smoke_test_template_with_route(
183180 let mut env = bootstrap_smoke_test (
184181 ServicesConfig :: none ( ) ,
185182 template_url,
186- template_branch,
187183 plugins,
188184 template_name,
189185 |_| Ok ( Vec :: new ( ) ) ,
@@ -207,8 +203,7 @@ pub fn http_smoke_test_template_with_route(
207203#[ allow( dependency_on_unit_never_type_fallback) ]
208204pub fn redis_smoke_test_template (
209205 template_name : & str ,
210- template_url : Option < & str > ,
211- template_branch : Option < & str > ,
206+ template_url : Option < TemplateSource > ,
212207 plugins : & [ & str ] ,
213208 new_app_args : impl FnOnce ( u16 ) -> Vec < String > ,
214209 prebuild_hook : impl FnOnce ( & mut TestEnvironment < ( ) > ) -> anyhow:: Result < ( ) > ,
@@ -217,7 +212,6 @@ pub fn redis_smoke_test_template(
217212 let mut env = bootstrap_smoke_test (
218213 test_environment:: services:: ServicesConfig :: new ( vec ! [ "redis" ] ) ?,
219214 template_url,
220- template_branch,
221215 plugins,
222216 template_name,
223217 |env| {
@@ -254,13 +248,20 @@ pub fn redis_smoke_test_template(
254248
255249static TEMPLATE_MUTEX : std:: sync:: Mutex < ( ) > = std:: sync:: Mutex :: new ( ( ) ) ;
256250
251+ pub enum TemplateSource {
252+ Url {
253+ repo : & ' static str ,
254+ branch : Option < & ' static str > ,
255+ } ,
256+ Local ,
257+ }
258+
257259/// Bootstrap a test environment for a smoke test
258260// TODO: refactor this function to not take so many arguments
259261#[ allow( clippy:: too_many_arguments) ]
260262pub fn bootstrap_smoke_test (
261263 services : ServicesConfig ,
262- template_url : Option < & str > ,
263- template_branch : Option < & str > ,
264+ template_url : Option < TemplateSource > ,
264265 plugins : & [ & str ] ,
265266 template_name : & str ,
266267 new_app_args : impl FnOnce ( & mut TestEnvironment < ( ) > ) -> anyhow:: Result < Vec < String > > ,
@@ -271,12 +272,25 @@ pub fn bootstrap_smoke_test(
271272) -> anyhow:: Result < TestEnvironment < testing_framework:: runtimes:: spin_cli:: SpinCli > > {
272273 let mut env: TestEnvironment < ( ) > = TestEnvironment :: boot ( services) ?;
273274
274- let template_url = template_url. unwrap_or ( "https://github.com/spinframework/spin" ) ;
275+ let this_dir = std:: env:: current_dir ( ) ?. display ( ) . to_string ( ) ;
276+
277+ let template_source = template_url. unwrap_or ( TemplateSource :: Url {
278+ repo : "https://github.com/spinframework/spin" ,
279+ branch : None ,
280+ } ) ;
281+ let install_loc_args = match template_source {
282+ TemplateSource :: Url { repo, branch : None } => & [ "--git" , repo] ,
283+ TemplateSource :: Url {
284+ repo,
285+ branch : Some ( br) ,
286+ } => & [ "--git" , repo, "--branch" , br] [ ..] ,
287+ TemplateSource :: Local => & [ "--dir" , & this_dir] ,
288+ } ;
289+
275290 let mut template_install = std:: process:: Command :: new ( spin_binary ( ) ) ;
276- template_install. args ( [ "templates" , "install" , "--git" , template_url, "--update" ] ) ;
277- if let Some ( branch) = template_branch {
278- template_install. args ( [ "--branch" , branch] ) ;
279- }
291+ template_install. args ( [ "templates" , "install" , "--update" ] ) ;
292+ template_install. args ( install_loc_args) ;
293+
280294 // We need to serialize template installs since they can't be run in parallel
281295 {
282296 let _guard = TEMPLATE_MUTEX . lock ( ) . unwrap ( ) ;
0 commit comments