Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c7bdfd44
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,发现更多精彩内容 >>
提交
c7bdfd44
编写于
3月 22, 2016
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
Auto merge of #32341 - frewsxcv:compiletest-enum, r=nikomatsakis
Use enum for message kind in compiletest harness. None
上级
2ae05d37
73f43218
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
57 addition
and
14 deletion
+57
-14
src/compiletest/errors.rs
src/compiletest/errors.rs
+46
-6
src/compiletest/runtest.rs
src/compiletest/runtest.rs
+11
-8
未找到文件。
src/compiletest/errors.rs
浏览文件 @
c7bdfd44
...
...
@@ -9,14 +9,54 @@
// except according to those terms.
use
self
::
WhichLine
::
*
;
use
std
::
fmt
;
use
std
::
fs
::
File
;
use
std
::
io
::
BufReader
;
use
std
::
io
::
prelude
::
*
;
use
std
::
path
::
Path
;
use
std
::
str
::
FromStr
;
#[derive(Clone,
Debug,
PartialEq)]
pub
enum
ErrorKind
{
Help
,
Error
,
Note
,
Suggestion
,
Warning
,
}
impl
FromStr
for
ErrorKind
{
type
Err
=
();
fn
from_str
(
s
:
&
str
)
->
Result
<
Self
,
Self
::
Err
>
{
match
&
s
.trim_right_matches
(
':'
)
as
&
str
{
"HELP"
=>
Ok
(
ErrorKind
::
Help
),
"ERROR"
=>
Ok
(
ErrorKind
::
Error
),
"NOTE"
=>
Ok
(
ErrorKind
::
Note
),
"SUGGESTION"
=>
Ok
(
ErrorKind
::
Suggestion
),
"WARN"
=>
Ok
(
ErrorKind
::
Warning
),
"WARNING"
=>
Ok
(
ErrorKind
::
Warning
),
_
=>
Err
(()),
}
}
}
impl
fmt
::
Display
for
ErrorKind
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
match
*
self
{
ErrorKind
::
Help
=>
write!
(
f
,
"help"
),
ErrorKind
::
Error
=>
write!
(
f
,
"error"
),
ErrorKind
::
Note
=>
write!
(
f
,
"note"
),
ErrorKind
::
Suggestion
=>
write!
(
f
,
"suggestion"
),
ErrorKind
::
Warning
=>
write!
(
f
,
"warning"
),
}
}
}
pub
struct
ExpectedError
{
pub
line_num
:
usize
,
pub
kind
:
String
,
/// What kind of message we expect (e.g. warning, error, suggestion).
/// `None` if not specified or unknown message kind.
pub
kind
:
Option
<
ErrorKind
>
,
pub
msg
:
String
,
}
...
...
@@ -81,11 +121,11 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
(
false
,
line
[
start
+
tag
.len
()
..
]
.chars
()
.take_while
(|
c
|
*
c
==
'^'
)
.count
())
};
let
kind_start
=
start
+
tag
.len
()
+
adjusts
+
(
follow
as
usize
);
let
letters
=
line
[
kind_start
..
]
.chars
();
let
kind
=
letters
.skip_while
(|
c
|
c
.is_whitespace
()
)
.take_while
(|
c
|
!
c
.is_whitespace
()
)
.flat_map
(|
c
|
c
.to_lowercase
()
)
.collect
::
<
String
>
();
let
kind
=
line
[
kind_start
..
]
.split_whitespace
()
.next
(
)
.expect
(
"Encountered unexpected empty comment"
)
.parse
::
<
ErrorKind
>
(
)
.ok
();
let
letters
=
line
[
kind_start
..
]
.chars
();
let
msg
=
letters
.skip_while
(|
c
|
c
.is_whitespace
())
.skip_while
(|
c
|
!
c
.is_whitespace
())
...
...
src/compiletest/runtest.rs
浏览文件 @
c7bdfd44
...
...
@@ -11,7 +11,7 @@
use
common
::
Config
;
use
common
::{
CompileFail
,
ParseFail
,
Pretty
,
RunFail
,
RunPass
,
RunPassValgrind
};
use
common
::{
Codegen
,
DebugInfoLldb
,
DebugInfoGdb
,
Rustdoc
,
CodegenUnits
};
use
errors
;
use
errors
::{
self
,
ErrorKind
}
;
use
header
::
TestProps
;
use
header
;
use
procsrv
;
...
...
@@ -1033,8 +1033,8 @@ fn check_expected_errors(revision: Option<&str>,
expected_errors
.iter
()
.fold
((
false
,
false
),
|(
acc_help
,
acc_note
),
ee
|
(
acc_help
||
ee
.kind
==
"help:"
||
ee
.kind
==
"help"
,
acc_note
||
ee
.kind
==
"note:"
||
ee
.kind
==
"note"
));
(
acc_help
||
ee
.kind
==
Some
(
ErrorKind
::
Help
)
,
acc_note
||
ee
.kind
==
Some
(
ErrorKind
::
Note
)
));
// Scan and extract our error/warning messages,
// which look like:
...
...
@@ -1052,15 +1052,15 @@ fn check_expected_errors(revision: Option<&str>,
let
mut
prev
=
0
;
for
(
i
,
ee
)
in
expected_errors
.iter
()
.enumerate
()
{
if
!
found_flags
[
i
]
{
debug!
(
"prefix={} ee.kind={} ee.msg={} line={}"
,
debug!
(
"prefix={} ee.kind={
:?
} ee.msg={} line={}"
,
prefixes
[
i
],
ee
.kind
,
ee
.msg
,
line
);
// Suggestions have no line number in their output, so take on the line number of
// the previous expected error
if
ee
.kind
==
"suggestion"
{
assert
!
(
expected_errors
[
prev
]
.kind
==
"help"
,
if
ee
.kind
==
Some
(
ErrorKind
::
Suggestion
)
{
assert
!
(
expected_errors
[
prev
]
.kind
==
Some
(
ErrorKind
::
Help
)
,
"SUGGESTIONs must be preceded by a HELP"
);
if
line
.contains
(
&
ee
.msg
)
{
found_flags
[
i
]
=
true
;
...
...
@@ -1070,7 +1070,7 @@ fn check_expected_errors(revision: Option<&str>,
}
if
(
prefix_matches
(
line
,
&
prefixes
[
i
])
||
continuation
(
line
))
&&
line
.contains
(
&
ee
.kind
)
&&
(
ee
.kind
.is_none
()
||
line
.contains
(
&
ee
.kind
.as_ref
()
.unwrap
()
.to_string
())
)
&&
line
.contains
(
&
ee
.msg
)
{
found_flags
[
i
]
=
true
;
...
...
@@ -1096,7 +1096,10 @@ fn check_expected_errors(revision: Option<&str>,
if
!
flag
{
let
ee
=
&
expected_errors
[
i
];
error
(
revision
,
&
format!
(
"expected {} on line {} not found: {}"
,
ee
.kind
,
ee
.line_num
,
ee
.msg
));
ee
.kind
.as_ref
()
.map_or
(
"message"
.into
(),
|
k
|
k
.to_string
()),
ee
.line_num
,
ee
.msg
));
not_found
+=
1
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录