diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-09-22 11:17:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-22 11:17:02 -0400 |
commit | 716005a0d4afd1042fa75d8bdc32fd13e9ebe95f (patch) | |
tree | 4c417eb7b91d6203aacba7dcd81bee3f13c0cfd3 /test_util/src | |
parent | 9a216806d514b5f41c73c777010572cdf3c51eab (diff) |
feat(npm): add flag for creating and resolving npm packages to a local node_modules folder (#15971)
Diffstat (limited to 'test_util/src')
-rw-r--r-- | test_util/src/lib.rs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/test_util/src/lib.rs b/test_util/src/lib.rs index 5a357ee7d..73fe3ff9b 100644 --- a/test_util/src/lib.rs +++ b/test_util/src/lib.rs @@ -1861,6 +1861,7 @@ pub struct CheckOutputIntegrationTest<'a> { pub http_server: bool, pub envs: Vec<(String, String)>, pub env_clear: bool, + pub temp_cwd: bool, } impl<'a> CheckOutputIntegrationTest<'a> { @@ -1874,6 +1875,11 @@ impl<'a> CheckOutputIntegrationTest<'a> { ); std::borrow::Cow::Borrowed(&self.args_vec) }; + let testdata_dir = testdata_path(); + let args = args + .iter() + .map(|arg| arg.replace("$TESTDATA", &testdata_dir.to_string_lossy())) + .collect::<Vec<_>>(); let deno_exe = deno_exe_path(); println!("deno_exe path {}", deno_exe.display()); @@ -1884,17 +1890,21 @@ impl<'a> CheckOutputIntegrationTest<'a> { }; let (mut reader, writer) = pipe().unwrap(); - let testdata_dir = testdata_path(); let deno_dir = new_deno_dir(); // keep this alive for the test let mut command = deno_cmd_with_deno_dir(&deno_dir); - println!("deno_exe args {}", self.args); - println!("deno_exe testdata path {:?}", &testdata_dir); + let cwd = if self.temp_cwd { + deno_dir.path() + } else { + testdata_dir.as_path() + }; + println!("deno_exe args {}", args.join(" ")); + println!("deno_exe cwd {:?}", &testdata_dir); command.args(args.iter()); if self.env_clear { command.env_clear(); } command.envs(self.envs.clone()); - command.current_dir(&testdata_dir); + command.current_dir(&cwd); command.stdin(Stdio::piped()); let writer_clone = writer.try_clone().unwrap(); command.stderr(writer_clone); @@ -1949,7 +1959,7 @@ impl<'a> CheckOutputIntegrationTest<'a> { // deno test's output capturing flushes with a zero-width space in order to // synchronize the output pipes. Occassionally this zero width space // might end up in the output so strip it from the output comparison here. - if args.first() == Some(&"test") { + if args.first().map(|s| s.as_str()) == Some("test") { actual = actual.replace('\u{200B}', ""); } |