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,55 @@ 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" ,
686
+ "https://github.com/rust-random/getrandom" ,
687
+ "https://github.com/BurntSushi/memchr" ,
688
+ "https://github.com/dtolnay/itoa" ,
689
+ "https://github.com/rust-lang/cfg-if" ,
690
+ "https://github.com/rust-lang-nursery/lazy-static.rs" ,
691
+ //"https://github.com/marshallpierce/rust-base64", // FIXME: one test is OOM-killed.
692
+ // TODO: ignore the base64 test that is OOM-killed.
693
+ "https://github.com/time-rs/time" ,
694
+ "https://github.com/rust-lang/log" ,
695
+ "https://github.com/bitflags/bitflags" ,
696
+ //"https://github.com/serde-rs/serde", // FIXME: one test fails.
697
+ //"https://github.com/rayon-rs/rayon", // TODO: very slow, only run on master?
698
+ //"https://github.com/rust-lang/cargo", // TODO: very slow, only run on master?
699
+ ] ;
700
+
701
+ let run_tests = |iter : & mut dyn Iterator < Item =& & str > | -> Result < ( ) , String > {
702
+ for project in iter {
703
+ let projects_path = Path :: new ( "projects" ) ;
704
+ create_dir_all ( projects_path)
705
+ . map_err ( |err| format ! ( "Failed to create directory `projects`: {}" , err) ) ?;
706
+ let clone_result = git_clone ( project, Some ( projects_path) , true ) ?;
707
+ let repo_path = Path :: new ( & clone_result. repo_dir ) ;
708
+ run_cargo_command ( & [ & "build" , & "--release" ] , Some ( repo_path) , env, args) ?;
709
+ run_cargo_command ( & [ & "test" ] , Some ( repo_path) , env, args) ?;
710
+ }
711
+
712
+ Ok ( ( ) )
713
+ } ;
714
+
715
+ let nb_parts = args. nb_parts . unwrap_or ( 0 ) ;
716
+ if nb_parts > 0 {
717
+ // We increment the number of tests by one because if this is an odd number, we would skip
718
+ // one test.
719
+ let count = projects. len ( ) / nb_parts + 1 ;
720
+ let current_part = args. current_part . unwrap ( ) ;
721
+ let start = current_part * count;
722
+ // We remove the projects we don't want to test.
723
+ run_tests ( & mut projects. iter ( ) . skip ( start) . take ( count) ) ?;
724
+ }
725
+ else {
726
+ run_tests ( & mut projects. iter ( ) ) ?;
727
+ }
728
+
729
+ Ok ( ( ) )
730
+ }
731
+
682
732
fn test_libcore ( env : & Env , args : & TestArg ) -> Result < ( ) , String > {
683
733
// FIXME: create a function "display_if_not_quiet" or something along the line.
684
734
println ! ( "[TEST] libcore" ) ;
0 commit comments