Skip to content

Commit 4d3f1f7

Browse files
committed
Auto merge of #162030 - GuillaumeGomez:forbid-test-rustdoc-html, r=<try>
Prevent `--test` to be used in `rustdoc-html` testsuite try-job: i686-gnu-nopt-1
2 parents 0f819a1 + 5954af8 commit 4d3f1f7

33 files changed

Lines changed: 166 additions & 79 deletions

src/etc/htmldocck.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,16 @@ def check_command(c, cache):
624624

625625
def check(target, commands):
626626
cache = CachedFiles(target)
627+
run_commands = 0
627628
for c in commands:
628629
check_command(c, cache)
630+
run_commands += 1
631+
if run_commands == 0 and os.environ.get("IS_RMAKE") is None:
632+
stderr(
633+
"\nNo check, move this file in `rustdoc-ui` testsuite if you want to check "
634+
+ "it doesn't crash"
635+
)
636+
raise SystemExit(1)
629637

630638

631639
if __name__ == "__main__":

src/tools/compiletest/src/runtest/rustdoc.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
use super::{DocKind, TestCx, remove_and_create_dir_all};
22
use crate::util::ArgFileCommand;
33

4+
fn has_test_flag(flags: &[String]) -> bool {
5+
flags.iter().any(|s| s == "--test")
6+
}
7+
48
impl TestCx<'_> {
59
pub(super) fn run_rustdoc_html_test(&self) {
610
assert!(self.variant.revision.is_none(), "revisions not supported in this test suite");
711

12+
if has_test_flag(&self.props.compile_flags) || has_test_flag(&self.props.doc_flags) {
13+
panic!(
14+
"If you want to check `--test`, put this test into `rustdoc-ui` testsuite instead",
15+
);
16+
}
817
let out_dir = self.output_base_dir();
918
remove_and_create_dir_all(&out_dir).unwrap_or_else(|e| {
1019
panic!("failed to remove and recreate output directory `{out_dir}`: {e}")

src/tools/run-make-support/src/external_deps/htmldocck.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ use crate::source_root;
99
pub fn htmldocck() -> Command {
1010
let mut python = python_command();
1111
python.arg(source_root().join("src/etc/htmldocck.py"));
12+
python.env("IS_RMAKE", "1");
1213
python
1314
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This test ensures that the `foo` decl macro is present in the module sidebar.
2+
// Because these items are not generated into the HTML, we can't make them a `rustdoc-html`
3+
// test, so here we go...
4+
5+
go-to: "file://" + |DOC_PATH| + "/test_docs/details/index.html"
6+
assert-text: (
7+
'//*[@id="rustdoc-modnav"]/ul[@class="block macro"]//a[@href="../macro.decl_macro.html"]',
8+
"decl_macro",
9+
)

tests/rustdoc-gui/src/test_docs/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#![feature(macro_derive)]
1515
#![feature(negative_impls)]
1616
#![feature(doc_notable_trait)]
17+
#![feature(decl_macro)]
1718

1819
/*!
1920
Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy
@@ -822,3 +823,7 @@ pub mod notable {
822823
pub struct Wrapper;
823824
impl Labeled for Wrapper {}
824825
}
826+
827+
pub macro decl_macro {
828+
() => { "bar" }
829+
}

tests/rustdoc-html/doc-cfg/extern-items.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
#![feature(doc_cfg)]
66
#![crate_name = "foo"]
77

8-
//@has 'foo/index.html'
9-
//@count - '//*[@class="stab portability"]' 2
10-
//@has - '//*[@class="stab portability"]' 'Non-banana'
8+
//@ has 'foo/index.html'
9+
//@ count - '//*[@class="stab portability"]' 2
10+
//@ has - '//*[@class="stab portability"]' 'Non-banana'
1111

12-
//@has 'foo/fn.doc_cfg_doesnt_work.html'
13-
//@has - '//*[@class="stab portability"]' 'Available on non-crate feature banana only.'
12+
//@ has 'foo/fn.doc_cfg_doesnt_work.html'
13+
//@ has - '//*[@class="stab portability"]' 'Available on non-crate feature banana only.'
1414

15-
//@has 'foo/fn.doc_cfg_works.html'
16-
//@has - '//*[@class="stab portability"]' 'Available on non-crate feature banana only.'
15+
//@ has 'foo/fn.doc_cfg_works.html'
16+
//@ has - '//*[@class="stab portability"]' 'Available on non-crate feature banana only.'
1717

1818
unsafe extern "C" {
1919
#[cfg(not(feature = "banana"))]

tests/rustdoc-html/doc-cfg/impl-foreign-type.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#![feature(doc_cfg)]
77
#![crate_name = "foo"]
88

9-
//@has 'foo/trait.Blob.html'
10-
//@has - '//*[@id="impl-Blob-for-Box%3CR%3E"]//*[@class="stab portability"]' 'Available on non-crate feature alloc only.'
9+
//@ has 'foo/trait.Blob.html'
10+
//@ has - '//*[@id="impl-Blob-for-Box%3CR%3E"]//*[@class="stab portability"]' 'Available on non-crate feature alloc only.'
1111

1212
pub trait Blob {}
1313

tests/rustdoc-html/doc-cfg/reexports.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
#![feature(doc_cfg)]
77
#![crate_name = "foo"]
88

9-
//@has 'foo/struct.FlatBanana.html'
10-
//@has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature banana and non-crate feature yoyo only.'
9+
//@ has 'foo/struct.FlatBanana.html'
10+
//@ has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature banana and non-crate feature yoyo only.'
1111

12-
//@has 'foo/struct.SubBanana.html'
13-
//@has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature ananas and non-crate feature banana and non-crate feature yoyo only.'
12+
//@ has 'foo/struct.SubBanana.html'
13+
//@ has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature ananas and non-crate feature banana and non-crate feature yoyo only.'
1414

1515
#[cfg(not(feature = "yoyo"))]
1616
pub use self::banana::*;
1717

18-
//@has 'foo/struct.Yolo.html'
19-
//@has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature ananas and non-crate feature banana only.'
18+
//@ has 'foo/struct.Yolo.html'
19+
//@ has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature ananas and non-crate feature banana only.'
2020
pub use self::banana::SubBanana as Yolo;
2121

2222
#[cfg(not(feature = "banana"))]

tests/rustdoc-html/doc-cfg/trait-impls-manual.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,36 @@ pub trait Foo {
2222

2323
pub struct X;
2424

25-
//@has 'foo/struct.X.html'
26-
//@count - '//*[@id="impl-Bob-for-X"]' 1
27-
//@count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 0
28-
//@count - '//*[@id="impl-Trait-for-X"]' 1
29-
//@count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 0
25+
//@ has 'foo/struct.X.html'
26+
//@ count - '//*[@id="impl-Bob-for-X"]' 1
27+
//@ count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 1
28+
//@ count - '//*[@id="impl-Trait-for-X"]' 1
29+
//@ count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 1
3030

3131
// If you need to update this XPath, in particular `item-info`, update all
3232
// the others in this file.
33-
//@count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
33+
//@ count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
3434

35-
//@has 'foo/trait.Trait.html'
36-
//@count - '//*[@id="impl-Trait-for-X"]' 1
37-
//@count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 0
35+
//@ has 'foo/trait.Trait.html'
36+
//@ count - '//*[@id="impl-Trait-for-X"]' 1
37+
//@ count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 1
3838
#[doc(cfg(any(target_pointer_width = "64", target_arch = "wasm32")))]
3939
#[doc(auto_cfg(hide(target_arch, values("wasm32"))))]
4040
mod imp {
4141
impl super::Trait for super::X { fn f(&self) {} }
4242
}
4343

44-
//@has 'foo/trait.Bob.html'
45-
//@count - '//*[@id="impl-Bob-for-X"]' 1
46-
//@count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 0
44+
//@ has 'foo/trait.Bob.html'
45+
//@ count - '//*[@id="impl-Bob-for-X"]' 1
46+
//@ count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 1
4747
#[doc(cfg(any(target_pointer_width = "64", target_arch = "wasm32")))]
4848
#[doc(auto_cfg = false)]
4949
mod imp2 {
5050
impl super::Bob for super::X { fn bob(&self) {} }
5151
}
5252

53-
//@has 'foo/trait.Foo.html'
54-
//@count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
53+
//@ has 'foo/trait.Foo.html'
54+
//@ count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
5555
// We use this to force xpath tests to be updated if `item-info` class is changed.
5656
#[doc(cfg(any(target_pointer_width = "64", target_arch = "wasm32")))]
5757
mod imp3 {
@@ -60,9 +60,9 @@ mod imp3 {
6060

6161
pub struct Y;
6262

63-
//@has 'foo/struct.Y.html'
64-
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]' 1
65-
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]/*[@class="item-info"]' 0
63+
//@ has 'foo/struct.Y.html'
64+
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]' 1
65+
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]/*[@class="item-info"]' 0
6666
#[doc(cfg(any(target_pointer_width = "64", target_arch = "wasm32")))]
6767
#[doc(auto_cfg(hide(target_arch, values("wasm32"))))]
6868
mod imp4 {
@@ -71,9 +71,9 @@ mod imp4 {
7171

7272
pub struct Z;
7373

74-
//@has 'foo/struct.Z.html'
75-
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]' 1
76-
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]/*[@class="item-info"]' 0
74+
//@ has 'foo/struct.Z.html'
75+
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]' 1
76+
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]/*[@class="item-info"]' 0
7777
#[doc(cfg(any(target_pointer_width = "64", target_arch = "wasm32")))]
7878
#[doc(auto_cfg = false)]
7979
mod imp5 {
@@ -83,9 +83,9 @@ mod imp5 {
8383
// The "witness" which has the item info.
8484
pub struct W;
8585

86-
//@has 'foo/struct.W.html'
87-
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]' 1
88-
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]/*[@class="item-info"]' 1
86+
//@ has 'foo/struct.W.html'
87+
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]' 1
88+
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]/*[@class="item-info"]' 1
8989
#[doc(cfg(any(target_pointer_width = "64", target_arch = "wasm32")))]
9090
mod imp6 {
9191
impl super::W { pub fn plain_auto() {} }

tests/rustdoc-html/doc-cfg/trait-impls.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,36 @@ pub trait Foo {
2222

2323
pub struct X;
2424

25-
//@has 'foo/struct.X.html'
26-
//@count - '//*[@id="impl-Bob-for-X"]' 1
27-
//@count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 0
28-
//@count - '//*[@id="impl-Trait-for-X"]' 1
29-
//@count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 0
25+
//@ has 'foo/struct.X.html'
26+
//@ count - '//*[@id="impl-Bob-for-X"]' 1
27+
//@ count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 0
28+
//@ count - '//*[@id="impl-Trait-for-X"]' 1
29+
//@ count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 0
3030

3131
// If you need to update this XPath, in particular `item-info`, update all
3232
// the others in this file.
33-
//@count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
33+
//@ count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
3434

35-
//@has 'foo/trait.Trait.html'
36-
//@count - '//*[@id="impl-Trait-for-X"]' 1
37-
//@count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 0
35+
//@ has 'foo/trait.Trait.html'
36+
//@ count - '//*[@id="impl-Trait-for-X"]' 1
37+
//@ count - '//*[@id="impl-Trait-for-X"]/*[@class="item-info"]' 0
3838
#[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
3939
#[doc(auto_cfg(hide(target_arch, values("wasm32"))))]
4040
mod imp {
4141
impl super::Trait for super::X { fn f(&self) {} }
4242
}
4343

44-
//@has 'foo/trait.Bob.html'
45-
//@count - '//*[@id="impl-Bob-for-X"]' 1
46-
//@count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 0
44+
//@ has 'foo/trait.Bob.html'
45+
//@ count - '//*[@id="impl-Bob-for-X"]' 1
46+
//@ count - '//*[@id="impl-Bob-for-X"]/*[@class="item-info"]' 0
4747
#[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
4848
#[doc(auto_cfg = false)]
4949
mod imp2 {
5050
impl super::Bob for super::X { fn bob(&self) {} }
5151
}
5252

53-
//@has 'foo/trait.Foo.html'
54-
//@count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
53+
//@ has 'foo/trait.Foo.html'
54+
//@ count - '//*[@id="impl-Foo-for-X"]/*[@class="item-info"]' 1
5555
// We use this to force xpath tests to be updated if `item-info` class is changed.
5656
#[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
5757
mod imp3 {
@@ -60,9 +60,9 @@ mod imp3 {
6060

6161
pub struct Y;
6262

63-
//@has 'foo/struct.Y.html'
64-
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]' 1
65-
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]/*[@class="item-info"]' 0
63+
//@ has 'foo/struct.Y.html'
64+
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]' 1
65+
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]/*[@class="item-info"]' 0
6666
#[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
6767
#[doc(auto_cfg(hide(target_arch, values("wasm32"))))]
6868
mod imp4 {
@@ -71,9 +71,9 @@ mod imp4 {
7171

7272
pub struct Z;
7373

74-
//@has 'foo/struct.Z.html'
75-
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]' 1
76-
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]/*[@class="item-info"]' 0
74+
//@ has 'foo/struct.Z.html'
75+
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]' 1
76+
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]/*[@class="item-info"]' 0
7777
#[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
7878
#[doc(auto_cfg = false)]
7979
mod imp5 {
@@ -83,9 +83,9 @@ mod imp5 {
8383
// The "witness" which has the item info.
8484
pub struct W;
8585

86-
//@has 'foo/struct.W.html'
87-
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]' 1
88-
//@count - '//*[@id="implementations-list"]/*[@class="impl-items"]/*[@class="item-info"]' 1
86+
//@ has 'foo/struct.W.html'
87+
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]' 1
88+
//@ count - '//*[@id="implementations-list"]//*[@class="impl-items"]//*[@class="item-info"]' 1
8989
#[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
9090
mod imp6 {
9191
impl super::W { pub fn plain_auto() {} }

0 commit comments

Comments
 (0)