@@ -106,9 +106,16 @@ fn main() {
106106 let out_dir = Path :: new ( & args[ 2 ] ) ;
107107 let cargo = & Path :: new ( cargo) ;
108108
109- for test in TEST_REPOS . iter ( ) . rev ( ) {
110- if args[ 3 ..] . is_empty ( ) || args[ 3 ..] . iter ( ) . any ( |s| s. contains ( test. name ) ) {
111- test_repo ( cargo, out_dir, test) ;
109+ if false {
110+ for test in TEST_REPOS . iter ( ) . rev ( ) {
111+ if args[ 3 ..] . is_empty ( ) || args[ 3 ..] . iter ( ) . any ( |s| s. contains ( test. name ) ) {
112+ test_repo ( cargo, out_dir, test) ;
113+ }
114+ }
115+ } else {
116+ // For now, let Fuchsia tests fail.
117+ if std:: panic:: catch_unwind ( || test_fuchsia ( out_dir) ) . is_err ( ) {
118+ eprintln ! ( "Fuchsia tests failed; continuing." ) ;
112119 }
113120 }
114121}
@@ -216,3 +223,99 @@ fn run_cargo_test(
216223
217224 status. success ( )
218225}
226+
227+ fn test_fuchsia ( out_dir : & Path ) {
228+ const INTEGRATION_SHA : & str = "06ae16d18bd8e4db9a3fc062f678a170025d9f1a" ;
229+ const PICK_REFS : & [ & str ] = & [ "refs/changes/58/938058/3" , "refs/changes/33/943833/10" ] ;
230+
231+ // This script will:
232+ // - create a directory named "fuchsia" if it does not exist
233+ // - download "jiri" to "fuchsia/.jiri_root/bin"
234+ const BOOTSTRAP : & ' static str = r#"
235+ curl -s "https://fuchsia.googlesource.com/jiri/+/HEAD/scripts/bootstrap_jiri?format=TEXT" | base64 --decode | bash -s fuchsia
236+ "# ;
237+ let status = Command :: new ( "sh" ) . arg ( "-c" ) . arg ( BOOTSTRAP ) . current_dir ( out_dir) . status ( ) . unwrap ( ) ;
238+ assert ! ( status. success( ) , "bootstrap_jiri failed" ) ;
239+
240+ let checkout_dir = & out_dir. join ( "fuchsia" ) ;
241+ let jiri = || {
242+ let mut cmd = Command :: new ( ".jiri_root/bin/jiri" ) ;
243+ cmd. current_dir ( checkout_dir) ;
244+ cmd
245+ } ;
246+
247+ let status = jiri ( )
248+ . arg ( "init" )
249+ . arg ( "-partial=true" )
250+ . arg ( "-analytics-opt=false" )
251+ . arg ( checkout_dir)
252+ . status ( )
253+ . unwrap ( ) ;
254+ assert ! ( status. success( ) , "jiri init failed" ) ;
255+
256+ let status = jiri ( )
257+ . args ( [
258+ "import" ,
259+ "-name=integration" ,
260+ & format ! ( "-revision={INTEGRATION_SHA}" ) ,
261+ "-overwrite=true" ,
262+ "flower" ,
263+ "https://fuchsia.googlesource.com/integration" ,
264+ ] )
265+ . status ( )
266+ . unwrap ( ) ;
267+ assert ! ( status. success( ) , "jiri import failed" ) ;
268+
269+ if checkout_dir. join ( ".git" ) . is_dir ( ) {
270+ // Wipe out any local changes if we're reusing a checkout.
271+ let status = Command :: new ( "git" )
272+ . arg ( "checkout" )
273+ . arg ( "--force" )
274+ . arg ( "JIRI_HEAD" )
275+ . current_dir ( checkout_dir)
276+ . status ( )
277+ . unwrap ( ) ;
278+ assert ! ( status. success( ) , "checkout JIRI_HEAD failed" ) ;
279+ }
280+
281+ let status = jiri ( )
282+ . arg ( "update" )
283+ . arg ( "-autoupdate=false" )
284+ // .arg("-v")
285+ . status ( )
286+ . unwrap ( ) ;
287+ assert ! ( status. success( ) , "jiri update failed" ) ;
288+
289+ let integration = Command :: new ( "git" )
290+ . current_dir ( checkout_dir. join ( "integration" ) )
291+ . arg ( "rev-parse" )
292+ . arg ( "HEAD" )
293+ . output ( )
294+ . unwrap ( )
295+ . stdout ;
296+ let integration = String :: from_utf8_lossy ( & integration) ;
297+ println ! ( "integration commit = {integration}" ) ;
298+
299+ for git_ref in PICK_REFS {
300+ let status = Command :: new ( "git" )
301+ . current_dir ( checkout_dir)
302+ . args ( [ "fetch" , "https://fuchsia.googlesource.com/fuchsia" , git_ref] )
303+ . status ( )
304+ . unwrap ( ) ;
305+ assert ! ( status. success( ) , "fetching ref '{git_ref}' failed" ) ;
306+
307+ let status = Command :: new ( "git" )
308+ . current_dir ( checkout_dir)
309+ . args ( [ "cherry-pick" , "--no-commit" , "FETCH_HEAD" ] )
310+ . status ( )
311+ . unwrap ( ) ;
312+ assert ! ( status. success( ) , "picking ref '{git_ref}' failed" ) ;
313+ }
314+
315+ let status = Command :: new ( "bash" )
316+ . current_dir ( checkout_dir)
317+ . arg ( "scripts/rust/build_fuchsia_from_rust_ci.sh" )
318+ . status ( )
319+ . unwrap ( ) ;
320+ assert ! ( status. success( ) , "fuchsia build failed" ) ;
321+ }
0 commit comments