rustdoc: Fix incorrect usage of @!has and @!matches

`@!has` (and `@!matches`) with two arguments used to treat the second
argument as a literal string of HTML code. Now, that feature has been
renamed into `@!hasraw` (and `@!matchesraw`), and the arity-2 `@!has`
version is an error.

These uses thought the second argument was being treated as an XPath, as
with the arity-3 version, but in fact was being treated as literal HTML.
Because these were checking for the *absence* of the string, the tests
silently did nothing -- an XPath string won't ever be showing up in the
test's generated HTML!
This commit is contained in:
Noah Lev 2022-08-13 00:56:16 -04:00
parent b34e2404fd
commit 0d588e928e
11 changed files with 24 additions and 22 deletions

View File

@ -2,14 +2,16 @@
// Check that the unstable marker is not added for "rustc_private".
// @!matchesraw internal/index.html \
// '//*[@class="item-right docblock-short"]/span[@class="stab unstable"]'
// @!matchesraw internal/index.html \
// '//*[@class="item-right docblock-short"]/span[@class="stab internal"]'
// @!matches internal/index.html \
// '//*[@class="item-right docblock-short"]/span[@class="stab unstable"]' \
// ''
// @!matches internal/index.html \
// '//*[@class="item-right docblock-short"]/span[@class="stab internal"]' \
// ''
// @matches - '//*[@class="item-right docblock-short"]' 'Docs'
// @!hasraw internal/struct.S.html '//*[@class="stab unstable"]'
// @!hasraw internal/struct.S.html '//*[@class="stab internal"]'
// @!has internal/struct.S.html '//*[@class="stab unstable"]' ''
// @!has internal/struct.S.html '//*[@class="stab internal"]' ''
/// Docs
pub struct S;

View File

@ -5,11 +5,11 @@ extern crate foo;
// @has issue_61592/index.html
// @has - '//a[@href="#reexports"]' 'Re-exports'
// @has - '//code' 'pub use foo::FooTrait as _;'
// @!hasraw - '//a[@href="trait._.html"]'
// @!has - '//a[@href="trait._.html"]' ''
pub use foo::FooTrait as _;
// @has issue_61592/index.html
// @has - '//a[@href="#reexports"]' 'Re-exports'
// @has - '//code' 'pub use foo::FooStruct as _;'
// @!hasraw - '//a[@href="struct._.html"]'
// @!has - '//a[@href="struct._.html"]' ''
pub use foo::FooStruct as _;

View File

@ -2,5 +2,5 @@
// compile-flags: -Z unstable-options --disable-per-crate-search
// @!hasraw 'foo/struct.Foo.html' '//*[id="crate-search"]'
// @!has 'foo/struct.Foo.html' '//*[id="crate-search"]' ''
pub struct Foo;

View File

@ -51,7 +51,7 @@ impl G {
// @has recursive_deref/struct.D.html '//h3[@class="code-header in-band"]' 'impl Deref for D'
// We also check that `G::g` method isn't rendered because there is no `self` argument.
// @!hasraw '-' '//*[@id="deref-methods-G"]'
// @!has '-' '//*[@id="deref-methods-G"]' ''
impl Deref for D {
type Target = E;
@ -62,7 +62,7 @@ impl Deref for D {
// @has recursive_deref/struct.E.html '//h3[@class="code-header in-band"]' 'impl Deref for E'
// We also check that `G::g` method isn't rendered because there is no `self` argument.
// @!hasraw '-' '//*[@id="deref-methods-G"]'
// @!has '-' '//*[@id="deref-methods-G"]' ''
impl Deref for E {
type Target = F;
@ -73,7 +73,7 @@ impl Deref for E {
// @has recursive_deref/struct.F.html '//h3[@class="code-header in-band"]' 'impl Deref for F'
// We also check that `G::g` method isn't rendered because there is no `self` argument.
// @!hasraw '-' '//*[@id="deref-methods-G"]'
// @!has '-' '//*[@id="deref-methods-G"]' ''
impl Deref for F {
type Target = G;
@ -101,7 +101,7 @@ impl I {
}
// @has recursive_deref/struct.H.html '//h3[@class="code-header in-band"]' 'impl Deref for H'
// @!hasraw '-' '//*[@id="deref-methods-I"]'
// @!has '-' '//*[@id="deref-methods-I"]' ''
impl Deref for H {
type Target = I;

View File

@ -1,7 +1,7 @@
#![crate_name = "foo"]
// @has foo/fn.foo.html
// @!hasraw - '//a[@href="http://a.a"]'
// @!has - '//a[@href="http://a.a"]' ''
// @has - '//a[@href="#implementing-stuff-somewhere"]' 'Implementing stuff somewhere'
// @has - '//a[@href="#another-one-urg"]' 'Another one urg'

View File

@ -1,13 +1,13 @@
#![crate_name = "foo"]
// @has foo/struct.Bar.html
// @!hasraw - '//*[@id="impl-Sized"]'
// @!has - '//*[@id="impl-Sized"]' ''
pub struct Bar {
a: u16,
}
// @has foo/struct.Foo.html
// @!hasraw - '//*[@id="impl-Sized"]'
// @!has - '//*[@id="impl-Sized"]' ''
pub struct Foo<T: ?Sized>(T);
// @has foo/struct.Unsized.html

View File

@ -2,7 +2,7 @@
// @has foo/struct.Foo.html
// @count - '//*[@class="docblock"]/div/table' 2
// @!hasraw - '//*[@class="docblock"]/table'
// @!has - '//*[@class="docblock"]/table' ''
/// | hello | hello2 |
/// | ----- | ------ |
/// | data | data2 |

View File

@ -62,7 +62,7 @@ pub struct PrivStruct {
}
// @has 'toggle_item_contents/enum.Enum.html'
// @!hasraw - '//details[@class="rustdoc-toggle type-contents-toggle"]'
// @!has - '//details[@class="rustdoc-toggle type-contents-toggle"]' ''
pub enum Enum {
A, B, C,
D {
@ -72,7 +72,7 @@ pub enum Enum {
}
// @has 'toggle_item_contents/enum.EnumStructVariant.html'
// @!hasraw - '//details[@class="rustdoc-toggle type-contents-toggle"]'
// @!has - '//details[@class="rustdoc-toggle type-contents-toggle"]' ''
pub enum EnumStructVariant {
A, B, C,
D {

View File

@ -59,7 +59,7 @@ pub struct MyStruct;
// We check that associated items with default values aren't generated in the implementors list.
impl MyTrait for (u8, u8) {
// @!hasraw trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-4"]'
// @!has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-4"]' ''
type Assoc = bool;
fn trait_function(&self) {}
}

View File

@ -40,7 +40,7 @@ impl Trait for Struct {
fn c() {}
// @has - '//*[@id="method.d"]/../../div[@class="docblock"]/p' 'Escaped formatting a*b*c* works'
// @!hasraw - '//*[@id="method.d"]/../../div[@class="docblock"]/p/em'
// @!has - '//*[@id="method.d"]/../../div[@class="docblock"]/p/em' ''
fn d() {}
// @has - '//*[@id="impl-Trait-for-Struct"]/h3//a/@href' 'trait.Trait.html'

View File

@ -5,7 +5,7 @@
// @has - '//h3[@class="sidebar-title"]/a[@href="#fields"]' 'Tuple Fields'
// @has - '//*[@id="structfield.0"]' '0: u32'
// @has - '//*[@id="main-content"]/div[@class="docblock"]' 'hello'
// @!hasraw - '//*[@id="structfield.1"]'
// @!has - '//*[@id="structfield.1"]' ''
// @has - '//*[@id="structfield.2"]' '2: char'
// @has - '//*[@id="structfield.3"]' '3: i8'
// @has - '//*[@id="main-content"]/div[@class="docblock"]' 'not hello'