@@ -637,8 +637,8 @@ mod snapshot {
637
637
638
638
use crate :: core:: build_steps:: { compile, dist, doc, test, tool} ;
639
639
use crate :: core:: builder:: tests:: {
640
- TEST_TRIPLE_1 , TEST_TRIPLE_2 , TEST_TRIPLE_3 , configure, configure_with_args, first ,
641
- host_target, render_steps, run_build,
640
+ RenderConfig , TEST_TRIPLE_1 , TEST_TRIPLE_2 , TEST_TRIPLE_3 , configure, configure_with_args,
641
+ first , host_target, render_steps, run_build,
642
642
} ;
643
643
use crate :: core:: builder:: { Builder , Kind , StepDescription , StepMetadata } ;
644
644
use crate :: core:: config:: TargetSelection ;
@@ -1521,6 +1521,49 @@ mod snapshot {
1521
1521
steps. assert_contains ( StepMetadata :: test ( "CrateLibrustc" , host) ) ;
1522
1522
steps. assert_contains_fuzzy ( StepMetadata :: build ( "rustc" , host) ) ;
1523
1523
}
1524
+
1525
+ #[ test]
1526
+ fn doc_library ( ) {
1527
+ let ctx = TestCtx :: new ( ) ;
1528
+ insta:: assert_snapshot!(
1529
+ ctx. config( "doc" )
1530
+ . path( "library" )
1531
+ . render_steps( ) , @r"
1532
+ [build] llvm <host>
1533
+ [build] rustc 0 <host> -> rustc 1 <host>
1534
+ [build] rustdoc 0 <host>
1535
+ [doc] std 1 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,std,sysroot,test,unwind]
1536
+ " ) ;
1537
+ }
1538
+
1539
+ #[ test]
1540
+ fn doc_core ( ) {
1541
+ let ctx = TestCtx :: new ( ) ;
1542
+ insta:: assert_snapshot!(
1543
+ ctx. config( "doc" )
1544
+ . path( "core" )
1545
+ . render_steps( ) , @r"
1546
+ [build] llvm <host>
1547
+ [build] rustc 0 <host> -> rustc 1 <host>
1548
+ [build] rustdoc 0 <host>
1549
+ [doc] std 1 <host> crates=[core]
1550
+ " ) ;
1551
+ }
1552
+
1553
+ #[ test]
1554
+ fn doc_library_no_std_target ( ) {
1555
+ let ctx = TestCtx :: new ( ) ;
1556
+ insta:: assert_snapshot!(
1557
+ ctx. config( "doc" )
1558
+ . path( "core" )
1559
+ . override_target_no_std( & host_target( ) )
1560
+ . render_steps( ) , @r"
1561
+ [build] llvm <host>
1562
+ [build] rustc 0 <host> -> rustc 1 <host>
1563
+ [build] rustdoc 0 <host>
1564
+ [doc] std 1 <host> crates=[core]
1565
+ " ) ;
1566
+ }
1524
1567
}
1525
1568
1526
1569
struct ExecutedSteps {
@@ -1529,7 +1572,10 @@ struct ExecutedSteps {
1529
1572
1530
1573
impl ExecutedSteps {
1531
1574
fn render ( & self ) -> String {
1532
- render_steps ( & self . steps )
1575
+ self . render_with ( RenderConfig :: default ( ) )
1576
+ }
1577
+ fn render_with ( & self , config : RenderConfig ) -> String {
1578
+ render_steps ( & self . steps , config)
1533
1579
}
1534
1580
1535
1581
#[ track_caller]
@@ -1538,7 +1584,7 @@ impl ExecutedSteps {
1538
1584
if !self . contains ( & metadata) {
1539
1585
panic ! (
1540
1586
"Metadata `{}` ({metadata:?}) not found in executed steps:\n {}" ,
1541
- render_metadata( & metadata) ,
1587
+ render_metadata( & metadata, & RenderConfig :: default ( ) ) ,
1542
1588
self . render( )
1543
1589
) ;
1544
1590
}
@@ -1553,7 +1599,7 @@ impl ExecutedSteps {
1553
1599
if !self . contains_fuzzy ( & metadata) {
1554
1600
panic ! (
1555
1601
"Metadata `{}` ({metadata:?}) not found in executed steps:\n {}" ,
1556
- render_metadata( & metadata) ,
1602
+ render_metadata( & metadata, & RenderConfig :: default ( ) ) ,
1557
1603
self . render( )
1558
1604
) ;
1559
1605
}
@@ -1565,7 +1611,7 @@ impl ExecutedSteps {
1565
1611
if self . contains ( & metadata) {
1566
1612
panic ! (
1567
1613
"Metadata `{}` ({metadata:?}) found in executed steps (it should not be there):\n {}" ,
1568
- render_metadata( & metadata) ,
1614
+ render_metadata( & metadata, & RenderConfig :: default ( ) ) ,
1569
1615
self . render( )
1570
1616
) ;
1571
1617
}
@@ -1618,14 +1664,24 @@ impl ConfigBuilder {
1618
1664
}
1619
1665
}
1620
1666
1667
+ struct RenderConfig {
1668
+ normalize_host : bool ,
1669
+ }
1670
+
1671
+ impl Default for RenderConfig {
1672
+ fn default ( ) -> Self {
1673
+ Self { normalize_host : true }
1674
+ }
1675
+ }
1676
+
1621
1677
/// Renders the executed bootstrap steps for usage in snapshot tests with insta.
1622
1678
/// Only renders certain important steps.
1623
1679
/// Each value in `steps` should be a tuple of (Step, step output).
1624
1680
///
1625
1681
/// The arrow in the rendered output (`X -> Y`) means `X builds Y`.
1626
1682
/// This is similar to the output printed by bootstrap to stdout, but here it is
1627
1683
/// generated purely for the purpose of tests.
1628
- fn render_steps ( steps : & [ ExecutedStep ] ) -> String {
1684
+ fn render_steps ( steps : & [ ExecutedStep ] , config : RenderConfig ) -> String {
1629
1685
steps
1630
1686
. iter ( )
1631
1687
. filter_map ( |step| {
@@ -1635,35 +1691,35 @@ fn render_steps(steps: &[ExecutedStep]) -> String {
1635
1691
return None ;
1636
1692
} ;
1637
1693
1638
- Some ( render_metadata ( & metadata) )
1694
+ Some ( render_metadata ( & metadata, & config ) )
1639
1695
} )
1640
1696
. collect :: < Vec < _ > > ( )
1641
1697
. join ( "\n " )
1642
1698
}
1643
1699
1644
- fn render_metadata ( metadata : & StepMetadata ) -> String {
1700
+ fn render_metadata ( metadata : & StepMetadata , config : & RenderConfig ) -> String {
1645
1701
let mut record = format ! ( "[{}] " , metadata. kind. as_str( ) ) ;
1646
1702
if let Some ( compiler) = metadata. built_by {
1647
- write ! ( record, "{} -> " , render_compiler( compiler) ) ;
1703
+ write ! ( record, "{} -> " , render_compiler( compiler, config ) ) ;
1648
1704
}
1649
1705
let stage = metadata. get_stage ( ) . map ( |stage| format ! ( "{stage} " ) ) . unwrap_or_default ( ) ;
1650
- write ! ( record, "{} {stage}<{}>" , metadata. name, normalize_target( metadata. target) ) ;
1706
+ write ! ( record, "{} {stage}<{}>" , metadata. name, normalize_target( metadata. target, config ) ) ;
1651
1707
if let Some ( metadata) = & metadata. metadata {
1652
1708
write ! ( record, " {metadata}" ) ;
1653
1709
}
1654
1710
record
1655
1711
}
1656
1712
1657
- fn normalize_target ( target : TargetSelection ) -> String {
1658
- target
1659
- . to_string ( )
1660
- . replace ( & host_target ( ) , "host" )
1661
- . replace ( TEST_TRIPLE_1 , "target1" )
1662
- . replace ( TEST_TRIPLE_2 , "target2" )
1713
+ fn normalize_target ( target : TargetSelection , config : & RenderConfig ) -> String {
1714
+ let mut target = target . to_string ( ) ;
1715
+ if config . normalize_host {
1716
+ target = target . replace ( & host_target ( ) , "host" ) ;
1717
+ }
1718
+ target . replace ( TEST_TRIPLE_1 , "target1" ) . replace ( TEST_TRIPLE_2 , "target2" )
1663
1719
}
1664
1720
1665
- fn render_compiler ( compiler : Compiler ) -> String {
1666
- format ! ( "rustc {} <{}>" , compiler. stage, normalize_target( compiler. host) )
1721
+ fn render_compiler ( compiler : Compiler , config : & RenderConfig ) -> String {
1722
+ format ! ( "rustc {} <{}>" , compiler. stage, normalize_target( compiler. host, config ) )
1667
1723
}
1668
1724
1669
1725
fn host_target ( ) -> String {
0 commit comments