@@ -724,40 +724,109 @@ where
724724// echo "[BUILD] sysroot in release mode"
725725// ./build_sysroot/build_sysroot.sh --release
726726
727+ struct Project {
728+ url : & ' static str ,
729+ /// Arguments added to both the `cargo build` and the `cargo test` invocations.
730+ cargo_arguments : & ' static [ & ' static str ] ,
731+ /// Arguments forwarded to the test harness by `cargo test`.
732+ test_harness_arguments : & ' static [ & ' static str ] ,
733+ /// Variables added to the environment of both invocations.
734+ environment_variables : & ' static [ ( & ' static str , & ' static str ) ] ,
735+ }
736+
737+ impl Project {
738+ const fn new ( url : & ' static str ) -> Self {
739+ Self { url, cargo_arguments : & [ ] , test_harness_arguments : & [ ] , environment_variables : & [ ] }
740+ }
741+
742+ const fn cargo_arguments ( mut self , arguments : & ' static [ & ' static str ] ) -> Self {
743+ self . cargo_arguments = arguments;
744+ self
745+ }
746+
747+ const fn test_harness_arguments ( mut self , arguments : & ' static [ & ' static str ] ) -> Self {
748+ self . test_harness_arguments = arguments;
749+ self
750+ }
751+
752+ const fn environment_variables (
753+ mut self ,
754+ variables : & ' static [ ( & ' static str , & ' static str ) ] ,
755+ ) -> Self {
756+ self . environment_variables = variables;
757+ self
758+ }
759+ }
760+
727761fn test_projects ( env : & Env , args : & TestArg ) -> Result < ( ) , String > {
728762 let projects = [
729- //"https://gitlab.gnome.org/GNOME/librsvg", // FIXME: doesn't compile in the CI since the
730- // version of cairo and other libraries is too old.
731- "https://github.com/rust-random/getrandom" ,
732- "https://github.com/BurntSushi/memchr" ,
733- "https://github.com/dtolnay/itoa" ,
734- "https://github.com/rust-lang/cfg-if" ,
735- //"https://github.com/rust-lang-nursery/lazy-static.rs", // FIXME: re-enable when the
736- //failing test is fixed upstream.
737- //"https://github.com/marshallpierce/rust-base64", // FIXME: one test is OOM-killed.
738- // FIXME: ignore the base64 test that is OOM-killed.
739- //"https://github.com/time-rs/time", // FIXME: one test fails (https://github.com/time-rs/time/issues/719).
740- "https://github.com/rust-lang/log" ,
741- "https://github.com/bitflags/bitflags" ,
742- //"https://github.com/serde-rs/serde", // FIXME: one test fails.
743- //"https://github.com/rayon-rs/rayon", // FIXME: very slow, only run on master?
744- //"https://github.com/rust-lang/cargo", // FIXME: very slow, only run on master?
763+ // The reference images assume the exact cairo, pango and freetype that librsvg pins in its
764+ // own CI; this one renders text decorations a pixel off with the versions Ubuntu ships.
765+ Project :: new ( "https://gitlab.gnome.org/GNOME/librsvg" )
766+ . test_harness_arguments ( & [ "--skip" , "tests::svg1_1_text_text_03_b_svg" , "--exact" ] )
767+ // A debug build of librsvg needs about 5 MB of stack per `cargo test` thread to reach
768+ // its maximum layer nesting depth; librsvg's own CI sets the same value.
769+ . environment_variables ( & [ ( "RUST_MIN_STACK" , "8388608" ) ] ) ,
770+ Project :: new ( "https://github.com/rust-random/getrandom" ) ,
771+ Project :: new ( "https://github.com/BurntSushi/memchr" ) ,
772+ Project :: new ( "https://github.com/dtolnay/itoa" ) ,
773+ Project :: new ( "https://github.com/rust-lang/cfg-if" ) ,
774+ // The `ui` test compares against the diagnostics of the compiler it was blessed with, so it
775+ // fails on the nightly we use no matter which backend produces the code.
776+ Project :: new ( "https://github.com/rust-lang-nursery/lazy-static.rs" )
777+ . test_harness_arguments ( & [ "--skip" , "ui" , "--exact" ] ) ,
778+ Project :: new ( "https://github.com/marshallpierce/rust-base64" ) ,
779+ // The test suite refuses to build unless every feature is enabled; it otherwise spawns a
780+ // nested `cargo test --all-features` which would not use this backend.
781+ Project :: new ( "https://github.com/time-rs/time" ) . cargo_arguments ( & [ "--all-features" ] ) ,
782+ Project :: new ( "https://github.com/rust-lang/log" ) ,
783+ Project :: new ( "https://github.com/bitflags/bitflags" ) ,
784+ Project :: new ( "https://github.com/serde-rs/serde" ) ,
785+ Project :: new ( "https://github.com/rayon-rs/rayon" ) ,
786+ // FIXME: too slow to run in the CI: the release build alone takes 46 minutes and the
787+ // `cargo` crate itself needs 5.4 GB of memory in a single rustc process.
788+ //Project::new("https://github.com/rust-lang/cargo"),
745789 ] ;
746790
747791 let mut env = env. clone ( ) ;
748792 let rustflags =
749793 format ! ( "{} --cap-lints allow" , env. get( "RUSTFLAGS" ) . cloned( ) . unwrap_or_default( ) ) ;
750794 env. insert ( "RUSTFLAGS" . to_string ( ) , rustflags) ;
751- let run_tests = |projects_path, iter : & mut dyn Iterator < Item = & & str > | -> Result < ( ) , String > {
752- for project in iter {
753- let clone_result = git_clone_root_dir ( project, projects_path, true ) ?;
754- let repo_path = Path :: new ( & clone_result. repo_dir ) ;
755- run_cargo_command ( & [ & "build" , & "--release" ] , Some ( repo_path) , & env, args) ?;
756- run_cargo_command ( & [ & "test" ] , Some ( repo_path) , & env, args) ?;
757- }
795+ let run_tests =
796+ |projects_path, iter : & mut dyn Iterator < Item = & Project > | -> Result < ( ) , String > {
797+ for project in iter {
798+ let clone_result = git_clone_root_dir ( project. url , projects_path, true ) ?;
799+ let repo_path = Path :: new ( & clone_result. repo_dir ) ;
800+
801+ let mut project_environment = env. clone ( ) ;
802+ for ( name, value) in project. environment_variables {
803+ project_environment. insert ( name. to_string ( ) , value. to_string ( ) ) ;
804+ }
758805
759- Ok ( ( ) )
760- } ;
806+ let mut build_command: Vec < & dyn AsRef < OsStr > > = vec ! [ & "build" , & "--release" ] ;
807+ build_command. extend (
808+ project. cargo_arguments . iter ( ) . map ( |argument| argument as & dyn AsRef < OsStr > ) ,
809+ ) ;
810+ run_cargo_command ( & build_command, Some ( repo_path) , & project_environment, args) ?;
811+
812+ let mut test_command: Vec < & dyn AsRef < OsStr > > = vec ! [ & "test" ] ;
813+ test_command. extend (
814+ project. cargo_arguments . iter ( ) . map ( |argument| argument as & dyn AsRef < OsStr > ) ,
815+ ) ;
816+ if !project. test_harness_arguments . is_empty ( ) {
817+ test_command. push ( & "--" ) ;
818+ test_command. extend (
819+ project
820+ . test_harness_arguments
821+ . iter ( )
822+ . map ( |argument| argument as & dyn AsRef < OsStr > ) ,
823+ ) ;
824+ }
825+ run_cargo_command ( & test_command, Some ( repo_path) , & project_environment, args) ?;
826+ }
827+
828+ Ok ( ( ) )
829+ } ;
761830
762831 let projects_path = Path :: new ( "projects" ) ;
763832 create_dir ( projects_path) ?;
0 commit comments