Skip to content

Commit

Permalink
add tests for behavior in rfc#3662
Browse files Browse the repository at this point in the history
* Adds tests for the behavior from rfc#3662 in `tests/rustdoc/`
  • Loading branch information
EtomicBomb committed Sep 7, 2024
1 parent 2e1cba6 commit 548b6e1
Show file tree
Hide file tree
Showing 41 changed files with 501 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//@ doc-flags:--merge=shared
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

pub struct Quebec;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@ aux-build:quebec.rs
//@ build-aux-docs
//@ doc-flags:--merge=shared
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

extern crate quebec;
pub trait Tango {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//@ aux-build:tango.rs
//@ build-aux-docs
//@ doc-flags:--merge=shared
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

//@ has index.html
//@ has index.html '//h1' 'List of all crates'
//@ has index.html '//ul[@class="all-items"]//a[@href="quebec/index.html"]' 'quebec'
//@ has index.html '//ul[@class="all-items"]//a[@href="sierra/index.html"]' 'sierra'
//@ has index.html '//ul[@class="all-items"]//a[@href="tango/index.html"]' 'tango'
//@ has quebec/struct.Quebec.html
//@ has sierra/struct.Sierra.html
//@ has tango/trait.Tango.html
//@ hasraw sierra/struct.Sierra.html 'Tango'
//@ hasraw trait.impl/tango/trait.Tango.js 'struct.Sierra.html'
//@ hasraw search-index.js 'Tango'
//@ hasraw search-index.js 'Sierra'
//@ hasraw search-index.js 'Quebec'

// similar to cargo-workflow-transitive, but we use --merge=read-write,
// which is the default.
extern crate tango;
pub struct Sierra;
impl tango::Tango for Sierra {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//@ unique-doc-out-dir
//@ doc-flags:--merge=none
//@ doc-flags:--parts-out-dir=info/doc.parts/quebec
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

pub struct Quebec;
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//@ aux-build:sierra.rs
//@ build-aux-docs
//@ unique-doc-out-dir
//@ doc-flags:--merge=none
//@ doc-flags:--parts-out-dir=info/doc.parts/romeo
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

extern crate sierra;
pub type Romeo = sierra::Sierra;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@ aux-build:tango.rs
//@ build-aux-docs
//@ unique-doc-out-dir
//@ doc-flags:--merge=none
//@ doc-flags:--parts-out-dir=info/doc.parts/sierra
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

extern crate tango;
pub struct Sierra;
impl tango::Tango for Sierra {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//@ aux-build:quebec.rs
//@ build-aux-docs
//@ unique-doc-out-dir
//@ doc-flags:--merge=none
//@ doc-flags:--parts-out-dir=info/doc.parts/tango
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

extern crate quebec;
pub trait Tango {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//@ aux-build:tango.rs
//@ aux-build:romeo.rs
//@ aux-build:quebec.rs
//@ aux-build:sierra.rs
//@ build-aux-docs
//@ doc-flags:--merge=finalize
//@ doc-flags:--include-parts-dir=info/doc.parts/tango
//@ doc-flags:--include-parts-dir=info/doc.parts/romeo
//@ doc-flags:--include-parts-dir=info/doc.parts/quebec
//@ doc-flags:--include-parts-dir=info/doc.parts/sierra
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

//@ has index.html '//h1' 'List of all crates'
//@ has index.html
//@ has index.html '//ul[@class="all-items"]//a[@href="indigo/index.html"]' 'indigo'
//@ has index.html '//ul[@class="all-items"]//a[@href="quebec/index.html"]' 'quebec'
//@ has index.html '//ul[@class="all-items"]//a[@href="romeo/index.html"]' 'romeo'
//@ has index.html '//ul[@class="all-items"]//a[@href="sierra/index.html"]' 'sierra'
//@ has index.html '//ul[@class="all-items"]//a[@href="tango/index.html"]' 'tango'
//@ !has quebec/struct.Quebec.html
//@ !has romeo/type.Romeo.html
//@ !has sierra/struct.Sierra.html
//@ !has tango/trait.Tango.html
//@ hasraw trait.impl/tango/trait.Tango.js 'struct.Sierra.html'
//@ hasraw search-index.js 'Quebec'
//@ hasraw search-index.js 'Romeo'
//@ hasraw search-index.js 'Sierra'
//@ hasraw search-index.js 'Tango'
//@ has type.impl/sierra/struct.Sierra.js
//@ hasraw type.impl/sierra/struct.Sierra.js 'Tango'
//@ hasraw type.impl/sierra/struct.Sierra.js 'Romeo'

// document everything in the default mode, there are separate out
// directories that are linked together
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//@ unique-doc-out-dir
//@ doc-flags:--merge=none
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

pub struct Quebec;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//@ aux-build:quebec.rs
//@ build-aux-docs
//@ unique-doc-out-dir
//@ doc-flags:--merge=none
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

extern crate quebec;
pub trait Tango {}
17 changes: 17 additions & 0 deletions tests/rustdoc/merge-cross-crate-info/no-merge-separate/sierra.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//@ aux-build:tango.rs
//@ build-aux-docs
//@ doc-flags:--merge=none
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

//@ !has index.html
//@ has sierra/struct.Sierra.html
//@ hasraw sierra/struct.Sierra.html 'Tango'
//@ !has trait.impl/tango/trait.Tango.js
//@ !has search-index.js

// we don't generate any cross-crate info if --merge=none, even if we
// document crates separately
extern crate tango;
pub struct Sierra;
impl tango::Tango for Sierra {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//@ doc-flags:--merge=none
//@ doc-flags:--parts-out-dir=info/doc.parts/quebec
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

pub struct Quebec;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//@ aux-build:quebec.rs
//@ build-aux-docs
//@ doc-flags:--merge=none
//@ doc-flags:--parts-out-dir=info/doc.parts/tango
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

extern crate quebec;
pub trait Tango {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//@ aux-build:tango.rs
//@ build-aux-docs
//@ doc-flags:--merge=none
//@ doc-flags:--parts-out-dir=info/doc.parts/sierra
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

//@ !has index.html
//@ has sierra/struct.Sierra.html
//@ has tango/trait.Tango.html
//@ hasraw sierra/struct.Sierra.html 'Tango'
//@ !has trait.impl/tango/trait.Tango.js
//@ !has search-index.js

// we --merge=none, so --parts-out-dir doesn't do anything
extern crate tango;
pub struct Sierra;
impl tango::Tango for Sierra {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//@ doc-flags:--merge=none
//@ doc-flags:--parts-out-dir=info/doc.parts/quebec
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

pub struct Quebec;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//@ aux-build:quebec.rs
//@ build-aux-docs
//@ doc-flags:--merge=none
//@ doc-flags:--parts-out-dir=info/doc.parts/tango
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

extern crate quebec;
pub trait Tango {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//@ aux-build:tango.rs
//@ build-aux-docs
//@ doc-flags:--merge=finalize
//@ doc-flags:--include-parts-dir=info/doc.parts/tango
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

//@ has quebec/struct.Quebec.html
//@ has sierra/struct.Sierra.html
//@ has tango/trait.Tango.html
//@ hasraw sierra/struct.Sierra.html 'Tango'
//@ hasraw trait.impl/tango/trait.Tango.js 'struct.Sierra.html'
//@ hasraw search-index.js 'Tango'
//@ hasraw search-index.js 'Sierra'
//@ !hasraw search-index.js 'Quebec'

// we overwrite quebec and tango's cross-crate information, but we
// include the info from tango meaning that it should appear in the out
// dir
extern crate tango;
pub struct Sierra;
impl tango::Tango for Sierra {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//@ unique-doc-out-dir
//@ doc-flags:--merge=none
//@ doc-flags:--parts-out-dir=info/doc.parts/quebec
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

pub struct Quebec;
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//@ aux-build:quebec.rs
//@ build-aux-docs
//@ unique-doc-out-dir
//@ doc-flags:--merge=none
//@ doc-flags:--parts-out-dir=info/doc.parts/tango
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

extern crate quebec;
pub trait Tango {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//@ aux-build:tango.rs
//@ build-aux-docs
//@ doc-flags:--merge=finalize
//@ doc-flags:--include-parts-dir=info/doc.parts/tango
//@ doc-flags:--include-parts-dir=info/doc.parts/quebec
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

//@ has index.html
//@ has index.html '//h1' 'List of all crates'
//@ has index.html '//ul[@class="all-items"]//a[@href="quebec/index.html"]' 'quebec'
//@ has index.html '//ul[@class="all-items"]//a[@href="sierra/index.html"]' 'sierra'
//@ has index.html '//ul[@class="all-items"]//a[@href="tango/index.html"]' 'tango'
//@ has sierra/struct.Sierra.html
//@ hasraw trait.impl/tango/trait.Tango.js 'struct.Sierra.html'
//@ hasraw search-index.js 'Tango'
//@ hasraw search-index.js 'Sierra'
//@ hasraw search-index.js 'Quebec'

// If these were documeted into the same directory, the info would be
// overwritten. However, since they are merged, we can still recover all
// of the cross-crate information
extern crate tango;
pub struct Sierra;
impl tango::Tango for Sierra {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//@ doc-flags:--merge=none
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

pub struct Quebec;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@ aux-build:quebec.rs
//@ build-aux-docs
//@ doc-flags:--merge=finalize
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

extern crate quebec;
pub trait Tango {}
20 changes: 20 additions & 0 deletions tests/rustdoc/merge-cross-crate-info/overwrite/sierra.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//@ aux-build:tango.rs
//@ build-aux-docs
//@ doc-flags:--merge=shared
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

//@ has quebec/struct.Quebec.html
//@ has sierra/struct.Sierra.html
//@ has tango/trait.Tango.html
//@ hasraw sierra/struct.Sierra.html 'Tango'
//@ hasraw trait.impl/tango/trait.Tango.js 'struct.Sierra.html'
//@ hasraw search-index.js 'Tango'
//@ hasraw search-index.js 'Sierra'
//@ !hasraw search-index.js 'Quebec'

// since tango is documented with --merge=finalize, we overwrite q's
// cross-crate information
extern crate tango;
pub struct Sierra;
impl tango::Tango for Sierra {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//@ doc-flags:--merge=finalize
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

//@ has index.html
//@ has index.html '//h1' 'List of all crates'
//@ has index.html '//ul[@class="all-items"]//a[@href="quebec/index.html"]' 'quebec'
//@ has quebec/struct.Quebec.html
//@ hasraw search-index.js 'Quebec'

// there is nothing to read from the output directory if we use a single
// crate
pub struct Quebec;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@ doc-flags:--merge=shared
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

//@ has index.html
//@ has index.html '//h1' 'List of all crates'
//@ has index.html '//ul[@class="all-items"]//a[@href="quebec/index.html"]' 'quebec'
//@ has quebec/struct.Quebec.html
//@ hasraw search-index.js 'Quebec'

// read-write is the default and this does the same as `single-crate`
pub struct Quebec;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//@ doc-flags:--parts-out-dir=info/doc.parts/quebec
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

//@ has index.html
//@ has index.html '//h1' 'List of all crates'
//@ has index.html '//ul[@class="all-items"]//a[@href="quebec/index.html"]' 'quebec'
//@ has quebec/struct.Quebec.html
//@ hasraw search-index.js 'Quebec'

// we can --parts-out-dir, but that doesn't do anything other than create
// the file
pub struct Quebec;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@ doc-flags:--merge=none
//@ doc-flags:--parts-out-dir=info/doc.parts/quebec
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

//@ !has index.html
//@ has quebec/struct.Quebec.html
//@ !has search-index.js

// --merge=none doesn't write anything, despite --parts-out-dir
pub struct Quebec;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//@ doc-flags:--merge=finalize
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

pub struct Quebec;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@ aux-build:quebec.rs
//@ build-aux-docs
//@ doc-flags:--merge=finalize
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

extern crate quebec;
pub trait Tango {}
20 changes: 20 additions & 0 deletions tests/rustdoc/merge-cross-crate-info/transitive-finalize/sierra.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//@ aux-build:tango.rs
//@ build-aux-docs
//@ doc-flags:--merge=finalize
//@ doc-flags:--enable-index-page
//@ doc-flags:-Zunstable-options

//@ has index.html
//@ has index.html '//h1' 'List of all crates'
//@ has index.html '//ul[@class="all-items"]//a[@href="sierra/index.html"]' 'sierra'
//@ has index.html '//ul[@class="all-items"]//a[@href="tango/index.html"]' 'tango'
//@ has sierra/struct.Sierra.html
//@ has tango/trait.Tango.html
//@ hasraw sierra/struct.Sierra.html 'Tango'
//@ hasraw trait.impl/tango/trait.Tango.js 'struct.Sierra.html'
//@ hasraw search-index.js 'Sierra'

// write only overwrites stuff in the output directory
extern crate tango;
pub struct Sierra;
impl tango::Tango for Sierra {}
Loading

0 comments on commit 548b6e1

Please sign in to comment.