1
1
use crate :: build;
2
2
use crate :: config:: { Channel , ConfigInfo } ;
3
3
use crate :: utils:: {
4
- get_gcc_path, get_toolchain, remove_file, run_command, run_command_with_env,
4
+ get_gcc_path, get_toolchain, git_clone , remove_file, run_command, run_command_with_env,
5
5
run_command_with_output_and_env, rustc_version_info, split_args, walk_dir,
6
6
} ;
7
7
8
8
use std:: collections:: { BTreeSet , HashMap } ;
9
9
use std:: ffi:: OsStr ;
10
- use std:: fs:: { remove_dir_all, File } ;
10
+ use std:: fs:: { create_dir_all , remove_dir_all, File } ;
11
11
use std:: io:: { BufRead , BufReader } ;
12
12
use std:: path:: { Path , PathBuf } ;
13
13
use std:: str:: FromStr ;
@@ -31,6 +31,7 @@ fn get_runners() -> Runners {
31
31
"--test-failing-rustc" ,
32
32
( "Run failing rustc tests" , test_failing_rustc) ,
33
33
) ;
34
+ runners. insert ( "--projects" , ( "Run the tests of popular crates" , test_projects) ) ;
34
35
runners. insert ( "--test-libcore" , ( "Run libcore tests" , test_libcore) ) ;
35
36
runners. insert ( "--clean" , ( "Empty cargo target directory" , clean) ) ;
36
37
runners. insert ( "--build-sysroot" , ( "Build sysroot" , build_sysroot) ) ;
@@ -679,6 +680,57 @@ where
679
680
// echo "[BUILD] sysroot in release mode"
680
681
// ./build_sysroot/build_sysroot.sh --release
681
682
683
+ fn test_projects ( env : & Env , args : & TestArg ) -> Result < ( ) , String > {
684
+ let projects = [
685
+ //"https://gitlab.gnome.org/GNOME/librsvg", // FIXME: doesn't compile in the CI since the
686
+ // version of cairo and other libraries is too old.
687
+ "https://github.com/rust-random/getrandom" ,
688
+ "https://github.com/BurntSushi/memchr" ,
689
+ "https://github.com/dtolnay/itoa" ,
690
+ "https://github.com/rust-lang/cfg-if" ,
691
+ "https://github.com/rust-lang-nursery/lazy-static.rs" ,
692
+ //"https://github.com/marshallpierce/rust-base64", // FIXME: one test is OOM-killed.
693
+ // TODO: ignore the base64 test that is OOM-killed.
694
+ "https://github.com/time-rs/time" ,
695
+ "https://github.com/rust-lang/log" ,
696
+ "https://github.com/bitflags/bitflags" ,
697
+ //"https://github.com/serde-rs/serde", // FIXME: one test fails.
698
+ //"https://github.com/rayon-rs/rayon", // TODO: very slow, only run on master?
699
+ //"https://github.com/rust-lang/cargo", // TODO: very slow, only run on master?
700
+ ] ;
701
+
702
+ let run_tests = |projects_path, iter : & mut dyn Iterator < Item =& & str > | -> Result < ( ) , String > {
703
+ for project in iter {
704
+ let clone_result = git_clone ( project, Some ( projects_path) , true ) ?;
705
+ let repo_path = Path :: new ( & clone_result. repo_dir ) ;
706
+ run_cargo_command ( & [ & "build" , & "--release" ] , Some ( repo_path) , env, args) ?;
707
+ run_cargo_command ( & [ & "test" ] , Some ( repo_path) , env, args) ?;
708
+ }
709
+
710
+ Ok ( ( ) )
711
+ } ;
712
+
713
+ let projects_path = Path :: new ( "projects" ) ;
714
+ create_dir_all ( projects_path)
715
+ . map_err ( |err| format ! ( "Failed to create directory `projects`: {}" , err) ) ?;
716
+
717
+ let nb_parts = args. nb_parts . unwrap_or ( 0 ) ;
718
+ if nb_parts > 0 {
719
+ // We increment the number of tests by one because if this is an odd number, we would skip
720
+ // one test.
721
+ let count = projects. len ( ) / nb_parts + 1 ;
722
+ let current_part = args. current_part . unwrap ( ) ;
723
+ let start = current_part * count;
724
+ // We remove the projects we don't want to test.
725
+ run_tests ( projects_path, & mut projects. iter ( ) . skip ( start) . take ( count) ) ?;
726
+ }
727
+ else {
728
+ run_tests ( projects_path, & mut projects. iter ( ) ) ?;
729
+ }
730
+
731
+ Ok ( ( ) )
732
+ }
733
+
682
734
fn test_libcore ( env : & Env , args : & TestArg ) -> Result < ( ) , String > {
683
735
// FIXME: create a function "display_if_not_quiet" or something along the line.
684
736
println ! ( "[TEST] libcore" ) ;
0 commit comments