mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-21 19:19:45 +00:00
editor launch fix + new test
This commit is contained in:
parent
e32cd140a8
commit
652dbde26e
13 changed files with 126 additions and 43 deletions
|
@ -4,6 +4,7 @@ extern crate roc_load;
|
|||
extern crate roc_module;
|
||||
extern crate tempfile;
|
||||
|
||||
use roc_utils::root_dir;
|
||||
use serde::Deserialize;
|
||||
use serde_xml_rs::from_str;
|
||||
use std::env;
|
||||
|
@ -27,9 +28,15 @@ where
|
|||
I: IntoIterator<Item = S>,
|
||||
S: AsRef<OsStr>,
|
||||
{
|
||||
let roc_binary_path = build_roc_bin_cached();
|
||||
|
||||
run_with_stdin_and_env(&roc_binary_path, args, stdin_vals, extra_env)
|
||||
}
|
||||
|
||||
// If we don't already have a /target/release/roc, build it!
|
||||
pub fn build_roc_bin_cached() -> PathBuf {
|
||||
let roc_binary_path = path_to_roc_binary();
|
||||
|
||||
// If we don't have a /target/release/roc, rebuild it!
|
||||
if !roc_binary_path.exists() {
|
||||
// Remove the /target/release/roc part
|
||||
let root_project_dir = roc_binary_path
|
||||
|
@ -48,21 +55,26 @@ where
|
|||
vec!["build", "--release", "--bin", "roc"]
|
||||
};
|
||||
|
||||
let output = Command::new("cargo")
|
||||
let run_command = "cargo";
|
||||
|
||||
let output = Command::new(run_command)
|
||||
.current_dir(root_project_dir)
|
||||
.args(args)
|
||||
.args(&args)
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
if !output.status.success() {
|
||||
panic!("cargo build --release --bin roc failed. stdout was:\n\n{:?}\n\nstderr was:\n\n{:?}\n",
|
||||
output.stdout,
|
||||
output.stderr
|
||||
panic!(
|
||||
"{} {} failed:\n\n stdout was:\n\n {}\n\n stderr was:\n\n {}\n",
|
||||
run_command,
|
||||
args.join(" "),
|
||||
String::from_utf8(output.stdout).unwrap(),
|
||||
String::from_utf8(output.stderr).unwrap()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
run_with_stdin_and_env(&roc_binary_path, args, stdin_vals, extra_env)
|
||||
roc_binary_path
|
||||
}
|
||||
|
||||
pub fn run_glue<I, S>(args: I) -> Out
|
||||
|
@ -357,30 +369,6 @@ pub fn extract_valgrind_errors(xml: &str) -> Result<Vec<ValgrindError>, serde_xm
|
|||
Ok(answer)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn root_dir() -> PathBuf {
|
||||
let mut path = env::current_exe().ok().unwrap();
|
||||
|
||||
// Get rid of the filename in target/debug/deps/cli_run-99c65e4e9a1fbd06
|
||||
path.pop();
|
||||
|
||||
// If we're in deps/ get rid of deps/ in target/debug/deps/
|
||||
if path.ends_with("deps") {
|
||||
path.pop();
|
||||
}
|
||||
|
||||
// Get rid of target/debug/ so we're back at the project root
|
||||
path.pop();
|
||||
path.pop();
|
||||
|
||||
// running cargo with --target will put us in the target dir
|
||||
if path.ends_with("target") {
|
||||
path.pop();
|
||||
}
|
||||
|
||||
path
|
||||
}
|
||||
|
||||
// start the dir with crates/cli_testing_examples
|
||||
#[allow(dead_code)]
|
||||
pub fn cli_testing_dir(dir_name: &str) -> PathBuf {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue