mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
test: Fix --reload in integration_tests (#9345)
This commit removes redundant "--reload" args because "util::deno_cmd" recreates "DENO_DIR". This commit also fixes ta_reload in integration tests to actually test reload.
This commit is contained in:
parent
9cc7e32e37
commit
f6a80f34d9
2 changed files with 18 additions and 10 deletions
|
@ -31,7 +31,6 @@ fn js_unit_tests() {
|
||||||
.current_dir(util::root_path())
|
.current_dir(util::root_path())
|
||||||
.arg("run")
|
.arg("run")
|
||||||
.arg("--unstable")
|
.arg("--unstable")
|
||||||
.arg("--reload")
|
|
||||||
.arg("-A")
|
.arg("-A")
|
||||||
.arg("cli/tests/unit/unit_test_runner.ts")
|
.arg("cli/tests/unit/unit_test_runner.ts")
|
||||||
.arg("--master")
|
.arg("--master")
|
||||||
|
@ -1328,31 +1327,37 @@ mod integration {
|
||||||
fn ts_reload() {
|
fn ts_reload() {
|
||||||
let hello_ts = util::root_path().join("cli/tests/002_hello.ts");
|
let hello_ts = util::root_path().join("cli/tests/002_hello.ts");
|
||||||
assert!(hello_ts.is_file());
|
assert!(hello_ts.is_file());
|
||||||
let mut initial = util::deno_cmd()
|
|
||||||
|
let deno_dir = TempDir::new().expect("tempdir fail");
|
||||||
|
let mut initial = util::deno_cmd_with_deno_dir(deno_dir.path())
|
||||||
.current_dir(util::root_path())
|
.current_dir(util::root_path())
|
||||||
.arg("cache")
|
.arg("cache")
|
||||||
.arg("--reload")
|
.arg(&hello_ts)
|
||||||
.arg(hello_ts.clone())
|
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("failed to spawn script");
|
.expect("failed to spawn script");
|
||||||
let status_initial =
|
let status_initial =
|
||||||
initial.wait().expect("failed to wait for child process");
|
initial.wait().expect("failed to wait for child process");
|
||||||
assert!(status_initial.success());
|
assert!(status_initial.success());
|
||||||
|
|
||||||
let output = util::deno_cmd()
|
let output = util::deno_cmd_with_deno_dir(deno_dir.path())
|
||||||
.current_dir(util::root_path())
|
.current_dir(util::root_path())
|
||||||
.arg("cache")
|
.arg("cache")
|
||||||
.arg("--reload")
|
.arg("--reload")
|
||||||
.arg("-L")
|
.arg("-L")
|
||||||
.arg("debug")
|
.arg("debug")
|
||||||
.arg(hello_ts)
|
.arg(&hello_ts)
|
||||||
.output()
|
.output()
|
||||||
.expect("failed to spawn script");
|
.expect("failed to spawn script");
|
||||||
|
|
||||||
// check the output of the the bundle program.
|
// check the output of the the bundle program.
|
||||||
|
let output_path = hello_ts.canonicalize().unwrap();
|
||||||
assert!(std::str::from_utf8(&output.stderr)
|
assert!(std::str::from_utf8(&output.stderr)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.trim()
|
.trim()
|
||||||
.contains("host.writeFile(\"deno://002_hello.js\")"));
|
.contains(&format!(
|
||||||
|
"host.getSourceFile(\"{}\", Latest)",
|
||||||
|
url::Url::from_file_path(&output_path).unwrap().as_str()
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1494,7 +1499,6 @@ mod integration {
|
||||||
let output = util::deno_cmd()
|
let output = util::deno_cmd()
|
||||||
.current_dir(util::root_path())
|
.current_dir(util::root_path())
|
||||||
.arg("run")
|
.arg("run")
|
||||||
.arg("--reload")
|
|
||||||
.arg(&bundle)
|
.arg(&bundle)
|
||||||
.output()
|
.output()
|
||||||
.expect("failed to spawn script");
|
.expect("failed to spawn script");
|
||||||
|
|
|
@ -1151,11 +1151,15 @@ pub fn new_deno_dir() -> TempDir {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deno_cmd() -> Command {
|
pub fn deno_cmd() -> Command {
|
||||||
let e = deno_exe_path();
|
|
||||||
let deno_dir = new_deno_dir();
|
let deno_dir = new_deno_dir();
|
||||||
|
deno_cmd_with_deno_dir(deno_dir.path())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn deno_cmd_with_deno_dir(deno_dir: &std::path::Path) -> Command {
|
||||||
|
let e = deno_exe_path();
|
||||||
assert!(e.exists());
|
assert!(e.exists());
|
||||||
let mut c = Command::new(e);
|
let mut c = Command::new(e);
|
||||||
c.env("DENO_DIR", deno_dir.path());
|
c.env("DENO_DIR", deno_dir);
|
||||||
c
|
c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue