summaryrefslogtreecommitdiff
path: root/tests/specs/mod.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-11-13 10:10:09 -0500
committerGitHub <noreply@github.com>2024-11-13 15:10:09 +0000
commitf091d1ad69b4e5217ae3272b641171781a372c4f (patch)
tree4ef4f90ec8a6b5c977efb187449f8c59c45de5e1 /tests/specs/mod.rs
parent6a4c6d83bacf5f03628a494778a30bce970f7cbc (diff)
feat(node): stabilize detecting if CJS via `"type": "commonjs"` in a package.json (#26439)
This will respect `"type": "commonjs"` in a package.json to determine if `.js`/`.jsx`/`.ts`/.tsx` files are CJS or ESM. If the file is found to be ESM it will be loaded as ESM though.
Diffstat (limited to 'tests/specs/mod.rs')
-rw-r--r--tests/specs/mod.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/specs/mod.rs b/tests/specs/mod.rs
index 34221dd9d..b4c8781d3 100644
--- a/tests/specs/mod.rs
+++ b/tests/specs/mod.rs
@@ -119,6 +119,9 @@ struct MultiStepMetaData {
/// steps.
#[serde(default)]
pub temp_dir: bool,
+ /// Whether the temporary directory should be symlinked to another path.
+ #[serde(default)]
+ pub symlinked_temp_dir: bool,
/// The base environment to use for the test.
#[serde(default)]
pub base: Option<String>,
@@ -142,6 +145,8 @@ struct SingleTestMetaData {
#[serde(default)]
pub temp_dir: bool,
#[serde(default)]
+ pub symlinked_temp_dir: bool,
+ #[serde(default)]
pub repeat: Option<usize>,
#[serde(flatten)]
pub step: StepMetaData,
@@ -155,6 +160,7 @@ impl SingleTestMetaData {
base: self.base,
cwd: None,
temp_dir: self.temp_dir,
+ symlinked_temp_dir: self.symlinked_temp_dir,
repeat: self.repeat,
envs: Default::default(),
steps: vec![self.step],
@@ -330,6 +336,20 @@ fn test_context_from_metadata(
builder = builder.cwd(cwd.to_string_lossy());
}
+ if metadata.symlinked_temp_dir {
+ // not actually deprecated, we just want to discourage its use
+ // because it's mostly used for testing purposes locally
+ #[allow(deprecated)]
+ {
+ builder = builder.use_symlinked_temp_dir();
+ }
+ if cfg!(not(debug_assertions)) {
+ // panic to prevent using this on the CI as CI already uses
+ // a symlinked temp directory for every test
+ panic!("Cannot use symlinkedTempDir in release mode");
+ }
+ }
+
match &metadata.base {
// todo(dsherret): add bases in the future as needed
Some(base) => panic!("Unknown test base: {}", base),