Skip to content

Add a rustdoc test #11032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -920,14 +920,15 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),rmake): \

$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
$(S)src/test/run-make/%/Makefile \
$$(HSREQ$(1)_H_$(3))
$$(CSREQ$(1)_T_$(2)_H_$(3))
@rm -rf $(3)/test/run-make/$$*
@mkdir -p $(3)/test/run-make/$$*
@echo maketest: $$*
$$(Q)$$(CFG_PYTHON) $(S)src/etc/maketest.py $$(dir $$<) \
$$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
$(3)/test/run-make/$$* \
"$$(CC_$(3)) $$(CFG_GCCISH_CFLAGS_$(3))"
"$$(CC_$(3)) $$(CFG_GCCISH_CFLAGS_$(3))" \
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3))
@touch $$@

endef
Expand Down
1 change: 1 addition & 0 deletions src/etc/maketest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
os.putenv('RUSTC', os.path.abspath(sys.argv[2]))
os.putenv('TMPDIR', os.path.abspath(sys.argv[3]))
os.putenv('CC', sys.argv[4])
os.putenv('RUSTDOC', os.path.abspath(sys.argv[5]))

proc = subprocess.Popen(['make', '-C', sys.argv[1]],
stdout = subprocess.PIPE,
Expand Down
12 changes: 9 additions & 3 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,15 +678,21 @@ impl Context {
// using a rwarc makes this parallelizable in the future
local_data::set(cache_key, Arc::new(cache));

self.item(item);
let mut work = ~[(self, item)];
while work.len() > 0 {
let (mut cx, item) = work.pop();
cx.item(item, |cx, item| {
work.push((cx.clone(), item));
})
}
}

/// Non-parellelized version of rendering an item. This will take the input
/// item, render its contents, and then invoke the specified closure with
/// all sub-items which need to be rendered.
///
/// The rendering driver uses this closure to queue up more work.
fn item(&mut self, item: clean::Item) {
fn item(&mut self, item: clean::Item, f: |&mut Context, clean::Item|) {
fn render(w: io::File, cx: &mut Context, it: &clean::Item,
pushname: bool) {
info!("Rendering an item to {}", w.path().display());
Expand Down Expand Up @@ -733,7 +739,7 @@ impl Context {
};
this.sidebar = build_sidebar(&m);
for item in m.items.move_iter() {
this.item(item);
f(this,item);
}
})
}
Expand Down
5 changes: 5 additions & 0 deletions src/test/run-make/rustdoc-smoke/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-include ../tools.mk
all:
$(RUSTDOC) -w html -o $(TMPDIR)/doc foo.rs
cp verify.sh $(TMPDIR)
$(call RUN,verify.sh) $(TMPDIR)
15 changes: 15 additions & 0 deletions src/test/run-make/rustdoc-smoke/foo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#[pkgid = "foo#0.1"];

//! Very docs

pub mod bar {

/// So correct
pub mod baz {
/// Much detail
pub fn baz() { }
}

/// *wow*
pub trait Doge { }
}
17 changes: 17 additions & 0 deletions src/test/run-make/rustdoc-smoke/verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/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