Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
77d1185f
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
77d1185f
编写于
2月 20, 2021
作者:
T
The8472
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
parallelize tidy checks
上级
5233edcf
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
76 addition
and
39 deletion
+76
-39
Cargo.lock
Cargo.lock
+1
-0
src/tools/tidy/Cargo.toml
src/tools/tidy/Cargo.toml
+1
-0
src/tools/tidy/src/bins.rs
src/tools/tidy/src/bins.rs
+5
-2
src/tools/tidy/src/lib.rs
src/tools/tidy/src/lib.rs
+7
-0
src/tools/tidy/src/main.rs
src/tools/tidy/src/main.rs
+62
-37
未找到文件。
Cargo.lock
浏览文件 @
77d1185f
...
...
@@ -5239,6 +5239,7 @@ name = "tidy"
version = "0.1.0"
dependencies = [
"cargo_metadata 0.11.1",
"crossbeam-utils 0.8.0",
"lazy_static",
"regex",
"walkdir",
...
...
src/tools/tidy/Cargo.toml
浏览文件 @
77d1185f
...
...
@@ -10,6 +10,7 @@ cargo_metadata = "0.11"
regex
=
"1"
lazy_static
=
"1"
walkdir
=
"2"
crossbeam-utils
=
"0.8.0"
[[bin]]
name
=
"rust-tidy"
...
...
src/tools/tidy/src/bins.rs
浏览文件 @
77d1185f
...
...
@@ -32,9 +32,12 @@ fn is_executable(path: &Path) -> std::io::Result<bool> {
// readily create a file there to test.
//
// See #36706 and #74753 for context.
let
mut
temp_path
=
path
.join
(
"tidy-test-file"
);
//
// We also add the thread ID to avoid threads trampling on each others files.
let
file_name
=
format!
(
"t{}.tidy-test-file"
,
std
::
thread
::
current
()
.id
()
.as_u64
());
let
mut
temp_path
=
path
.join
(
&
file_name
);
match
fs
::
File
::
create
(
&
temp_path
)
.or_else
(|
_
|
{
temp_path
=
output
.join
(
"tidy-test-file"
);
temp_path
=
output
.join
(
&
file_name
);
fs
::
File
::
create
(
&
temp_path
)
})
{
Ok
(
file
)
=>
{
...
...
src/tools/tidy/src/lib.rs
浏览文件 @
77d1185f
...
...
@@ -4,6 +4,7 @@
//! to be used by tools.
#![cfg_attr(bootstrap,
feature(str_split_once))]
#![feature(thread_id_value)]
use
std
::
fs
::
File
;
use
std
::
io
::
Read
;
...
...
@@ -54,6 +55,12 @@
pub
mod
unstable_book
;
fn
filter_dirs
(
path
:
&
Path
)
->
bool
{
// Filter out temporary files used by the bins module to probe the filesystem
match
path
.extension
()
{
Some
(
ext
)
if
ext
==
"tidy-test-file"
=>
return
true
,
_
=>
{}
}
let
skip
=
[
"compiler/rustc_codegen_cranelift"
,
"src/llvm-project"
,
...
...
src/tools/tidy/src/main.rs
浏览文件 @
77d1185f
...
...
@@ -6,9 +6,11 @@
use
tidy
::
*
;
use
crossbeam_utils
::
thread
::
scope
;
use
std
::
env
;
use
std
::
path
::
PathBuf
;
use
std
::
process
;
use
std
::
sync
::
atomic
::{
AtomicBool
,
Ordering
};
fn
main
()
{
let
root_path
:
PathBuf
=
env
::
args_os
()
.nth
(
1
)
.expect
(
"need path to root of repo"
)
.into
();
...
...
@@ -22,45 +24,68 @@ fn main() {
let
args
:
Vec
<
String
>
=
env
::
args
()
.skip
(
1
)
.collect
();
let
mut
bad
=
false
;
let
verbose
=
args
.iter
()
.any
(|
s
|
*
s
==
"--verbose"
);
// Checks over tests.
debug_artifacts
::
check
(
&
src_path
,
&
mut
bad
);
ui_tests
::
check
(
&
src_path
,
&
mut
bad
);
// Checks that only make sense for the compiler.
errors
::
check
(
&
compiler_path
,
&
mut
bad
);
error_codes_check
::
check
(
&
src_path
,
&
mut
bad
);
// Checks that only make sense for the std libs.
pal
::
check
(
&
library_path
,
&
mut
bad
);
// Checks that need to be done for both the compiler and std libraries.
unit_tests
::
check
(
&
src_path
,
&
mut
bad
);
unit_tests
::
check
(
&
compiler_path
,
&
mut
bad
);
unit_tests
::
check
(
&
library_path
,
&
mut
bad
);
bins
::
check
(
&
src_path
,
&
output_directory
,
&
mut
bad
);
bins
::
check
(
&
compiler_path
,
&
output_directory
,
&
mut
bad
);
bins
::
check
(
&
library_path
,
&
output_directory
,
&
mut
bad
);
style
::
check
(
&
src_path
,
&
mut
bad
);
style
::
check
(
&
compiler_path
,
&
mut
bad
);
style
::
check
(
&
library_path
,
&
mut
bad
);
edition
::
check
(
&
src_path
,
&
mut
bad
);
edition
::
check
(
&
compiler_path
,
&
mut
bad
);
edition
::
check
(
&
library_path
,
&
mut
bad
);
let
collected
=
features
::
check
(
&
src_path
,
&
compiler_path
,
&
library_path
,
&
mut
bad
,
verbose
);
unstable_book
::
check
(
&
src_path
,
collected
,
&
mut
bad
);
// Checks that are done on the cargo workspace.
deps
::
check
(
&
root_path
,
&
cargo
,
&
mut
bad
);
extdeps
::
check
(
&
root_path
,
&
mut
bad
);
if
bad
{
let
bad
=
std
::
sync
::
Arc
::
new
(
AtomicBool
::
new
(
false
));
scope
(|
s
|
{
macro_rules!
check
{
(
$p:ident
$
(,
$args:expr
)
*
)
=>
{
s
.spawn
(|
_
|
{
let
mut
flag
=
false
;
$p
::
check
(
$
(
$args
),
*
,
&
mut
flag
);
if
(
flag
)
{
bad
.store
(
true
,
Ordering
::
Relaxed
);
}
});
}
}
// Checks that are done on the cargo workspace.
check!
(
deps
,
&
root_path
,
&
cargo
);
check!
(
extdeps
,
&
root_path
);
// Checks over tests.
check!
(
debug_artifacts
,
&
src_path
);
check!
(
ui_tests
,
&
src_path
);
// Checks that only make sense for the compiler.
check!
(
errors
,
&
compiler_path
);
check!
(
error_codes_check
,
&
src_path
);
// Checks that only make sense for the std libs.
check!
(
pal
,
&
library_path
);
// Checks that need to be done for both the compiler and std libraries.
check!
(
unit_tests
,
&
src_path
);
check!
(
unit_tests
,
&
compiler_path
);
check!
(
unit_tests
,
&
library_path
);
check!
(
bins
,
&
src_path
,
&
output_directory
);
check!
(
bins
,
&
compiler_path
,
&
output_directory
);
check!
(
bins
,
&
library_path
,
&
output_directory
);
check!
(
style
,
&
src_path
);
check!
(
style
,
&
compiler_path
);
check!
(
style
,
&
library_path
);
check!
(
edition
,
&
src_path
);
check!
(
edition
,
&
compiler_path
);
check!
(
edition
,
&
library_path
);
let
collected
=
{
let
mut
flag
=
false
;
let
r
=
features
::
check
(
&
src_path
,
&
compiler_path
,
&
library_path
,
&
mut
flag
,
verbose
);
if
flag
{
bad
.store
(
true
,
Ordering
::
Relaxed
);
}
r
};
check!
(
unstable_book
,
&
src_path
,
collected
);
})
.unwrap
();
if
bad
.load
(
Ordering
::
Relaxed
)
{
eprintln!
(
"some tidy checks failed"
);
process
::
exit
(
1
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录