@@ -836,22 +836,39 @@ impl Step for RustdocJSNotStd {
836836 }
837837}
838838
839- fn check_if_browser_ui_test_is_installed_global ( npm : & Path , global : bool ) -> bool {
839+ fn get_browser_ui_test_version_inner ( npm : & Path , global : bool ) -> Option < String > {
840840 let mut command = Command :: new ( & npm) ;
841- command. arg ( "list" ) . arg ( "--depth=0" ) ;
841+ command. arg ( "list" ) . arg ( "--parseable" ) . arg ( "--long" ) . arg ( "-- depth=0") ;
842842 if global {
843843 command. arg ( "--global" ) ;
844844 }
845845 let lines = command
846846 . output ( )
847847 . map ( |output| String :: from_utf8_lossy ( & output. stdout ) . into_owned ( ) )
848848 . unwrap_or ( String :: new ( ) ) ;
849- lines. contains ( & " browser-ui-test@")
849+ lines. lines ( ) . find_map ( |l| l . split ( ": browser-ui-test@") . skip ( 1 ) . next ( ) ) . map ( |v| v . to_owned ( ) )
850850}
851851
852- fn check_if_browser_ui_test_is_installed ( npm : & Path ) -> bool {
853- check_if_browser_ui_test_is_installed_global ( npm, false )
854- || check_if_browser_ui_test_is_installed_global ( npm, true )
852+ fn get_browser_ui_test_version ( npm : & Path ) -> Option < String > {
853+ get_browser_ui_test_version_inner ( npm, false )
854+ . or_else ( || get_browser_ui_test_version_inner ( npm, true ) )
855+ }
856+
857+ fn compare_browser_ui_test_version ( installed_version : & str , src : & Path ) {
858+ match fs:: read_to_string (
859+ src. join ( "src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version" ) ,
860+ ) {
861+ Ok ( v) => {
862+ if v. trim ( ) != installed_version {
863+ eprintln ! (
864+ "⚠️ Installed version of browser-ui-test (`{}`) is different than the \
865+ one used in the CI (`{}`)",
866+ installed_version, v
867+ ) ;
868+ }
869+ }
870+ Err ( e) => eprintln ! ( "Couldn't find the CI browser-ui-test version: {:?}" , e) ,
871+ }
855872}
856873
857874#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
@@ -874,7 +891,7 @@ impl Step for RustdocGUI {
874891 . config
875892 . npm
876893 . as_ref ( )
877- . map ( |p| check_if_browser_ui_test_is_installed ( p ) )
894+ . map ( |p| get_browser_ui_test_version ( p ) . is_some ( ) )
878895 . unwrap_or ( false )
879896 } ) )
880897 }
@@ -892,16 +909,23 @@ impl Step for RustdocGUI {
892909
893910 // The goal here is to check if the necessary packages are installed, and if not, we
894911 // panic.
895- if !check_if_browser_ui_test_is_installed ( & npm) {
896- eprintln ! (
897- "error: rustdoc-gui test suite cannot be run because npm `browser-ui-test` \
898- dependency is missing",
899- ) ;
900- eprintln ! (
901- "If you want to install the `{0}` dependency, run `npm install {0}`" ,
902- "browser-ui-test" ,
903- ) ;
904- panic ! ( "Cannot run rustdoc-gui tests" ) ;
912+ match get_browser_ui_test_version ( & npm) {
913+ Some ( version) => {
914+ // We also check the version currently used in CI and emit a warning if it's not the
915+ // same one.
916+ compare_browser_ui_test_version ( & version, & builder. build . src ) ;
917+ }
918+ None => {
919+ eprintln ! (
920+ "error: rustdoc-gui test suite cannot be run because npm `browser-ui-test` \
921+ dependency is missing",
922+ ) ;
923+ eprintln ! (
924+ "If you want to install the `{0}` dependency, run `npm install {0}`" ,
925+ "browser-ui-test" ,
926+ ) ;
927+ panic ! ( "Cannot run rustdoc-gui tests" ) ;
928+ }
905929 }
906930
907931 let out_dir = builder. test_out ( self . target ) . join ( "rustdoc-gui" ) ;
0 commit comments