@@ -4617,7 +4617,7 @@ impl CommandLineStep for RemoteTestClientTests {
46174617}
46184618
46194619fn check_if_cargo_semver_checks_is_installed ( builder : & Builder < ' _ > ) -> bool {
4620- command ( "cargo" )
4620+ command ( & builder . initial_cargo )
46214621 . allow_failure ( )
46224622 . arg ( "semver-checks" )
46234623 . arg ( "--version" )
@@ -4630,6 +4630,9 @@ fn check_if_cargo_semver_checks_is_installed(builder: &Builder<'_>) -> bool {
46304630/// Run cargo-semver-checks on the standard library and compare its API
46314631/// versus a previous baseline, using rustdoc JSON data.
46324632///
4633+ /// The baseline commit can be configured using `rust.stdlib-semver-baseline`.
4634+ /// If unset, the first upstream parent commit will be used.
4635+ ///
46334636/// Fails if a semver-breaking change is detected.
46344637#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
46354638pub struct StdSemverCheck {
@@ -4651,19 +4654,22 @@ impl CommandLineStep for StdSemverCheck {
46514654 panic ! ( "cargo-semver-checks was not found, please install it" ) ;
46524655 }
46534656
4654- let baseline_commit = match get_closest_upstream_commit (
4655- Some ( & run. builder . config . src ) ,
4656- & run. builder . config . git_config ( ) ,
4657- run. builder . config . ci_env ,
4658- ) {
4659- Ok ( Some ( commit) ) => commit,
4660- Ok ( None ) => {
4661- panic ! ( "No baseline parent commit found for std-semver-check" ) ;
4662- }
4663- Err ( error) => {
4664- panic ! ( "Cannot get baseline parent commit for std-semver-check: {error:?}" ) ;
4665- }
4666- } ;
4657+ let baseline_commit =
4658+ run. builder . config . stdlib_semver_baseline . clone ( ) . unwrap_or_else ( || {
4659+ match get_closest_upstream_commit (
4660+ Some ( & run. builder . config . src ) ,
4661+ & run. builder . config . git_config ( ) ,
4662+ run. builder . config . ci_env ,
4663+ ) {
4664+ Ok ( Some ( commit) ) => commit,
4665+ Ok ( None ) => {
4666+ panic ! ( "No baseline parent commit found for std-semver-check" ) ;
4667+ }
4668+ Err ( error) => {
4669+ panic ! ( "Cannot get baseline parent commit for std-semver-check: {error:?}" ) ;
4670+ }
4671+ }
4672+ } ) ;
46674673
46684674 run. builder . ensure ( Self {
46694675 build_compiler : run. builder . compiler_for_std ( run. builder . top_stage ) ,
@@ -4687,7 +4693,7 @@ impl CommandLineStep for StdSemverCheck {
46874693
46884694 for library in [ "core" , "alloc" , "std" ] {
46894695 println ! ( "Checking semver compatibility of {library}" ) ;
4690- let mut cmd = command ( "cargo" ) ;
4696+ let mut cmd = command ( & builder . initial_cargo ) ;
46914697 cmd. arg ( "semver-checks" )
46924698 . arg ( "-Z" )
46934699 . arg ( "unstable-options" )
@@ -4698,7 +4704,41 @@ impl CommandLineStep for StdSemverCheck {
46984704 . arg ( directory. join ( format ! ( "{library}.json" ) ) )
46994705 . arg ( "--baseline-rustdoc" )
47004706 . arg ( baseline_dir. join ( format ! ( "{library}.json" ) ) ) ;
4701- cmd. run ( builder) ;
4707+
4708+ // We use run_capture to get the exit status
4709+ let res = cmd. allow_failure ( ) . run_capture ( builder) ;
4710+ match res. status ( ) {
4711+ Some ( status) if status. success ( ) => {
4712+ println ! ( "{}\n {}" , res. stdout( ) , res. stderr( ) ) ;
4713+ }
4714+ // 101 marks that csc was unable to parse the JSON data, but it did not fail with a
4715+ // semver breakage.
4716+ Some ( status) if status. code ( ) == Some ( 101 ) => {
4717+ eprintln ! (
4718+ "cargo-semver-checks was unable to process {library} (this is not a fatal error)\n {}\n {}" ,
4719+ res. stderr( ) ,
4720+ res. stdout( )
4721+ ) ;
4722+ }
4723+ // 100 marks semver breakage
4724+ Some ( status) if status. code ( ) == Some ( 100 ) => {
4725+ let error = format ! (
4726+ "cargo-semver-checks found semver breakage in {library}\n {}\n {}" ,
4727+ res. stderr( ) ,
4728+ res. stdout( )
4729+ ) ;
4730+ if builder. fail_fast {
4731+ eprintln ! ( "{error}" , ) ;
4732+ exit ! ( 1 ) ;
4733+ } else {
4734+ builder. config . exec_ctx ( ) . add_to_delay_failure ( error) ;
4735+ }
4736+ }
4737+ _ => {
4738+ eprintln ! ( "cargo-semver-checks failed.\n {}\n {}" , res. stderr( ) , res. stdout( ) ) ;
4739+ exit ! ( 1 ) ;
4740+ }
4741+ }
47024742 }
47034743 }
47044744}
0 commit comments