about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2022-11-19 17:42:07 -0700
committerMichael Howell <michael@notriddle.com>2022-11-19 17:42:07 -0700
commitaa5a0c0d88eceb2bb55bdc7a39ffc6adc7a22881 (patch)
tree81aa295c1ea6c634895ee31e58c04f77cce17e78
parentae27c790ff235a4110b559223aa8483e97d38929 (diff)
downloadrust-aa5a0c0d88eceb2bb55bdc7a39ffc6adc7a22881.tar.gz
rust-aa5a0c0d88eceb2bb55bdc7a39ffc6adc7a22881.zip
rustdoc: add test case for scraped example expand GUI
-rw-r--r--src/bootstrap/test.rs2
-rw-r--r--src/test/rustdoc-gui/scrape-examples-button-focus.goml14
-rw-r--r--src/test/rustdoc-gui/src/scrape_examples/Cargo.lock7
-rw-r--r--src/test/rustdoc-gui/src/scrape_examples/Cargo.toml8
-rw-r--r--src/test/rustdoc-gui/src/scrape_examples/examples/check.rs25
-rw-r--r--src/test/rustdoc-gui/src/scrape_examples/src/lib.rs7
6 files changed, 63 insertions, 0 deletions
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index fd362b8367c..db83cda3700 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -1011,6 +1011,8 @@ impl Step for RustdocGUI {
                 //        instead of hard-coding this test
                 if entry.file_name() == "link_to_definition" {
                     cargo.env("RUSTDOCFLAGS", "-Zunstable-options --generate-link-to-definition");
+                } else if entry.file_name() == "scrape_examples" {
+                    cargo.arg("-Zrustdoc-scrape-examples=examples");
                 }
                 builder.run(&mut cargo);
             }
diff --git a/src/test/rustdoc-gui/scrape-examples-button-focus.goml b/src/test/rustdoc-gui/scrape-examples-button-focus.goml
new file mode 100644
index 00000000000..2a263a87a47
--- /dev/null
+++ b/src/test/rustdoc-gui/scrape-examples-button-focus.goml
@@ -0,0 +1,14 @@
+goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test.html"
+store-property: (smallOffsetHeight, ".scraped-example-list > .scraped-example pre", "offsetHeight")
+assert-property-false: (".scraped-example-list > .scraped-example pre", {
+	"scrollHeight": |smallOffsetHeight|
+})
+focus: ".scraped-example-list > .scraped-example .expand"
+press-key: "Enter"
+assert-property-false: (".scraped-example-list > .scraped-example pre", {
+	"offsetHeight": |smallOffsetHeight|
+})
+store-property: (fullOffsetHeight, ".scraped-example-list > .scraped-example pre", "offsetHeight")
+assert-property: (".scraped-example-list > .scraped-example pre", {
+	"scrollHeight": |fullOffsetHeight|
+})
diff --git a/src/test/rustdoc-gui/src/scrape_examples/Cargo.lock b/src/test/rustdoc-gui/src/scrape_examples/Cargo.lock
new file mode 100644
index 00000000000..7cd6d0844e4
--- /dev/null
+++ b/src/test/rustdoc-gui/src/scrape_examples/Cargo.lock
@@ -0,0 +1,7 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "scrape_examples"
+version = "0.1.0"
diff --git a/src/test/rustdoc-gui/src/scrape_examples/Cargo.toml b/src/test/rustdoc-gui/src/scrape_examples/Cargo.toml
new file mode 100644
index 00000000000..aea9b657d30
--- /dev/null
+++ b/src/test/rustdoc-gui/src/scrape_examples/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "scrape_examples"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/src/test/rustdoc-gui/src/scrape_examples/examples/check.rs b/src/test/rustdoc-gui/src/scrape_examples/examples/check.rs
new file mode 100644
index 00000000000..3e69c6086ae
--- /dev/null
+++ b/src/test/rustdoc-gui/src/scrape_examples/examples/check.rs
@@ -0,0 +1,25 @@
+fn main() {
+    for i in 0..9 {
+        println!("hello world!");
+        println!("hello world!");
+        println!("hello world!");
+        println!("hello world!");
+        println!("hello world!");
+        println!("hello world!");
+        println!("hello world!");
+        println!("hello world!");
+        println!("hello world!");
+    }
+    scrape_examples::test();
+    for i in 0..9 {
+        println!("hello world!");
+        println!("hello world!");
+        println!("hello world!");
+        println!("hello world!");
+        println!("hello world!");
+        println!("hello world!");
+        println!("hello world!");
+        println!("hello world!");
+        println!("hello world!");
+    }
+}
diff --git a/src/test/rustdoc-gui/src/scrape_examples/src/lib.rs b/src/test/rustdoc-gui/src/scrape_examples/src/lib.rs
new file mode 100644
index 00000000000..6412de2c03a
--- /dev/null
+++ b/src/test/rustdoc-gui/src/scrape_examples/src/lib.rs
@@ -0,0 +1,7 @@
+/// # Examples
+///
+/// ```
+/// test();
+/// test();
+/// ```
+pub fn test() {}