mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Check installed extension
This commit is contained in:
parent
bbaf750b10
commit
cb60416cb5
2 changed files with 45 additions and 12 deletions
|
@ -2,7 +2,7 @@ use std::{
|
|||
fs,
|
||||
collections::HashMap,
|
||||
path::{Path, PathBuf},
|
||||
process::{Command, Stdio},
|
||||
process::{Command, Output, Stdio},
|
||||
io::{Error, ErrorKind}
|
||||
};
|
||||
|
||||
|
@ -80,15 +80,14 @@ pub fn project_root() -> PathBuf {
|
|||
}
|
||||
|
||||
pub fn run(cmdline: &str, dir: &str) -> Result<()> {
|
||||
eprintln!("\nwill run: {}", cmdline);
|
||||
let project_dir = project_root().join(dir);
|
||||
let mut args = cmdline.split_whitespace();
|
||||
let exec = args.next().unwrap();
|
||||
let status = Command::new(exec).args(args).current_dir(project_dir).status()?;
|
||||
if !status.success() {
|
||||
bail!("`{}` exited with {}", cmdline, status);
|
||||
}
|
||||
Ok(())
|
||||
do_run(cmdline, dir, |c| {
|
||||
c.stdout(Stdio::inherit());
|
||||
})
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
pub fn run_with_output(cmdline: &str, dir: &str) -> Result<Output> {
|
||||
do_run(cmdline, dir, |_| {})
|
||||
}
|
||||
|
||||
pub fn run_rustfmt(mode: Mode) -> Result<()> {
|
||||
|
@ -175,6 +174,23 @@ pub fn gen_tests(mode: Mode) -> Result<()> {
|
|||
install_tests(&tests.err, ERR_INLINE_TESTS_DIR, mode)
|
||||
}
|
||||
|
||||
fn do_run<F>(cmdline: &str, dir: &str, mut f: F) -> Result<Output>
|
||||
where
|
||||
F: FnMut(&mut Command),
|
||||
{
|
||||
eprintln!("\nwill run: {}", cmdline);
|
||||
let proj_dir = project_root().join(dir);
|
||||
let mut args = cmdline.split_whitespace();
|
||||
let exec = args.next().unwrap();
|
||||
let mut cmd = Command::new(exec);
|
||||
f(cmd.args(args).current_dir(proj_dir).stderr(Stdio::inherit()));
|
||||
let output = cmd.output()?;
|
||||
if !output.status.success() {
|
||||
bail!("`{}` exited with {}", cmdline, output.status);
|
||||
}
|
||||
Ok(output)
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
struct Tests {
|
||||
pub ok: HashMap<String, Test>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue