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