Skip to content

Commit 0db6f4c

Browse files
committed
Add a simple test for rustdoc search index contents
1 parent bcb0717 commit 0db6f4c

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-include ../tools.mk
2+
3+
# FIXME ignore windows
4+
ifndef IS_WINDOWS
5+
6+
source=index.rs
7+
8+
all:
9+
$(HOST_RPATH_ENV) $(RUSTDOC) -w html -o $(TMPDIR)/doc $(source)
10+
cp $(source) $(TMPDIR)
11+
cp verify.sh $(TMPDIR)
12+
$(call RUN,verify.sh) $(TMPDIR)
13+
14+
else
15+
all:
16+
17+
endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_name = "rustdoc_test"]
12+
13+
// In: Foo
14+
pub use private::Foo;
15+
16+
mod private {
17+
pub struct Foo;
18+
impl Foo {
19+
// In: test_method
20+
pub fn test_method() {}
21+
// Out: priv_method
22+
fn priv_method() {}
23+
}
24+
25+
pub trait PrivateTrait {
26+
// Out: priv_method
27+
fn trait_method() {}
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh
2+
3+
source="$1/index.rs"
4+
index="$1/doc/search-index.js"
5+
6+
if ! [ -e $index ]
7+
then
8+
echo "Could not find the search index (looked for $index)"
9+
exit 1
10+
fi
11+
12+
ins=$(grep -o 'In: .*' $source | sed 's/In: \(.*\)/\1/g')
13+
outs=$(grep -o 'Out: .*' $source | sed 's/Out: \(.*\)/\1/g')
14+
15+
for p in $ins
16+
do
17+
if ! grep -q $p $index
18+
then
19+
echo "'$p' was erroneously excluded from search index."
20+
exit 1
21+
fi
22+
done
23+
24+
for p in $outs
25+
do
26+
if grep -q $p $index
27+
then
28+
echo "'$p' was erroneously included in search index."
29+
exit 1
30+
fi
31+
done
32+
33+
exit 0

0 commit comments

Comments
 (0)