diff options
| author | bors <bors@rust-lang.org> | 2017-08-31 08:52:03 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-08-31 08:52:03 +0000 |
| commit | 97b01abf3d222523d0db4f79c13ed45e7fef27e3 (patch) | |
| tree | bd854760b9d0c82c9a5625296b12c6ae71ee7bb5 /src/test | |
| parent | 890c87b643264120dc1064ed73df6def974e02fc (diff) | |
| parent | b501d000907963aa33d65a864f684de0de4167e6 (diff) | |
| download | rust-97b01abf3d222523d0db4f79c13ed45e7fef27e3.tar.gz rust-97b01abf3d222523d0db4f79c13ed45e7fef27e3.zip | |
Auto merge of #41991 - GuillaumeGomez:rustdoc-html-diff, r=nrc
Add warnings when rustdoc html rendering differs
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-make/sysroot-crates-are-unstable/Makefile | 37 | ||||
| -rw-r--r-- | src/test/run-make/sysroot-crates-are-unstable/test.py | 71 | ||||
| -rw-r--r-- | src/test/rustdoc/issue-29449.rs | 6 |
3 files changed, 76 insertions, 38 deletions
diff --git a/src/test/run-make/sysroot-crates-are-unstable/Makefile b/src/test/run-make/sysroot-crates-are-unstable/Makefile index 4b7052f9b94..a35174b3c2a 100644 --- a/src/test/run-make/sysroot-crates-are-unstable/Makefile +++ b/src/test/run-make/sysroot-crates-are-unstable/Makefile @@ -1,35 +1,2 @@ --include ../tools.mk - -# This is a whitelist of files which are stable crates or simply are not crates, -# we don't check for the instability of these crates as they're all stable! -STABLE_CRATES := \ - std \ - core \ - proc_macro \ - rsbegin.o \ - rsend.o \ - dllcrt2.o \ - crt2.o \ - clang_rt.%_dynamic.dylib - -# Generate a list of all crates in the sysroot. To do this we list all files in -# rustc's sysroot, look at the filename, strip everything after the `-`, and -# strip the leading `lib` (if present) -SYSROOT := $(shell $(RUSTC) --print sysroot) -LIBS := $(wildcard $(SYSROOT)/lib/rustlib/$(TARGET)/lib/*) -LIBS := $(foreach lib,$(LIBS),$(notdir $(lib))) -LIBS := $(foreach lib,$(LIBS),$(word 1,$(subst -, ,$(lib)))) -LIBS := $(foreach lib,$(LIBS),$(patsubst lib%,%,$(lib))) -LIBS := $(filter-out $(STABLE_CRATES),$(LIBS)) - -all: $(foreach lib,$(LIBS),check-crate-$(lib)-is-unstable) - -check-crate-%-is-unstable: - @echo verifying $* is an unstable crate - @echo 'extern crate $*;' | \ - $(RUSTC) - --crate-type rlib 2>&1 | cat > $(TMPDIR)/$*; \ - true - @grep -q 'use of unstable library feature' $(TMPDIR)/$* || \ - (echo crate $* is not unstable && \ - cat $(TMPDIR)/$* && \ - false) +all: + python2.7 test.py diff --git a/src/test/run-make/sysroot-crates-are-unstable/test.py b/src/test/run-make/sysroot-crates-are-unstable/test.py new file mode 100644 index 00000000000..210059e1010 --- /dev/null +++ b/src/test/run-make/sysroot-crates-are-unstable/test.py @@ -0,0 +1,71 @@ +# Copyright 2015 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +import sys +import os +from os import listdir +from os.path import isfile, join +from subprocess import PIPE, Popen + + +# This is a whitelist of files which are stable crates or simply are not crates, +# we don't check for the instability of these crates as they're all stable! +STABLE_CRATES = ['std', 'core', 'proc_macro', 'rsbegin.o', 'rsend.o', 'dllcrt2.o', 'crt2.o', + 'clang_rt'] + + +def convert_to_string(s): + if s.__class__.__name__ == 'bytes': + return s.decode('utf-8') + return s + + +def exec_command(command, to_input=None): + child = None + if to_input is None: + child = Popen(command, stdout=PIPE, stderr=PIPE) + else: + child = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE) + stdout, stderr = child.communicate(input=to_input) + return (convert_to_string(stdout), convert_to_string(stderr)) + + +def check_lib(lib): + if lib['name'] in STABLE_CRATES: + return True + print('verifying if {} is an unstable crate'.format(lib['name'])) + stdout, stderr = exec_command([os.environ['RUSTC'], '-', '--crate-type', 'rlib', + '--extern', '{}={}'.format(lib['name'], lib['path'])], + to_input='extern crate {};'.format(lib['name'])) + if not 'use of unstable library feature' in '{}{}'.format(stdout, stderr): + print('crate {} "{}" is not unstable'.format(lib['name'], lib['path'])) + print('{}{}'.format(stdout, stderr)) + print('') + return False + return True + +# Generate a list of all crates in the sysroot. To do this we list all files in +# rustc's sysroot, look at the filename, strip everything after the `-`, and +# strip the leading `lib` (if present) +def get_all_libs(dir_path): + return [{ 'path': join(dir_path, f), 'name': f[3:].split('-')[0] } + for f in listdir(dir_path) + if isfile(join(dir_path, f)) and f.endswith('.rlib') and f not in STABLE_CRATES] + + +sysroot = exec_command([os.environ['RUSTC'], '--print', 'sysroot'])[0].replace('\n', '') +libs = get_all_libs(join(sysroot, 'lib/rustlib/{}/lib'.format(os.environ['TARGET']))) + +ret = 0 +for lib in libs: + if not check_lib(lib): + # We continue so users can see all the not unstable crates. + ret = 1 +sys.exit(ret) diff --git a/src/test/rustdoc/issue-29449.rs b/src/test/rustdoc/issue-29449.rs index f296048e30b..29b89d68970 100644 --- a/src/test/rustdoc/issue-29449.rs +++ b/src/test/rustdoc/issue-29449.rs @@ -18,12 +18,12 @@ impl Foo { /// # Panics pub fn bar() {} - // @has - '//*[@id="examples-1"]//a' 'Examples' + // @has - '//*[@id="examples-2"]//a' 'Examples' /// # Examples pub fn bar_1() {} - // @has - '//*[@id="examples-2"]//a' 'Examples' - // @has - '//*[@id="panics-1"]//a' 'Panics' + // @has - '//*[@id="examples-4"]//a' 'Examples' + // @has - '//*[@id="panics-2"]//a' 'Panics' /// # Examples /// # Panics pub fn bar_2() {} |
