mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
fmt
This commit is contained in:
parent
2fd3228525
commit
a5a6973df6
1 changed files with 7 additions and 11 deletions
|
@ -1,11 +1,11 @@
|
||||||
extern crate file;
|
extern crate file;
|
||||||
extern crate walkdir;
|
|
||||||
extern crate itertools;
|
extern crate itertools;
|
||||||
|
extern crate walkdir;
|
||||||
|
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
||||||
use std::path::{PathBuf, Path};
|
use std::path::{Path, PathBuf};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Eq)]
|
#[derive(Debug, Eq)]
|
||||||
struct Test {
|
struct Test {
|
||||||
name: String,
|
name: String,
|
||||||
|
@ -57,13 +56,12 @@ fn tests_from_dir(dir: &Path) -> HashSet<Test> {
|
||||||
for entry in WalkDir::new(dir) {
|
for entry in WalkDir::new(dir) {
|
||||||
let entry = entry.unwrap();
|
let entry = entry.unwrap();
|
||||||
if !entry.file_type().is_file() {
|
if !entry.file_type().is_file() {
|
||||||
continue
|
continue;
|
||||||
}
|
}
|
||||||
if entry.path().extension().unwrap_or_default() != "rs" {
|
if entry.path().extension().unwrap_or_default() != "rs" {
|
||||||
continue
|
continue;
|
||||||
}
|
}
|
||||||
let text = file::get_text(entry.path())
|
let text = file::get_text(entry.path()).unwrap();
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
for test in collect_tests(&text) {
|
for test in collect_tests(&text) {
|
||||||
if let Some(old_test) = res.replace(test) {
|
if let Some(old_test) = res.replace(test) {
|
||||||
|
@ -88,7 +86,7 @@ fn collect_tests(s: &str) -> Vec<Test> {
|
||||||
let mut block = block.map(|line| &line[prefix.len()..]);
|
let mut block = block.map(|line| &line[prefix.len()..]);
|
||||||
let first = block.next().unwrap();
|
let first = block.next().unwrap();
|
||||||
if !first.starts_with("test ") {
|
if !first.starts_with("test ") {
|
||||||
continue
|
continue;
|
||||||
}
|
}
|
||||||
let name = first["test ".len()..].to_string();
|
let name = first["test ".len()..].to_string();
|
||||||
let text: String = itertools::join(block.chain(::std::iter::once("")), "\n");
|
let text: String = itertools::join(block.chain(::std::iter::once("")), "\n");
|
||||||
|
@ -104,7 +102,7 @@ fn existing_tests() -> HashSet<Test> {
|
||||||
let file = file.unwrap();
|
let file = file.unwrap();
|
||||||
let path = file.path();
|
let path = file.path();
|
||||||
if path.extension().unwrap_or_default() != "rs" {
|
if path.extension().unwrap_or_default() != "rs" {
|
||||||
continue
|
continue;
|
||||||
}
|
}
|
||||||
let name = path.file_name().unwrap().to_str().unwrap();
|
let name = path.file_name().unwrap().to_str().unwrap();
|
||||||
let name = name["0000_".len()..name.len() - 3].to_string();
|
let name = name["0000_".len()..name.len() - 3].to_string();
|
||||||
|
@ -130,5 +128,3 @@ fn base_dir() -> PathBuf {
|
||||||
let dir = env!("CARGO_MANIFEST_DIR");
|
let dir = env!("CARGO_MANIFEST_DIR");
|
||||||
PathBuf::from(dir).parent().unwrap().to_owned()
|
PathBuf::from(dir).parent().unwrap().to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue