@@ -942,28 +942,6 @@ fn get_browser_ui_test_version(npm: &Path) -> Option<String> {
942942 . or_else ( || get_browser_ui_test_version_inner ( npm, true ) )
943943}
944944
945- fn compare_browser_ui_test_version ( installed_version : & str , src : & Path ) {
946- match fs:: read_to_string (
947- src. join ( "src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version" ) ,
948- ) {
949- Ok ( v) => {
950- if v. trim ( ) != installed_version {
951- eprintln ! (
952- "⚠️ Installed version of browser-ui-test (`{}`) is different than the \
953- one used in the CI (`{}`)",
954- installed_version, v
955- ) ;
956- eprintln ! (
957- "You can install this version using `npm update browser-ui-test` or by using \
958- `npm install browser-ui-test@{}`",
959- v,
960- ) ;
961- }
962- }
963- Err ( e) => eprintln ! ( "Couldn't find the CI browser-ui-test version: {:?}" , e) ,
964- }
965- }
966-
967945#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
968946pub struct RustdocGUI {
969947 pub target : TargetSelection ,
@@ -995,94 +973,56 @@ impl Step for RustdocGUI {
995973 }
996974
997975 fn run ( self , builder : & Builder < ' _ > ) {
998- let nodejs = builder. config . nodejs . as_ref ( ) . expect ( "nodejs isn't available" ) ;
999- let npm = builder. config . npm . as_ref ( ) . expect ( "npm isn't available" ) ;
1000-
1001976 builder. ensure ( compile:: Std :: new ( self . compiler , self . target ) ) ;
1002977
1003- // The goal here is to check if the necessary packages are installed, and if not, we
1004- // panic.
1005- match get_browser_ui_test_version ( & npm) {
1006- Some ( version) => {
1007- // We also check the version currently used in CI and emit a warning if it's not the
1008- // same one.
1009- compare_browser_ui_test_version ( & version, & builder. build . src ) ;
1010- }
1011- None => {
1012- eprintln ! (
1013- "error: rustdoc-gui test suite cannot be run because npm `browser-ui-test` \
1014- dependency is missing",
1015- ) ;
1016- eprintln ! (
1017- "If you want to install the `{0}` dependency, run `npm install {0}`" ,
1018- "browser-ui-test" ,
1019- ) ;
1020- panic ! ( "Cannot run rustdoc-gui tests" ) ;
1021- }
1022- }
978+ let mut cmd = builder. tool_cmd ( Tool :: RustdocGUITest ) ;
1023979
1024980 let out_dir = builder. test_out ( self . target ) . join ( "rustdoc-gui" ) ;
1025-
1026- // We remove existing folder to be sure there won't be artifacts remaining.
1027981 builder. clear_if_dirty ( & out_dir, & builder. rustdoc ( self . compiler ) ) ;
1028982
1029- let src_path = builder. build . src . join ( "tests/rustdoc-gui/src" ) ;
1030- // We generate docs for the libraries present in the rustdoc-gui's src folder.
1031- for entry in src_path. read_dir ( ) . expect ( "read_dir call failed" ) {
1032- if let Ok ( entry) = entry {
1033- let path = entry. path ( ) ;
983+ if let Some ( src) = builder. config . src . to_str ( ) {
984+ cmd. arg ( "--rust-src" ) . arg ( src) ;
985+ }
1034986
1035- if !path . is_dir ( ) {
1036- continue ;
1037- }
987+ if let Some ( out_dir ) = out_dir . to_str ( ) {
988+ cmd . arg ( "--out-dir" ) . arg ( out_dir ) ;
989+ }
1038990
1039- let mut cargo = Command :: new ( & builder. initial_cargo ) ;
1040- cargo
1041- . arg ( "doc" )
1042- . arg ( "--target-dir" )
1043- . arg ( & out_dir)
1044- . env ( "RUSTC_BOOTSTRAP" , "1" )
1045- . env ( "RUSTDOC" , builder. rustdoc ( self . compiler ) )
1046- . env ( "RUSTC" , builder. rustc ( self . compiler ) )
1047- . current_dir ( path) ;
1048- // FIXME: implement a `// compile-flags` command or similar
1049- // instead of hard-coding this test
1050- if entry. file_name ( ) == "link_to_definition" {
1051- cargo. env ( "RUSTDOCFLAGS" , "-Zunstable-options --generate-link-to-definition" ) ;
1052- } else if entry. file_name ( ) == "scrape_examples" {
1053- cargo. arg ( "-Zrustdoc-scrape-examples" ) ;
1054- } else if entry. file_name ( ) == "extend_css" {
1055- cargo. env ( "RUSTDOCFLAGS" , & format ! ( "--extend-css extra.css" ) ) ;
1056- }
1057- builder. run ( & mut cargo) ;
1058- }
991+ if let Some ( initial_cargo) = builder. config . initial_cargo . to_str ( ) {
992+ cmd. arg ( "--initial-cargo" ) . arg ( initial_cargo) ;
1059993 }
1060994
1061- // We now run GUI tests.
1062- let mut command = Command :: new ( & nodejs) ;
1063- command
1064- . arg ( builder. build . src . join ( "src/tools/rustdoc-gui/tester.js" ) )
1065- . arg ( "--jobs" )
1066- . arg ( & builder. jobs ( ) . to_string ( ) )
1067- . arg ( "--doc-folder" )
1068- . arg ( out_dir. join ( "doc" ) )
1069- . arg ( "--tests-folder" )
1070- . arg ( builder. build . src . join ( "tests/rustdoc-gui" ) ) ;
995+ cmd. arg ( "--jobs" ) . arg ( builder. jobs ( ) . to_string ( ) ) ;
996+
997+ cmd. env ( "RUSTDOC" , builder. rustdoc ( self . compiler ) )
998+ . env ( "RUSTC" , builder. rustc ( self . compiler ) ) ;
999+
10711000 for path in & builder. paths {
10721001 if let Some ( p) = util:: is_valid_test_suite_arg ( path, "tests/rustdoc-gui" , builder) {
10731002 if !p. ends_with ( ".goml" ) {
10741003 eprintln ! ( "A non-goml file was given: `{}`" , path. display( ) ) ;
10751004 panic ! ( "Cannot run rustdoc-gui tests" ) ;
10761005 }
10771006 if let Some ( name) = path. file_name ( ) . and_then ( |f| f. to_str ( ) ) {
1078- command . arg ( "--file" ) . arg ( name) ;
1007+ cmd . arg ( "--goml -file" ) . arg ( name) ;
10791008 }
10801009 }
10811010 }
1011+
10821012 for test_arg in builder. config . test_args ( ) {
1083- command . arg ( test_arg) ;
1013+ cmd . arg ( "--test-arg" ) . arg ( test_arg) ;
10841014 }
1085- builder. run ( & mut command) ;
1015+
1016+ if let Some ( ref nodejs) = builder. config . nodejs {
1017+ cmd. arg ( "--nodejs" ) . arg ( nodejs) ;
1018+ }
1019+
1020+ if let Some ( ref npm) = builder. config . npm {
1021+ cmd. arg ( "--npm" ) . arg ( npm) ;
1022+ }
1023+
1024+ let _time = util:: timeit ( & builder) ;
1025+ crate :: render_tests:: try_run_tests ( builder, & mut cmd) ;
10861026 }
10871027}
10881028
0 commit comments