Skip to content

Commit 02ba107

Browse files
bors[bot]matklad
andcommitted
Merge #1265
1265: drop obsolete render test subcommand r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 1944fc2 + 8ee2926 commit 02ba107

File tree

2 files changed

+7
-34
lines changed

2 files changed

+7
-34
lines changed

crates/ra_cli/src/analysis_stats.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use ra_syntax::AstNode;
77

88
use crate::Result;
99

10-
pub fn run(verbose: bool, only: Option<&str>) -> Result<()> {
10+
pub fn run(verbose: bool, path: &str, only: Option<&str>) -> Result<()> {
1111
let db_load_time = Instant::now();
12-
let (db, roots) = BatchDatabase::load_cargo(".")?;
12+
let (db, roots) = BatchDatabase::load_cargo(path)?;
1313
println!("Database loaded, {} roots, {:?}", roots.len(), db_load_time.elapsed());
1414
let analysis_time = Instant::now();
1515
let mut num_crates = 0;

crates/ra_cli/src/main.rs

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
mod analysis_stats;
22

3-
use std::{fs, io::Read, path::Path};
3+
use std::io::Read;
44

55
use clap::{App, Arg, SubCommand};
66
use ra_ide_api::file_structure;
77
use ra_syntax::{SourceFile, TreeArc, AstNode};
8-
use tools::collect_tests;
98
use flexi_logger::Logger;
109
use ra_prof::profile;
1110

@@ -15,17 +14,13 @@ fn main() -> Result<()> {
1514
Logger::with_env().start()?;
1615
let matches = App::new("ra-cli")
1716
.setting(clap::AppSettings::SubcommandRequiredElseHelp)
18-
.subcommand(
19-
SubCommand::with_name("render-test")
20-
.arg(Arg::with_name("line").long("--line").required(true).takes_value(true))
21-
.arg(Arg::with_name("file").long("--file").required(true).takes_value(true)),
22-
)
2317
.subcommand(SubCommand::with_name("parse").arg(Arg::with_name("no-dump").long("--no-dump")))
2418
.subcommand(SubCommand::with_name("symbols"))
2519
.subcommand(
2620
SubCommand::with_name("analysis-stats")
2721
.arg(Arg::with_name("verbose").short("v"))
28-
.arg(Arg::with_name("only").short("o").takes_value(true)),
22+
.arg(Arg::with_name("only").short("o").takes_value(true))
23+
.arg(Arg::with_name("path")),
2924
)
3025
.get_matches();
3126
match matches.subcommand() {
@@ -43,18 +38,11 @@ fn main() -> Result<()> {
4338
println!("{:?}", s);
4439
}
4540
}
46-
("render-test", Some(matches)) => {
47-
let file = matches.value_of("file").unwrap();
48-
let file = Path::new(file);
49-
let line: usize = matches.value_of("line").unwrap().parse()?;
50-
let line = line - 1;
51-
let (test, tree) = render_test(file, line)?;
52-
println!("{}\n{}", test, tree);
53-
}
5441
("analysis-stats", Some(matches)) => {
5542
let verbose = matches.is_present("verbose");
43+
let path = matches.value_of("path").unwrap_or("");
5644
let only = matches.value_of("only");
57-
analysis_stats::run(verbose, only)?;
45+
analysis_stats::run(verbose, path, only)?;
5846
}
5947
_ => unreachable!(),
6048
}
@@ -71,18 +59,3 @@ fn read_stdin() -> Result<String> {
7159
::std::io::stdin().read_to_string(&mut buff)?;
7260
Ok(buff)
7361
}
74-
75-
fn render_test(file: &Path, line: usize) -> Result<(String, String)> {
76-
let text = fs::read_to_string(file)?;
77-
let tests = collect_tests(&text);
78-
let test = tests.into_iter().find(|(start_line, t)| {
79-
*start_line <= line && line <= *start_line + t.text.lines().count()
80-
});
81-
let test = match test {
82-
None => failure::bail!("No test found at line {} at {}", line, file.display()),
83-
Some((_start_line, test)) => test,
84-
};
85-
let file = SourceFile::parse(&test.text);
86-
let tree = file.syntax().debug_dump();
87-
Ok((test.text, tree))
88-
}

0 commit comments

Comments
 (0)