summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/npm_tests.rs81
-rw-r--r--cli/tests/testdata/npm/binary_package/main.js1
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/binary-package-linux/1.0.0/index.js1
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/binary-package-linux/1.0.0/package.json8
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/binary-package-mac/1.0.0/index.js1
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/binary-package-mac/1.0.0/package.json8
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/binary-package-windows/1.0.0/index.js1
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/binary-package-windows/1.0.0/package.json8
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/binary-package/1.0.0/index.js13
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/binary-package/1.0.0/package.json10
10 files changed, 132 insertions, 0 deletions
diff --git a/cli/tests/integration/npm_tests.rs b/cli/tests/integration/npm_tests.rs
index c04322027..dc3aa7b11 100644
--- a/cli/tests/integration/npm_tests.rs
+++ b/cli/tests/integration/npm_tests.rs
@@ -1799,3 +1799,84 @@ fn reload_info_not_found_cache_but_exists_remote() {
output.assert_exit_code(0);
}
}
+
+#[test]
+fn binary_package_with_optional_dependencies() {
+ let context = TestContextBuilder::for_npm()
+ .use_sync_npm_download()
+ .use_separate_deno_dir() // the "npm" folder means something in the deno dir, so use a separate folder
+ .use_copy_temp_dir("npm/binary_package")
+ .cwd("npm/binary_package")
+ .build();
+
+ let temp_dir = context.temp_dir();
+ let temp_dir_path = temp_dir.path();
+ let project_path = temp_dir_path.join("npm/binary_package");
+
+ // write empty config file so a lockfile gets created
+ temp_dir.write("npm/binary_package/deno.json", "{}");
+
+ // run it twice, with the first time creating the lockfile and the second using it
+ for i in 0..2 {
+ if i == 1 {
+ assert!(project_path.join("deno.lock").exists());
+ }
+
+ let output = context
+ .new_command()
+ .args("run -A --node-modules-dir main.js")
+ .run();
+
+ #[cfg(target_os = "windows")]
+ {
+ output.assert_exit_code(0);
+ output.assert_matches_text(
+ "[WILDCARD]Hello from binary package on windows[WILDCARD]",
+ );
+ assert!(project_path
+ .join("node_modules/.deno/@denotest+binary-package-windows@1.0.0")
+ .exists());
+ assert!(!project_path
+ .join("node_modules/.deno/@denotest+binary-package-linux@1.0.0")
+ .exists());
+ assert!(!project_path
+ .join("node_modules/.deno/@denotest+binary-package-mac@1.0.0")
+ .exists());
+ }
+
+ #[cfg(target_os = "macos")]
+ {
+ output.assert_exit_code(0);
+ output.assert_matches_text(
+ "[WILDCARD]Hello from binary package on mac[WILDCARD]",
+ );
+
+ assert!(!project_path
+ .join("node_modules/.deno/@denotest+binary-package-windows@1.0.0")
+ .exists());
+ assert!(!project_path
+ .join("node_modules/.deno/@denotest+binary-package-linux@1.0.0")
+ .exists());
+ assert!(project_path
+ .join("node_modules/.deno/@denotest+binary-package-mac@1.0.0")
+ .exists());
+ }
+
+ #[cfg(target_os = "linux")]
+ {
+ output.assert_exit_code(0);
+ output.assert_matches_text(
+ "[WILDCARD]Hello from binary package on linux[WILDCARD]",
+ );
+ assert!(!project_path
+ .join("node_modules/.deno/@denotest+binary-package-windows@1.0.0")
+ .exists());
+ assert!(project_path
+ .join("node_modules/.deno/@denotest+binary-package-linux@1.0.0")
+ .exists());
+ assert!(!project_path
+ .join("node_modules/.deno/@denotest+binary-package-mac@1.0.0")
+ .exists());
+ }
+ }
+}
diff --git a/cli/tests/testdata/npm/binary_package/main.js b/cli/tests/testdata/npm/binary_package/main.js
new file mode 100644
index 000000000..8823c5a5b
--- /dev/null
+++ b/cli/tests/testdata/npm/binary_package/main.js
@@ -0,0 +1 @@
+import "npm:@denotest/binary-package";
diff --git a/cli/tests/testdata/npm/registry/@denotest/binary-package-linux/1.0.0/index.js b/cli/tests/testdata/npm/registry/@denotest/binary-package-linux/1.0.0/index.js
new file mode 100644
index 000000000..03ecfc377
--- /dev/null
+++ b/cli/tests/testdata/npm/registry/@denotest/binary-package-linux/1.0.0/index.js
@@ -0,0 +1 @@
+console.log("Hello from binary package on linux"); \ No newline at end of file
diff --git a/cli/tests/testdata/npm/registry/@denotest/binary-package-linux/1.0.0/package.json b/cli/tests/testdata/npm/registry/@denotest/binary-package-linux/1.0.0/package.json
new file mode 100644
index 000000000..3b450e0d9
--- /dev/null
+++ b/cli/tests/testdata/npm/registry/@denotest/binary-package-linux/1.0.0/package.json
@@ -0,0 +1,8 @@
+{
+ "name": "@denotest/binary-package-linux",
+ "version": "1.0.0",
+ "main": "index.js",
+ "os": [
+ "linux"
+ ]
+}
diff --git a/cli/tests/testdata/npm/registry/@denotest/binary-package-mac/1.0.0/index.js b/cli/tests/testdata/npm/registry/@denotest/binary-package-mac/1.0.0/index.js
new file mode 100644
index 000000000..ac8c91f50
--- /dev/null
+++ b/cli/tests/testdata/npm/registry/@denotest/binary-package-mac/1.0.0/index.js
@@ -0,0 +1 @@
+console.log("Hello from binary package on mac"); \ No newline at end of file
diff --git a/cli/tests/testdata/npm/registry/@denotest/binary-package-mac/1.0.0/package.json b/cli/tests/testdata/npm/registry/@denotest/binary-package-mac/1.0.0/package.json
new file mode 100644
index 000000000..02916e65b
--- /dev/null
+++ b/cli/tests/testdata/npm/registry/@denotest/binary-package-mac/1.0.0/package.json
@@ -0,0 +1,8 @@
+{
+ "name": "@denotest/binary-package-linux",
+ "version": "1.0.0",
+ "main": "index.js",
+ "os": [
+ "darwin"
+ ]
+}
diff --git a/cli/tests/testdata/npm/registry/@denotest/binary-package-windows/1.0.0/index.js b/cli/tests/testdata/npm/registry/@denotest/binary-package-windows/1.0.0/index.js
new file mode 100644
index 000000000..57344ca00
--- /dev/null
+++ b/cli/tests/testdata/npm/registry/@denotest/binary-package-windows/1.0.0/index.js
@@ -0,0 +1 @@
+console.log("Hello from binary package on windows"); \ No newline at end of file
diff --git a/cli/tests/testdata/npm/registry/@denotest/binary-package-windows/1.0.0/package.json b/cli/tests/testdata/npm/registry/@denotest/binary-package-windows/1.0.0/package.json
new file mode 100644
index 000000000..1c0af637d
--- /dev/null
+++ b/cli/tests/testdata/npm/registry/@denotest/binary-package-windows/1.0.0/package.json
@@ -0,0 +1,8 @@
+{
+ "name": "@denotest/binary-package-windows",
+ "version": "1.0.0",
+ "main": "index.js",
+ "os": [
+ "win32"
+ ]
+}
diff --git a/cli/tests/testdata/npm/registry/@denotest/binary-package/1.0.0/index.js b/cli/tests/testdata/npm/registry/@denotest/binary-package/1.0.0/index.js
new file mode 100644
index 000000000..5870118e7
--- /dev/null
+++ b/cli/tests/testdata/npm/registry/@denotest/binary-package/1.0.0/index.js
@@ -0,0 +1,13 @@
+const packageByOs = {
+ "darwin": "@denotest/binary-package-mac",
+ "linux": "@denotest/binary-package-linux",
+ "win32": "@denotest/binary-package-windows",
+}
+
+const selectedPackage = packageByOs[process.platform];
+
+if (!selectedPackage) {
+ throw new Error("trying to run on unsupported platform");
+}
+
+require(selectedPackage); \ No newline at end of file
diff --git a/cli/tests/testdata/npm/registry/@denotest/binary-package/1.0.0/package.json b/cli/tests/testdata/npm/registry/@denotest/binary-package/1.0.0/package.json
new file mode 100644
index 000000000..dc8859bb4
--- /dev/null
+++ b/cli/tests/testdata/npm/registry/@denotest/binary-package/1.0.0/package.json
@@ -0,0 +1,10 @@
+{
+ "name": "@denotest/binary-package",
+ "version": "1.0.0",
+ "main": "index.js",
+ "optionalDependencies": {
+ "@denotest/binary-package-linux": "1.0.0",
+ "@denotest/binary-package-mac": "1.0.0",
+ "@denotest/binary-package-windows": "1.0.0"
+ }
+}