Update unstable-crate test
This commit is contained in:
parent
274543b9ca
commit
e1367ef1b1
File diff suppressed because it is too large
Load Diff
|
@ -13,8 +13,8 @@ env_logger = { version = "0.4", default-features = false }
|
|||
log = "0.3"
|
||||
pulldown-cmark = { version = "0.0.14", default-features = false }
|
||||
|
||||
[target.'cfg(not(stage0))'.dependencies]
|
||||
html-diff = "0.0.2"
|
||||
[target.'cfg(not(any(stage0, stage1)))'.dependencies]
|
||||
html-diff = "0.0.3"
|
||||
|
||||
[build-dependencies]
|
||||
build_helper = { path = "../build_helper" }
|
||||
|
|
|
@ -75,7 +75,7 @@ use html::item_type::ItemType;
|
|||
use html::markdown::{self, Markdown, MarkdownHtml, MarkdownSummaryLine, RenderType};
|
||||
use html::{highlight, layout};
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[cfg(not(any(stage0, stage1)))]
|
||||
use html_diff;
|
||||
|
||||
/// A pair of name and its optional document.
|
||||
|
@ -1648,7 +1648,7 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[cfg(not(any(stage0, stage1)))]
|
||||
fn get_html_diff(w: &mut fmt::Formatter, md_text: &str, render_type: RenderType,
|
||||
prefix: &str) -> fmt::Result {
|
||||
if render_type == RenderType::Pulldown {
|
||||
|
@ -1671,9 +1671,10 @@ fn get_html_diff(w: &mut fmt::Formatter, md_text: &str, render_type: RenderType,
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn get_html_diff(w: &mut fmt::Formatter, md_text: &str, render_type: RenderType) -> fmt::Result {
|
||||
write!(w, "<div class='docblock'>{}</div>", Markdown(md_text, render_type))
|
||||
#[cfg(any(stage0, stage1))]
|
||||
fn get_html_diff(w: &mut fmt::Formatter, md_text: &str, render_type: RenderType,
|
||||
prefix: &str) -> fmt::Result {
|
||||
write!(w, "<div class='docblock'>{}{}</div>", prefix, Markdown(md_text, render_type))
|
||||
}
|
||||
|
||||
fn document_short(w: &mut fmt::Formatter, item: &clean::Item, link: AssocItemLink,
|
||||
|
@ -1685,7 +1686,7 @@ fn document_short(w: &mut fmt::Formatter, item: &clean::Item, link: AssocItemLin
|
|||
} else {
|
||||
format!("{}", &plain_summary_line(Some(s)))
|
||||
};
|
||||
get_html_diff(&markdown, render_type, prefix)?;
|
||||
get_html_diff(w, &markdown, render_type, prefix)?;
|
||||
} else if !prefix.is_empty() {
|
||||
write!(w, "<div class='docblock'>{}</div>", prefix)?;
|
||||
}
|
||||
|
@ -1709,7 +1710,7 @@ fn render_assoc_const_value(item: &clean::Item) -> String {
|
|||
fn document_full(w: &mut fmt::Formatter, item: &clean::Item,
|
||||
render_type: RenderType, prefix: &str) -> fmt::Result {
|
||||
if let Some(s) = item.doc_value() {
|
||||
get_html_diff(format!("{}{}", md_render_assoc_item(item), s), render_type, prefix)?;
|
||||
get_html_diff(w, s, render_type, prefix)?;
|
||||
} else if !prefix.is_empty() {
|
||||
write!(w, "<div class='docblock'>{}</div>", prefix)?;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
extern crate arena;
|
||||
extern crate getopts;
|
||||
extern crate env_logger;
|
||||
#[cfg(not(stage0))]
|
||||
#[cfg(not(any(stage0, stage1)))]
|
||||
extern crate html_diff;
|
||||
extern crate libc;
|
||||
extern crate rustc;
|
||||
|
|
|
@ -1,35 +1,4 @@
|
|||
-include ../tools.mk
|
||||
PYTHON=python
|
||||
|
||||
# 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:
|
||||
python 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)
|
|
@ -15,7 +15,7 @@
|
|||
// @has issue_12834/fn.foo.html
|
||||
// @has - //pre 'a + b '
|
||||
|
||||
/// ```text
|
||||
/// ```
|
||||
/// a + b ∈ Self ∀ a, b ∈ Self
|
||||
/// ```
|
||||
pub fn foo() {}
|
||||
|
|
Loading…
Reference in New Issue