Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6756b72a
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6756b72a
编写于
1月 23, 2017
作者:
G
Guillaume Gomez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Create new flag to test rustdoc --test
上级
44b59be0
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
55 addition
and
53 deletion
+55
-53
.gitmodules
.gitmodules
+1
-1
src/librustdoc/test.rs
src/librustdoc/test.rs
+2
-1
src/rt/hoedown
src/rt/hoedown
+1
-1
src/test/rustdoc/test_option_check/test.rs
src/test/rustdoc/test_option_check/test.rs
+2
-3
src/tools/compiletest/src/header.rs
src/tools/compiletest/src/header.rs
+11
-0
src/tools/compiletest/src/runtest.rs
src/tools/compiletest/src/runtest.rs
+38
-47
未找到文件。
.gitmodules
浏览文件 @
6756b72a
...
...
@@ -7,7 +7,7 @@
url = https://github.com/rust-lang/compiler-rt.git
[submodule "src/rt/hoedown"]
path = src/rt/hoedown
url = https://github.com/
GuillaumeGomez
/hoedown.git
url = https://github.com/
rust-lang
/hoedown.git
[submodule "src/jemalloc"]
path = src/jemalloc
url = https://github.com/rust-lang/jemalloc.git
...
...
src/librustdoc/test.rs
浏览文件 @
6756b72a
...
...
@@ -467,7 +467,8 @@ pub fn add_test(&mut self, test: String,
pub
fn
get_line
(
&
self
)
->
usize
{
if
let
Some
(
ref
codemap
)
=
self
.codemap
{
codemap
.lookup_char_pos
(
BytePos
(
self
.start_line
as
u32
))
.line
-
1
let
line
=
codemap
.lookup_char_pos
(
BytePos
(
self
.start_line
as
u32
))
.line
;
if
line
>
0
{
line
-
1
}
else
{
line
}
}
else
{
self
.start_line
}
...
...
hoedown
@
a3736a0a
Subproject commit
78e7b6f69d3fa0cb6ae6e7fb9278c3fd167ec0d1
Subproject commit
a3736a0a1907cbc8bf619708738815a5fd789c80
src/test/rustdoc/test_option_check/test.rs
浏览文件 @
6756b72a
...
...
@@ -8,15 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags:--test
// check-
stdout
// compile-flags:
--test
// check-
test-line-numbers-match
/// This is a Foo;
///
/// ```
/// println!("baaaaaar");
/// ```
#[unstable]
pub
struct
Foo
;
/// This is a Bar;
...
...
src/tools/compiletest/src/header.rs
浏览文件 @
6756b72a
...
...
@@ -224,6 +224,8 @@ pub struct TestProps {
pub
incremental_dir
:
Option
<
PathBuf
>
,
// Specifies that a cfail test must actually compile without errors.
pub
must_compile_successfully
:
bool
,
// rustdoc will test the output of the `--test` option
pub
check_test_line_numbers_match
:
bool
,
}
impl
TestProps
{
...
...
@@ -248,6 +250,7 @@ pub fn new() -> Self {
forbid_output
:
vec!
[],
incremental_dir
:
None
,
must_compile_successfully
:
false
,
check_test_line_numbers_match
:
false
,
}
}
...
...
@@ -347,6 +350,10 @@ pub fn load_from(&mut self, testfile: &Path, cfg: Option<&str>) {
if
!
self
.must_compile_successfully
{
self
.must_compile_successfully
=
parse_must_compile_successfully
(
ln
);
}
if
!
self
.check_test_line_numbers_match
{
self
.check_test_line_numbers_match
=
parse_check_test_line_numbers_match
(
ln
);
}
});
for
key
in
vec!
[
"RUST_TEST_NOCAPTURE"
,
"RUST_TEST_THREADS"
]
{
...
...
@@ -458,6 +465,10 @@ fn parse_must_compile_successfully(line: &str) -> bool {
parse_name_directive
(
line
,
"must-compile-successfully"
)
}
fn
parse_check_test_line_numbers_match
(
line
:
&
str
)
->
bool
{
parse_name_directive
(
line
,
"check-test-line-numbers-match"
)
}
fn
parse_env
(
line
:
&
str
,
name
:
&
str
)
->
Option
<
(
String
,
String
)
>
{
parse_name_value_directive
(
line
,
name
)
.map
(|
nv
|
{
// nv is either FOO or FOO=BAR
...
...
src/tools/compiletest/src/runtest.rs
浏览文件 @
6756b72a
...
...
@@ -1879,20 +1879,19 @@ fn charset() -> &'static str {
fn
run_rustdoc_test
(
&
self
)
{
assert
!
(
self
.revision
.is_none
(),
"revisions not relevant here"
);
if
self
.props.compile_flags
.contains
(
&
"--test"
.to_owned
())
&&
self
.props.check_stdout
==
true
{
self
.check_rustdoc_test_option
();
}
else
{
let
out_dir
=
self
.output_base_name
();
let
_
=
fs
::
remove_dir_all
(
&
out_dir
);
self
.create_dir_racy
(
&
out_dir
);
let
out_dir
=
self
.output_base_name
();
let
_
=
fs
::
remove_dir_all
(
&
out_dir
);
self
.create_dir_racy
(
&
out_dir
);
let
proc_res
=
self
.document
(
&
out_dir
);
if
!
proc_res
.status
.success
()
{
self
.fatal_proc_rec
(
"rustdoc failed!"
,
&
proc_res
);
}
let
root
=
self
.find_rust_src_root
()
.unwrap
();
let
proc_res
=
self
.document
(
&
out_dir
);
if
!
proc_res
.status
.success
()
{
self
.fatal_proc_rec
(
"rustdoc failed!"
,
&
proc_res
);
}
if
self
.props.check_test_line_numbers_match
==
true
{
self
.check_rustdoc_test_option
(
proc_res
);
}
else
{
let
root
=
self
.find_rust_src_root
()
.unwrap
();
let
res
=
self
.cmd2procres
(
Command
::
new
(
&
self
.config.docck_python
)
.arg
(
root
.join
(
"src/etc/htmldocck.py"
))
.arg
(
out_dir
)
...
...
@@ -1903,7 +1902,7 @@ fn run_rustdoc_test(&self) {
}
}
fn
check_rustdoc_test_option
(
&
self
)
{
fn
check_rustdoc_test_option
(
&
self
,
res
:
ProcRes
)
{
let
mut
file
=
fs
::
File
::
open
(
&
self
.testpaths.file
)
.expect
(
"markdown_test_output_check_entry File::open failed"
);
let
mut
content
=
String
::
new
();
...
...
@@ -1911,13 +1910,12 @@ fn check_rustdoc_test_option(&self) {
.expect
(
"markdown_test_output_check_entry read_to_string failed"
);
let
mut
ignore
=
false
;
let
mut
v
:
Vec
<
usize
>
=
content
.
split
(
"
\n
"
)
content
.
lines
(
)
.enumerate
()
.filter_map
(|(
line_nb
,
line
)|
{
let
sline
=
line
.split
(
"///"
)
.last
()
.unwrap_or
(
""
);
let
line
=
sline
.trim_left
();
if
line
.starts_with
(
"```"
)
&&
!
line
.contains
(
"ignore"
)
{
if
line
.starts_with
(
"```"
)
{
if
ignore
{
ignore
=
false
;
None
...
...
@@ -1931,37 +1929,30 @@ fn check_rustdoc_test_option(&self) {
})
.collect
();
let
args
=
ProcArgs
{
prog
:
self
.config.rustdoc_path
.to_str
()
.unwrap
()
.to_owned
(),
args
:
vec!
[
"--test"
.to_owned
(),
self
.testpaths.file
.to_str
()
.unwrap
()
.to_owned
()],
};
let
env
=
self
.props.exec_env
.clone
();
let
res
=
self
.compose_and_run
(
args
,
env
,
self
.config.run_lib_path
.to_str
()
.unwrap
(),
None
,
None
);
res
.stdout
.split
(
"
\n
"
)
.filter
(|
s
|
s
.starts_with
(
"test "
))
.inspect
(|
s
|
{
let
tmp
:
Vec
<&
str
>
=
s
.split
(
" - line "
)
.collect
();
if
tmp
.len
()
==
2
{
let
line
=
usize
::
from_str_radix
(
tmp
[
1
]
.split
(
" ..."
)
.next
()
.unwrap_or
(
"0"
),
10
)
.unwrap_or
(
0
);
if
let
Ok
(
pos
)
=
v
.binary_search
(
&
line
)
{
v
.remove
(
pos
);
}
else
{
self
.fatal_proc_rec
(
&
format!
(
"Not found doc test:
\"
{}
\"
in {:?}"
,
s
,
v
),
&
res
);
}
}
})
.all
(|
_
|
true
);
if
v
.len
()
!=
0
{
let
mut
tested
=
0
;
for
_
in
res
.stdout
.split
(
"
\n
"
)
.filter
(|
s
|
s
.starts_with
(
"test "
))
.inspect
(|
s
|
{
let
tmp
:
Vec
<&
str
>
=
s
.split
(
" - line "
)
.collect
();
if
tmp
.len
()
==
2
{
tested
+=
1
;
let
line
=
tmp
[
1
]
.split
(
" ..."
)
.next
()
.unwrap_or
(
"0"
)
.parse
()
.unwrap_or
(
0
);
if
let
Ok
(
pos
)
=
v
.binary_search
(
&
line
)
{
v
.remove
(
pos
);
}
else
{
self
.fatal_proc_rec
(
&
format!
(
"Not found doc test:
\"
{}
\"
in {:?}"
,
s
,
v
),
&
res
);
}
}
})
{}
if
tested
==
0
{
self
.fatal_proc_rec
(
"No test has been found"
,
&
res
);
}
else
if
v
.len
()
!=
0
{
self
.fatal_proc_rec
(
&
format!
(
"Not found test at line{} {:?}"
,
if
v
.len
()
>
1
{
"s"
}
else
{
""
},
v
),
&
res
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录