Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
d857f6f1
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,发现更多精彩内容 >>
提交
d857f6f1
编写于
1月 24, 2020
作者:
T
Tomasz Miąsko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
compiletest: Add unit tests for EarlyProps
上级
bb6aac38
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
155 addition
and
1 deletion
+155
-1
src/tools/compiletest/src/header/tests.rs
src/tools/compiletest/src/header/tests.rs
+155
-1
未找到文件。
src/tools/compiletest/src/header/tests.rs
浏览文件 @
d857f6f1
use
super
::
*
;
use
std
::
path
::
Path
;
use
crate
::
common
::{
Config
,
Debugger
};
use
crate
::
header
::{
parse_normalization_string
,
EarlyProps
};
#[test]
fn
test_parse_normalization_string
()
{
...
...
@@ -25,3 +28,154 @@ fn test_parse_normalization_string() {
assert_eq!
(
first
,
Some
(
"something (32 bits)"
.to_owned
()));
assert_eq!
(
s
,
" ->
\"
something ($WORD bits)."
);
}
fn
config
()
->
Config
{
let
args
=
&
[
"compiletest"
,
"--mode=ui"
,
"--compile-lib-path="
,
"--run-lib-path="
,
"--rustc-path="
,
"--lldb-python="
,
"--docck-python="
,
"--src-base="
,
"--build-base="
,
"--stage-id=stage2"
,
"--cc=c"
,
"--cxx=c++"
,
"--cflags="
,
"--llvm-components="
,
"--llvm-cxxflags="
,
"--android-cross-path="
,
"--target=x86_64-unknown-linux-gnu"
,
];
let
args
=
args
.iter
()
.map
(
ToString
::
to_string
)
.collect
();
crate
::
parse_config
(
args
)
}
fn
parse_rs
(
config
:
&
Config
,
contents
:
&
str
)
->
EarlyProps
{
let
bytes
=
contents
.as_bytes
();
EarlyProps
::
from_reader
(
config
,
Path
::
new
(
"a.rs"
),
bytes
)
}
fn
parse_makefile
(
config
:
&
Config
,
contents
:
&
str
)
->
EarlyProps
{
let
bytes
=
contents
.as_bytes
();
EarlyProps
::
from_reader
(
config
,
Path
::
new
(
"Makefile"
),
bytes
)
}
#[test]
fn
should_fail
()
{
let
config
=
config
();
assert
!
(
!
parse_rs
(
&
config
,
""
)
.should_fail
);
assert
!
(
parse_rs
(
&
config
,
"// should-fail"
)
.should_fail
);
}
#[test]
fn
revisions
()
{
let
config
=
config
();
assert_eq!
(
parse_rs
(
&
config
,
"// revisions: a b c"
)
.revisions
,
vec!
[
"a"
,
"b"
,
"c"
],);
assert_eq!
(
parse_makefile
(
&
config
,
"# revisions: hello there"
)
.revisions
,
vec!
[
"hello"
,
"there"
],
);
}
#[test]
fn
aux_build
()
{
let
config
=
config
();
assert_eq!
(
parse_rs
(
&
config
,
r"
// aux-build: a.rs
// aux-build: b.rs
"
)
.aux
,
vec!
[
"a.rs"
,
"b.rs"
],
);
}
#[test]
fn
no_system_llvm
()
{
let
mut
config
=
config
();
config
.system_llvm
=
false
;
assert
!
(
!
parse_rs
(
&
config
,
"// no-system-llvm"
)
.ignore
);
config
.system_llvm
=
true
;
assert
!
(
parse_rs
(
&
config
,
"// no-system-llvm"
)
.ignore
);
}
#[test]
fn
ignore_target
()
{
let
mut
config
=
config
();
config
.target
=
"x86_64-unknown-linux-gnu"
.to_owned
();
assert
!
(
parse_rs
(
&
config
,
"// ignore-x86_64-unknown-linux-gnu"
)
.ignore
);
assert
!
(
parse_rs
(
&
config
,
"// ignore-x86_64"
)
.ignore
);
assert
!
(
parse_rs
(
&
config
,
"// ignore-linux"
)
.ignore
);
assert
!
(
parse_rs
(
&
config
,
"// ignore-gnu"
)
.ignore
);
assert
!
(
parse_rs
(
&
config
,
"// ignore-64bit"
)
.ignore
);
assert
!
(
!
parse_rs
(
&
config
,
"// ignore-i686"
)
.ignore
);
assert
!
(
!
parse_rs
(
&
config
,
"// ignore-windows"
)
.ignore
);
assert
!
(
!
parse_rs
(
&
config
,
"// ignore-msvc"
)
.ignore
);
assert
!
(
!
parse_rs
(
&
config
,
"// ignore-32bit"
)
.ignore
);
}
#[test]
fn
only_target
()
{
let
mut
config
=
config
();
config
.target
=
"x86_64-pc-windows-gnu"
.to_owned
();
assert
!
(
parse_rs
(
&
config
,
"// only-i686"
)
.ignore
);
assert
!
(
parse_rs
(
&
config
,
"// only-linux"
)
.ignore
);
assert
!
(
parse_rs
(
&
config
,
"// only-msvc"
)
.ignore
);
assert
!
(
parse_rs
(
&
config
,
"// only-32bit"
)
.ignore
);
assert
!
(
!
parse_rs
(
&
config
,
"// only-x86_64-pc-windows-gnu"
)
.ignore
);
assert
!
(
!
parse_rs
(
&
config
,
"// only-x86_64"
)
.ignore
);
assert
!
(
!
parse_rs
(
&
config
,
"// only-windows"
)
.ignore
);
assert
!
(
!
parse_rs
(
&
config
,
"// only-gnu"
)
.ignore
);
assert
!
(
!
parse_rs
(
&
config
,
"// only-64bit"
)
.ignore
);
}
#[test]
fn
stage
()
{
let
mut
config
=
config
();
config
.stage_id
=
"stage1"
.to_owned
();
assert
!
(
parse_rs
(
&
config
,
"// ignore-stage1"
)
.ignore
);
assert
!
(
!
parse_rs
(
&
config
,
"// ignore-stage2"
)
.ignore
);
}
#[test]
fn
cross_compile
()
{
let
mut
config
=
config
();
config
.host
=
"x86_64-apple-darwin"
.to_owned
();
config
.target
=
"wasm32-unknown-unknown"
.to_owned
();
assert
!
(
parse_rs
(
&
config
,
"// ignore-cross-compile"
)
.ignore
);
config
.target
=
config
.host
.clone
();
assert
!
(
!
parse_rs
(
&
config
,
"// ignore-cross-compile"
)
.ignore
);
}
#[test]
fn
debugger
()
{
let
mut
config
=
config
();
config
.debugger
=
None
;
assert
!
(
!
parse_rs
(
&
config
,
"// ignore-cdb"
)
.ignore
);
config
.debugger
=
Some
(
Debugger
::
Cdb
);
assert
!
(
parse_rs
(
&
config
,
"// ignore-cdb"
)
.ignore
);
config
.debugger
=
Some
(
Debugger
::
Gdb
);
assert
!
(
parse_rs
(
&
config
,
"// ignore-gdb"
)
.ignore
);
config
.debugger
=
Some
(
Debugger
::
Lldb
);
assert
!
(
parse_rs
(
&
config
,
"// ignore-lldb"
)
.ignore
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录