diff options
| author | bors <bors@rust-lang.org> | 2015-01-20 06:45:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-01-20 06:45:02 +0000 |
| commit | 3bf41dafcfb6c979efb4e2438e047e1a54045eec (patch) | |
| tree | 46883a9bec57ec670561487b7a17c1e6fa655a3b /src/test | |
| parent | 9006c3c0f14be45da8ffeba43d354d088e366c83 (diff) | |
| parent | 2c1d1fbdf96b4eb90fa48a3602cf869acf054d6c (diff) | |
| download | rust-3bf41dafcfb6c979efb4e2438e047e1a54045eec.tar.gz rust-3bf41dafcfb6c979efb4e2438e047e1a54045eec.zip | |
Auto merge of #21304 - lifthrasiir:htmldocck, r=alexcrichton
The script is intended as a tool for doing every sort of verifications amenable to Rustdoc's HTML output. For example, link checkers would go to this script. It already parses HTML into a document tree form (with a slight caveat), so future tests can make use of it. As an example, relevant `rustdoc-*` run-make tests have been updated to use `htmldocck.py` and got their `verify.sh` removed. In the future they may go to a dedicated directory with htmldocck running by default. The detailed explanation of test scripts is provided as a docstring of htmldocck. cc #19723
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-make/rustdoc-hidden-line/Makefile | 3 | ||||
| -rw-r--r-- | src/test/run-make/rustdoc-hidden-line/foo.rs | 4 | ||||
| -rwxr-xr-x | src/test/run-make/rustdoc-hidden-line/verify.sh | 8 | ||||
| -rw-r--r-- | src/test/run-make/rustdoc-search-index/Makefile | 4 | ||||
| -rw-r--r-- | src/test/run-make/rustdoc-search-index/index.rs | 11 | ||||
| -rwxr-xr-x | src/test/run-make/rustdoc-search-index/verify.sh | 33 | ||||
| -rw-r--r-- | src/test/run-make/rustdoc-smoke/Makefile | 3 | ||||
| -rw-r--r-- | src/test/run-make/rustdoc-smoke/foo.rs | 7 | ||||
| -rwxr-xr-x | src/test/run-make/rustdoc-smoke/verify.sh | 17 | ||||
| -rw-r--r-- | src/test/run-make/rustdoc-where/Makefile | 6 | ||||
| -rw-r--r-- | src/test/run-make/rustdoc-where/foo.rs | 12 | ||||
| -rwxr-xr-x | src/test/run-make/rustdoc-where/verify.sh | 23 | ||||
| -rw-r--r-- | src/test/run-make/tools.mk | 1 |
13 files changed, 34 insertions, 98 deletions
diff --git a/src/test/run-make/rustdoc-hidden-line/Makefile b/src/test/run-make/rustdoc-hidden-line/Makefile index bc7e4e5863e..3ac7b6d2fae 100644 --- a/src/test/run-make/rustdoc-hidden-line/Makefile +++ b/src/test/run-make/rustdoc-hidden-line/Makefile @@ -7,8 +7,7 @@ all: @echo $(RUSTDOC) $(HOST_RPATH_ENV) $(RUSTDOC) --test foo.rs $(HOST_RPATH_ENV) $(RUSTDOC) -w html -o $(TMPDIR)/doc foo.rs - cp verify.sh $(TMPDIR) - $(call RUN,verify.sh) $(TMPDIR) + $(HTMLDOCCK) $(TMPDIR)/doc foo.rs else all: diff --git a/src/test/run-make/rustdoc-hidden-line/foo.rs b/src/test/run-make/rustdoc-hidden-line/foo.rs index 78dcaebda4b..c538a132fb1 100644 --- a/src/test/run-make/rustdoc-hidden-line/foo.rs +++ b/src/test/run-make/rustdoc-hidden-line/foo.rs @@ -30,3 +30,7 @@ /// } /// ``` pub fn foo() {} + +// @!has foo/fn.foo.html invisible +// @matches - //pre '#.*\[.*derive.*\(.*Eq.*\).*\].*//.*Bar' + diff --git a/src/test/run-make/rustdoc-hidden-line/verify.sh b/src/test/run-make/rustdoc-hidden-line/verify.sh deleted file mode 100755 index 9f28b55b133..00000000000 --- a/src/test/run-make/rustdoc-hidden-line/verify.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -file="$1/doc/foo/fn.foo.html" - -grep -v 'invisible' $file && -grep '#.*\[.*derive.*(.*Eq.*).*\].*//.*Bar' $file - -exit $? diff --git a/src/test/run-make/rustdoc-search-index/Makefile b/src/test/run-make/rustdoc-search-index/Makefile index 1248f144a84..e7e8f0c35a7 100644 --- a/src/test/run-make/rustdoc-search-index/Makefile +++ b/src/test/run-make/rustdoc-search-index/Makefile @@ -7,9 +7,7 @@ source=index.rs all: $(HOST_RPATH_ENV) $(RUSTDOC) -w html -o $(TMPDIR)/doc $(source) - cp $(source) $(TMPDIR) - cp verify.sh $(TMPDIR) - $(call RUN,verify.sh) $(TMPDIR) + $(HTMLDOCCK) $(TMPDIR)/doc $(source) else all: diff --git a/src/test/run-make/rustdoc-search-index/index.rs b/src/test/run-make/rustdoc-search-index/index.rs index 019d77f1b1c..dd68f2d6f1d 100644 --- a/src/test/run-make/rustdoc-search-index/index.rs +++ b/src/test/run-make/rustdoc-search-index/index.rs @@ -10,20 +10,17 @@ #![crate_name = "rustdoc_test"] -// In: Foo +// @has search-index.js Foo pub use private::Foo; mod private { pub struct Foo; impl Foo { - // In: test_method - pub fn test_method() {} - // Out: priv_method - fn priv_method() {} + pub fn test_method() {} // @has - test_method + fn priv_method() {} // @!has - priv_method } pub trait PrivateTrait { - // Out: priv_method - fn trait_method() {} + fn trait_method() {} // @!has - priv_method } } diff --git a/src/test/run-make/rustdoc-search-index/verify.sh b/src/test/run-make/rustdoc-search-index/verify.sh deleted file mode 100755 index af5033adf6b..00000000000 --- a/src/test/run-make/rustdoc-search-index/verify.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -source="$1/index.rs" -index="$1/doc/search-index.js" - -if ! [ -e $index ] -then - echo "Could not find the search index (looked for $index)" - exit 1 -fi - -ins=$(grep -o 'In: .*' $source | sed 's/In: \(.*\)/\1/g') -outs=$(grep -o 'Out: .*' $source | sed 's/Out: \(.*\)/\1/g') - -for p in $ins -do - if ! grep -q $p $index - then - echo "'$p' was erroneously excluded from search index." - exit 1 - fi -done - -for p in $outs -do - if grep -q $p $index - then - echo "'$p' was erroneously included in search index." - exit 1 - fi -done - -exit 0 diff --git a/src/test/run-make/rustdoc-smoke/Makefile b/src/test/run-make/rustdoc-smoke/Makefile index de013ab28a5..7a1ad761b3d 100644 --- a/src/test/run-make/rustdoc-smoke/Makefile +++ b/src/test/run-make/rustdoc-smoke/Makefile @@ -1,5 +1,4 @@ -include ../tools.mk all: $(HOST_RPATH_ENV) $(RUSTDOC) -w html -o $(TMPDIR)/doc foo.rs - cp verify.sh $(TMPDIR) - $(call RUN,verify.sh) $(TMPDIR) + $(HTMLDOCCK) $(TMPDIR)/doc foo.rs diff --git a/src/test/run-make/rustdoc-smoke/foo.rs b/src/test/run-make/rustdoc-smoke/foo.rs index 499bcaff4d1..0438c9aba35 100644 --- a/src/test/run-make/rustdoc-smoke/foo.rs +++ b/src/test/run-make/rustdoc-smoke/foo.rs @@ -8,22 +8,29 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// @has foo/index.html #![crate_name = "foo"] //! Very docs +// @has foo/bar/index.html pub mod bar { /// So correct + // @has foo/bar/baz/index.html pub mod baz { /// Much detail + // @has foo/bar/baz/fn.baz.html pub fn baz() { } } /// *wow* + // @has foo/bar/trait.Doge.html pub trait Doge { } + // @has foo/bar/struct.Foo.html pub struct Foo { x: int, y: uint } + // @has foo/bar/fn.prawns.html pub fn prawns((a, b): (int, uint), Foo { x, y }: Foo) { } } diff --git a/src/test/run-make/rustdoc-smoke/verify.sh b/src/test/run-make/rustdoc-smoke/verify.sh deleted file mode 100755 index 18f3939794e..00000000000 --- a/src/test/run-make/rustdoc-smoke/verify.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -# $1 is the TMPDIR - -dirs="doc doc/foo doc/foo/bar doc/foo/bar/baz doc/src doc/src/foo" - -for dir in $dirs; do if [ ! -d $1/$dir ]; then - echo "$1/$dir is not a directory!" - exit 1 -fi done - -files="doc/foo/index.html doc/foo/bar/index.html doc/foo/bar/baz/fn.baz.html doc/foo/bar/trait.Doge.html doc/src/foo/foo.rs.html" - -for file in $files; do if [ ! -f $1/$file ]; then - echo "$1/$file is not a file!" - exit 1 -fi done diff --git a/src/test/run-make/rustdoc-where/Makefile b/src/test/run-make/rustdoc-where/Makefile index 864d594cf99..1316ee256e1 100644 --- a/src/test/run-make/rustdoc-where/Makefile +++ b/src/test/run-make/rustdoc-where/Makefile @@ -1,6 +1,6 @@ -include ../tools.mk -all: verify.sh foo.rs +all: foo.rs $(HOST_RPATH_ENV) $(RUSTDOC) -w html -o $(TMPDIR)/doc foo.rs - cp verify.sh $(TMPDIR) - $(call RUN,verify.sh) $(TMPDIR) + $(HTMLDOCCK) $(TMPDIR)/doc foo.rs + diff --git a/src/test/run-make/rustdoc-where/foo.rs b/src/test/run-make/rustdoc-where/foo.rs index 7e6df7f011a..9f38ff13805 100644 --- a/src/test/run-make/rustdoc-where/foo.rs +++ b/src/test/run-make/rustdoc-where/foo.rs @@ -10,17 +10,29 @@ pub trait MyTrait {} +// @matches foo/struct.Alpha.html '//pre' "Alpha.*where.*A:.*MyTrait" pub struct Alpha<A> where A: MyTrait; +// @matches foo/trait.Bravo.html '//pre' "Bravo.*where.*B:.*MyTrait" pub trait Bravo<B> where B: MyTrait {} +// @matches foo/fn.charlie.html '//pre' "charlie.*where.*C:.*MyTrait" pub fn charlie<C>() where C: MyTrait {} pub struct Delta<D>; +// @matches foo/struct.Delta.html '//*[@class="impl"]//code' "impl.*Delta.*where.*D:.*MyTrait" impl<D> Delta<D> where D: MyTrait { pub fn delta() {} } pub struct Echo<E>; +// @matches foo/struct.Echo.html '//*[@class="impl"]//code' \ +// "impl.*MyTrait.*for.*Echo.*where.*E:.*MyTrait" +// @matches foo/trait.MyTrait.html '//*[@id="implementors-list"]//code' \ +// "impl.*MyTrait.*for.*Echo.*where.*E:.*MyTrait" impl<E> MyTrait for Echo<E> where E: MyTrait {} pub enum Foxtrot<F> {} +// @matches foo/enum.Foxtrot.html '//*[@class="impl"]//code' \ +// "impl.*MyTrait.*for.*Foxtrot.*where.*F:.*MyTrait" +// @matches foo/trait.MyTrait.html '//*[@id="implementors-list"]//code' \ +// "impl.*MyTrait.*for.*Foxtrot.*where.*F:.*MyTrait" impl<F> MyTrait for Foxtrot<F> where F: MyTrait {} diff --git a/src/test/run-make/rustdoc-where/verify.sh b/src/test/run-make/rustdoc-where/verify.sh deleted file mode 100755 index 1d498231018..00000000000 --- a/src/test/run-make/rustdoc-where/verify.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -set -e - -# $1 is the TMPDIR -DOC=$1/doc/foo - -grep "Alpha.*where.*A:.*MyTrait" $DOC/struct.Alpha.html > /dev/null -echo "Alpha" -grep "Bravo.*where.*B:.*MyTrait" $DOC/trait.Bravo.html > /dev/null -echo "Bravo" -grep "charlie.*where.*C:.*MyTrait" $DOC/fn.charlie.html > /dev/null -echo "Charlie" -grep "impl.*Delta.*where.*D:.*MyTrait" $DOC/struct.Delta.html > /dev/null -echo "Delta" -grep "impl.*MyTrait.*for.*Echo.*where.*E:.*MyTrait" $DOC/struct.Echo.html > /dev/null -echo "Echo" -grep "impl.*MyTrait.*for.*Foxtrot.*where.*F:.*MyTrait" $DOC/enum.Foxtrot.html > /dev/null -echo "Foxtrot" - -# check "Implementors" section of MyTrait -grep "impl.*MyTrait.*for.*Echo.*where.*E:.*MyTrait" $DOC/trait.MyTrait.html > /dev/null -grep "impl.*MyTrait.*for.*Foxtrot.*where.*F:.*MyTrait" $DOC/trait.MyTrait.html > /dev/null -echo "Implementors OK" diff --git a/src/test/run-make/tools.mk b/src/test/run-make/tools.mk index 365cbf93da2..971295405aa 100644 --- a/src/test/run-make/tools.mk +++ b/src/test/run-make/tools.mk @@ -7,6 +7,7 @@ TARGET_RPATH_ENV = \ RUSTC := $(HOST_RPATH_ENV) $(RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR) CC := $(CC) -L $(TMPDIR) +HTMLDOCCK := $(PYTHON) $(S)/src/etc/htmldocck.py # This is the name of the binary we will generate and run; use this # e.g. for `$(CC) -o $(RUN_BINFILE)`. |
