@@ -688,6 +688,78 @@ impl Step for RustdocJSNotStd {
688
688
}
689
689
}
690
690
691
+ #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
692
+ pub struct RustdocGUI {
693
+ pub target : TargetSelection ,
694
+ pub compiler : Compiler ,
695
+ }
696
+
697
+ impl Step for RustdocGUI {
698
+ type Output = ( ) ;
699
+ const DEFAULT : bool = true ;
700
+ const ONLY_HOSTS : bool = true ;
701
+
702
+ fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
703
+ run. path ( "src/test/rustdoc-gui" )
704
+ }
705
+
706
+ fn make_run ( run : RunConfig < ' _ > ) {
707
+ let compiler = run. builder . compiler ( run. builder . top_stage , run. build_triple ( ) ) ;
708
+ run. builder . ensure ( RustdocGUI { target : run. target , compiler } ) ;
709
+ }
710
+
711
+ fn run ( self , builder : & Builder < ' _ > ) {
712
+ if let ( Some ( nodejs) , Some ( npm) ) = ( & builder. config . nodejs , & builder. config . npm ) {
713
+ builder. ensure ( compile:: Std { compiler : self . compiler , target : self . target } ) ;
714
+
715
+ // The goal here is to check if the necessary packages are installed, and if not, we
716
+ // display a warning and move on.
717
+ let mut command = Command :: new ( & npm) ;
718
+ command. arg ( "list" ) . arg ( "--depth=0" ) ;
719
+ let lines = command
720
+ . output ( )
721
+ . map ( |output| String :: from_utf8_lossy ( & output. stdout ) . to_string ( ) )
722
+ . unwrap_or ( String :: new ( ) ) ;
723
+ if !lines. contains ( & " browser-ui-test@" ) {
724
+ println ! (
725
+ "warning: rustdoc-gui test suite cannot be run because npm `browser-ui-test` \
726
+ dependency is missing",
727
+ ) ;
728
+ println ! (
729
+ "If you want to install the `{0}` dependency, run `npm install {0}`" ,
730
+ "browser-ui-test" ,
731
+ ) ;
732
+ return ;
733
+ }
734
+
735
+ let out_dir = builder. test_out ( self . target ) . join ( "rustdoc-gui" ) ;
736
+ let mut command = builder. rustdoc_cmd ( self . compiler ) ;
737
+ command. arg ( "src/test/rustdoc-gui/lib.rs" ) . arg ( "-o" ) . arg ( & out_dir) ;
738
+ builder. run ( & mut command) ;
739
+
740
+ for file in fs:: read_dir ( "src/test/rustdoc-gui" ) . unwrap ( ) {
741
+ let file = file. unwrap ( ) ;
742
+ let file_path = file. path ( ) ;
743
+ let file_name = file. file_name ( ) ;
744
+
745
+ if !file_name. to_str ( ) . unwrap ( ) . ends_with ( ".goml" ) {
746
+ continue ;
747
+ }
748
+ let mut command = Command :: new ( & nodejs) ;
749
+ command
750
+ . arg ( "src/tools/rustdoc-gui/tester.js" )
751
+ . arg ( "--doc-folder" )
752
+ . arg ( out_dir. join ( "test_docs" ) )
753
+ . arg ( "--test-file" )
754
+ . arg ( file_path) ;
755
+ builder. run ( & mut command) ;
756
+ }
757
+ } else {
758
+ builder. info ( "No nodejs found, skipping \" src/test/rustdoc-gui\" tests" ) ;
759
+ }
760
+ }
761
+ }
762
+
691
763
#[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
692
764
pub struct Tidy ;
693
765
@@ -1048,6 +1120,9 @@ note: if you're sure you want to do this, please open an issue as to why. In the
1048
1120
if let Some ( ref nodejs) = builder. config . nodejs {
1049
1121
cmd. arg ( "--nodejs" ) . arg ( nodejs) ;
1050
1122
}
1123
+ if let Some ( ref npm) = builder. config . npm {
1124
+ cmd. arg ( "--npm" ) . arg ( npm) ;
1125
+ }
1051
1126
1052
1127
let mut flags = if is_rustdoc { Vec :: new ( ) } else { vec ! [ "-Crpath" . to_string( ) ] } ;
1053
1128
if !is_rustdoc {
0 commit comments