Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
d6081314
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,发现更多精彩内容 >>
提交
d6081314
编写于
3月 12, 2012
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
std: Sort test failures. Closes #1929
上级
59a56ad0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
57 addition
and
15 deletion
+57
-15
src/libstd/test.rs
src/libstd/test.rs
+57
-15
未找到文件。
src/libstd/test.rs
浏览文件 @
d6081314
...
...
@@ -85,20 +85,20 @@ fn parse_opts(args: [str]) -> opt_res {
enum
test_result
{
tr_ok
,
tr_failed
,
tr_ignored
,
}
type
console_test_state
=
@
{
out
:
io
::
writer
,
use_color
:
bool
,
mutable
total
:
uint
,
mutable
passed
:
uint
,
mutable
failed
:
uint
,
mutable
ignored
:
uint
,
mutable
failures
:
[
test_desc
]};
// A simple console test runner
fn
run_tests_console
(
opts
:
test_opts
,
tests
:
[
test_desc
])
->
bool
{
type
test_state
=
@
{
out
:
io
::
writer
,
use_color
:
bool
,
mutable
total
:
uint
,
mutable
passed
:
uint
,
mutable
failed
:
uint
,
mutable
ignored
:
uint
,
mutable
failures
:
[
test_desc
]};
fn
callback
(
event
:
testevent
,
st
:
test_state
)
{
fn
callback
(
event
:
testevent
,
st
:
console_test_state
)
{
alt
event
{
te_filtered
(
filtered_tests
)
{
st
.total
=
vec
::
len
(
filtered_tests
);
...
...
@@ -143,11 +143,7 @@ fn callback(event: testevent, st: test_state) {
let
success
=
st
.failed
==
0u
;
if
!
success
{
st
.out
.write_line
(
"
\n
failures:"
);
for
test
:
test_desc
in
st
.failures
{
let
testname
=
test
.name
;
// Satisfy alias analysis
st
.out
.write_line
(
#
fmt
[
" %s"
,
testname
]);
}
print_failures
(
st
);
}
st
.out
.write_str
(
#
fmt
[
"
\n
result: "
]);
...
...
@@ -183,6 +179,52 @@ fn write_pretty(out: io::writer, word: str, color: u8, use_color: bool) {
}
}
fn
print_failures
(
st
:
console_test_state
)
{
st
.out
.write_line
(
"
\n
failures:"
);
let
failures
=
vec
::
map
(
copy
st
.failures
)
{|
test
|
test
.name
};
let
failures
=
sort
::
merge_sort
(
str
::
le
,
failures
);
for
name
in
failures
{
st
.out
.write_line
(
#
fmt
[
" %s"
,
name
]);
}
}
#[test]
fn
should_sort_failures_before_printing_them
()
{
let
buffer
=
io
::
mk_mem_buffer
();
let
writer
=
io
::
mem_buffer_writer
(
buffer
);
let
test_a
=
{
name
:
"a"
,
fn
:
fn
~
()
{
},
ignore
:
false
,
should_fail
:
false
};
let
test_b
=
{
name
:
"b"
,
fn
:
fn
~
()
{
},
ignore
:
false
,
should_fail
:
false
};
let
st
=
@
{
out
:
writer
,
use_color
:
false
,
mutable
total
:
0u
,
mutable
passed
:
0u
,
mutable
failed
:
0u
,
mutable
ignored
:
0u
,
mutable
failures
:
[
test_b
,
test_a
]};
print_failures
(
st
);
let
s
=
io
::
mem_buffer_str
(
buffer
);
let
apos
=
option
::
get
(
str
::
find_str
(
s
,
"a"
));
let
bpos
=
option
::
get
(
str
::
find_str
(
s
,
"b"
));
assert
apos
<
bpos
;
}
fn
use_color
()
->
bool
{
ret
get_concurrency
()
==
1u
;
}
enum
testevent
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录