summaryrefslogtreecommitdiff
path: root/tests/util
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-07-03 20:54:33 -0400
committerGitHub <noreply@github.com>2024-07-04 00:54:33 +0000
commit147411e64b22fe74cb258125acab83f9182c9f81 (patch)
treea1f63dcbf0404c20534986b10f02b649df5a3ad5 /tests/util
parentdd6d19e12051fac2ea5639f621501f4710a1b8e1 (diff)
feat: npm workspace and better Deno workspace support (#24334)
Adds much better support for the unstable Deno workspaces as well as support for npm workspaces. npm workspaces is still lacking in that we only install packages into the root node_modules folder. We'll make it smarter over time in order for it to figure out when to add node_modules folders within packages. This includes a breaking change in config file resolution where we stop searching for config files on the first found package.json unless it's in a workspace. For the previous behaviour, the root deno.json needs to be updated to be a workspace by adding `"workspace": ["./path-to-pkg-json-folder-goes-here"]`. See details in https://github.com/denoland/deno_config/pull/66 Closes #24340 Closes #24159 Closes #24161 Closes #22020 Closes #18546 Closes #16106 Closes #24160
Diffstat (limited to 'tests/util')
-rw-r--r--tests/util/server/src/builders.rs38
1 files changed, 32 insertions, 6 deletions
diff --git a/tests/util/server/src/builders.rs b/tests/util/server/src/builders.rs
index 4130a44e7..698543f50 100644
--- a/tests/util/server/src/builders.rs
+++ b/tests/util/server/src/builders.rs
@@ -89,6 +89,7 @@ pub struct TestContextBuilder {
use_http_server: bool,
use_temp_cwd: bool,
use_symlinked_temp_dir: bool,
+ use_canonicalized_temp_dir: bool,
/// Copies the files at the specified directory in the "testdata" directory
/// to the temp folder and runs the test from there. This is useful when
/// the test creates files in the testdata directory (ex. a node_modules folder)
@@ -143,6 +144,23 @@ impl TestContextBuilder {
self
}
+ /// Causes the temp directory to go to its canonicalized path instead
+ /// of being in a symlinked temp dir on the CI.
+ ///
+ /// Note: This method is not actually deprecated. It's just deprecated
+ /// to discourage its use. Use it sparingly and document why you're using
+ /// it. You better have a good reason other than being lazy!
+ ///
+ /// If your tests are failing because the temp dir is symlinked on the CI,
+ /// then it likely means your code doesn't properly handle when Deno is running
+ /// in a symlinked directory. That's a bug and you should fix it without using
+ /// this.
+ #[deprecated]
+ pub fn use_canonicalized_temp_dir(mut self) -> Self {
+ self.use_canonicalized_temp_dir = true;
+ self
+ }
+
/// Copies the files at the specified directory in the "testdata" directory
/// to the temp folder and runs the test from there. This is useful when
/// the test creates files in the testdata directory (ex. a node_modules folder)
@@ -207,13 +225,21 @@ impl TestContextBuilder {
panic!("{}", err);
}
- let temp_dir_path = self
- .temp_dir_path
- .clone()
- .unwrap_or_else(std::env::temp_dir);
- let deno_dir = TempDir::new_in(&temp_dir_path);
- let temp_dir = TempDir::new_in(&temp_dir_path);
+ let temp_dir_path = PathRef::new(
+ self
+ .temp_dir_path
+ .clone()
+ .unwrap_or_else(std::env::temp_dir),
+ );
+ let temp_dir_path = if self.use_canonicalized_temp_dir {
+ temp_dir_path.canonicalize()
+ } else {
+ temp_dir_path
+ };
+ let deno_dir = TempDir::new_in(temp_dir_path.as_path());
+ let temp_dir = TempDir::new_in(temp_dir_path.as_path());
let temp_dir = if self.use_symlinked_temp_dir {
+ assert!(!self.use_canonicalized_temp_dir); // code doesn't handle using both of these
TempDir::new_symlinked(temp_dir)
} else {
temp_dir