diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-07-03 20:54:33 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-04 00:54:33 +0000 |
commit | 147411e64b22fe74cb258125acab83f9182c9f81 (patch) | |
tree | a1f63dcbf0404c20534986b10f02b649df5a3ad5 /tests | |
parent | dd6d19e12051fac2ea5639f621501f4710a1b8e1 (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')
185 files changed, 1666 insertions, 154 deletions
diff --git a/tests/integration/compile_tests.rs b/tests/integration/compile_tests.rs index 0d94d4367..c902adfb2 100644 --- a/tests/integration/compile_tests.rs +++ b/tests/integration/compile_tests.rs @@ -822,7 +822,7 @@ testing[WILDCARD]this .args("compile --output binary main.ts") .run() .assert_exit_code(0) - .assert_matches_text("Check file:///[WILDCARD]/main.ts\nCompile file:///[WILDCARD]/main.ts to binary[WILDCARD]\n"); + .assert_matches_text("Check file:///[WILDLINE]/main.ts\nCompile file:///[WILDLINE]/main.ts to binary[WILDLINE]\n"); context .new_command() @@ -835,6 +835,7 @@ testing[WILDCARD]this fn compile_npm_file_system() { run_npm_bin_compile_test(RunNpmBinCompileOptions { input_specifier: "compile/npm_fs/main.ts", + copy_temp_dir: Some("compile/npm_fs"), compile_args: vec!["-A"], run_args: vec![], output_file: "compile/npm_fs/main.out", @@ -849,6 +850,7 @@ fn compile_npm_file_system() { fn compile_npm_bin_esm() { run_npm_bin_compile_test(RunNpmBinCompileOptions { input_specifier: "npm:@denotest/bin/cli-esm", + copy_temp_dir: None, compile_args: vec![], run_args: vec!["this", "is", "a", "test"], output_file: "npm/deno_run_esm.out", @@ -863,6 +865,7 @@ fn compile_npm_bin_esm() { fn compile_npm_bin_cjs() { run_npm_bin_compile_test(RunNpmBinCompileOptions { input_specifier: "npm:@denotest/bin/cli-cjs", + copy_temp_dir: None, compile_args: vec![], run_args: vec!["this", "is", "a", "test"], output_file: "npm/deno_run_cjs.out", @@ -877,6 +880,7 @@ fn compile_npm_bin_cjs() { fn compile_npm_cowsay_main() { run_npm_bin_compile_test(RunNpmBinCompileOptions { input_specifier: "npm:cowsay@1.5.0", + copy_temp_dir: None, compile_args: vec!["--allow-read"], run_args: vec!["Hello"], output_file: "npm/deno_run_cowsay.out", @@ -891,6 +895,7 @@ fn compile_npm_cowsay_main() { fn compile_npm_vfs_implicit_read_permissions() { run_npm_bin_compile_test(RunNpmBinCompileOptions { input_specifier: "compile/vfs_implicit_read_permission/main.ts", + copy_temp_dir: Some("compile/vfs_implicit_read_permission"), compile_args: vec![], run_args: vec![], output_file: "compile/vfs_implicit_read_permission/main.out", @@ -905,6 +910,7 @@ fn compile_npm_vfs_implicit_read_permissions() { fn compile_npm_no_permissions() { run_npm_bin_compile_test(RunNpmBinCompileOptions { input_specifier: "npm:cowsay@1.5.0", + copy_temp_dir: None, compile_args: vec![], run_args: vec!["Hello"], output_file: "npm/deno_run_cowsay_no_permissions.out", @@ -919,6 +925,7 @@ fn compile_npm_no_permissions() { fn compile_npm_cowsay_explicit() { run_npm_bin_compile_test(RunNpmBinCompileOptions { input_specifier: "npm:cowsay@1.5.0/cowsay", + copy_temp_dir: None, compile_args: vec!["--allow-read"], run_args: vec!["Hello"], output_file: "npm/deno_run_cowsay.out", @@ -933,6 +940,7 @@ fn compile_npm_cowsay_explicit() { fn compile_npm_cowthink() { run_npm_bin_compile_test(RunNpmBinCompileOptions { input_specifier: "npm:cowsay@1.5.0/cowthink", + copy_temp_dir: None, compile_args: vec!["--allow-read"], run_args: vec!["Hello"], output_file: "npm/deno_run_cowthink.out", @@ -945,6 +953,7 @@ fn compile_npm_cowthink() { struct RunNpmBinCompileOptions<'a> { input_specifier: &'a str, + copy_temp_dir: Option<&'a str>, node_modules_dir: bool, output_file: &'a str, input_name: Option<&'a str>, @@ -955,15 +964,13 @@ struct RunNpmBinCompileOptions<'a> { } fn run_npm_bin_compile_test(opts: RunNpmBinCompileOptions) { - let context = TestContextBuilder::for_npm().use_temp_cwd().build(); - - let temp_dir = context.temp_dir(); - let main_specifier = if opts.input_specifier.starts_with("npm:") { - opts.input_specifier.to_string() - } else { - testdata_path().join(opts.input_specifier).to_string() + let builder = TestContextBuilder::for_npm(); + let context = match opts.copy_temp_dir { + Some(copy_temp_dir) => builder.use_copy_temp_dir(copy_temp_dir).build(), + None => builder.use_temp_cwd().build(), }; + let temp_dir = context.temp_dir(); let mut args = vec!["compile".to_string()]; args.extend(opts.compile_args.iter().map(|s| s.to_string())); @@ -977,7 +984,7 @@ fn run_npm_bin_compile_test(opts: RunNpmBinCompileOptions) { args.push(bin_name.to_string()); } - args.push(main_specifier); + args.push(opts.input_specifier.to_string()); // compile let output = context.new_command().args_vec(args).run(); @@ -1004,7 +1011,13 @@ fn run_npm_bin_compile_test(opts: RunNpmBinCompileOptions) { #[test] fn compile_node_modules_symlink_outside() { + // this code is using a canonicalized temp dir because otherwise + // it fails on the Windows CI because Deno makes the root directory + // a common ancestor of the symlinked temp dir and the canonicalized + // temp dir, which causes the warnings to not be surfaced + #[allow(deprecated)] let context = TestContextBuilder::for_npm() + .use_canonicalized_temp_dir() .use_copy_temp_dir("compile/node_modules_symlink_outside") .cwd("compile/node_modules_symlink_outside") .build(); @@ -1014,15 +1027,15 @@ fn compile_node_modules_symlink_outside() { .path() .join("compile") .join("node_modules_symlink_outside"); - temp_dir.create_dir_all(project_dir.join("node_modules")); - temp_dir.create_dir_all(project_dir.join("some_folder")); - temp_dir.write(project_dir.join("test.txt"), "5"); - - // create a symlink in the node_modules directory that points to a folder in the cwd - temp_dir.symlink_dir( - project_dir.join("some_folder"), - project_dir.join("node_modules").join("some_folder"), - ); + let symlink_target_dir = temp_dir.path().join("some_folder"); + project_dir.join("node_modules").create_dir_all(); + symlink_target_dir.create_dir_all(); + let symlink_target_file = temp_dir.path().join("target.txt"); + symlink_target_file.write("5"); + let symlink_dir = project_dir.join("node_modules").join("symlink_dir"); + + // create a symlink in the node_modules directory that points to a folder outside the project + temp_dir.symlink_dir(&symlink_target_dir, &symlink_dir); // compile folder let output = context .new_command() @@ -1032,16 +1045,16 @@ fn compile_node_modules_symlink_outside() { output.assert_matches_file( "compile/node_modules_symlink_outside/main_compile_folder.out", ); - assert!(project_dir.join("node_modules/some_folder").exists()); + assert!(symlink_dir.exists()); // Cleanup and remove the folder. The folder test is done separately from // the file symlink test because different systems would traverse // the directory items in different order. - temp_dir.remove_dir_all(project_dir.join("node_modules/some_folder")); + symlink_dir.remove_dir_all(); // create a symlink in the node_modules directory that points to a file in the cwd temp_dir.symlink_file( - project_dir.join("test.txt"), + &symlink_target_file, project_dir.join("node_modules").join("test.txt"), ); assert!(project_dir.join("node_modules/test.txt").exists()); @@ -1154,8 +1167,11 @@ fn granular_unstable_features() { #[test] fn granular_unstable_features_config_file() { - let context = TestContextBuilder::new().build(); + let context = TestContextBuilder::new().use_temp_cwd().build(); let dir = context.temp_dir(); + testdata_path() + .join("compile/unstable_features.ts") + .copy(&dir.path().join("unstable_features.ts")); let exe = if cfg!(windows) { dir.path().join("app.exe") } else { @@ -1176,7 +1192,7 @@ fn granular_unstable_features_config_file() { &dir.path().join("deno.json").to_string(), "--output", &exe.to_string_lossy(), - "./compile/unstable_features.ts", + "./unstable_features.ts", ]) .run(); output.assert_exit_code(0); diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index d0df5e6e8..f66fc97be 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -13051,7 +13051,7 @@ fn lsp_deno_json_workspace_fmt_config() { temp_dir.write( "deno.json", json!({ - "workspaces": ["project1", "project2"], + "workspace": ["project1", "project2"], "fmt": { "semiColons": false, }, @@ -13174,7 +13174,7 @@ fn lsp_deno_json_workspace_lint_config() { temp_dir.write( "deno.json", json!({ - "workspaces": ["project1", "project2"], + "workspace": ["project1", "project2"], "lint": { "rules": { "include": ["camelcase"], @@ -13315,7 +13315,7 @@ fn lsp_deno_json_workspace_import_map() { temp_dir.write( "project1/deno.json", json!({ - "workspaces": ["project2"], + "workspace": ["project2"], "imports": { "foo": "./foo1.ts", }, @@ -13376,7 +13376,7 @@ fn lsp_deno_json_workspace_jsr_resolution() { temp_dir.write( "deno.json", json!({ - "workspaces": ["project1"], + "workspace": ["project1"], }) .to_string(), ); diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index b8263be29..d4d1fea2e 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -1113,7 +1113,9 @@ fn lock_deno_json_package_json_deps_workspace() { // deno.json let deno_json = temp_dir.join("deno.json"); - deno_json.write_json(&json!({})); + deno_json.write_json(&json!({ + "nodeModulesDir": true + })); // package.json let package_json = temp_dir.join("package.json"); @@ -1147,16 +1149,23 @@ fn lock_deno_json_package_json_deps_workspace() { let lockfile = temp_dir.join("deno.lock"); let esm_basic_integrity = get_lockfile_npm_package_integrity(&lockfile, "@denotest/esm-basic@1.0.0"); + let cjs_default_export_integrity = get_lockfile_npm_package_integrity( + &lockfile, + "@denotest/cjs-default-export@1.0.0", + ); - // no "workspace" because deno isn't smart enough to figure this out yet - // since it discovered the package.json in a folder different from the lockfile lockfile.assert_matches_json(json!({ "version": "3", "packages": { "specifiers": { + "npm:@denotest/cjs-default-export@1": "npm:@denotest/cjs-default-export@1.0.0", "npm:@denotest/esm-basic@1": "npm:@denotest/esm-basic@1.0.0" }, "npm": { + "@denotest/cjs-default-export@1.0.0": { + "integrity": cjs_default_export_integrity, + "dependencies": {} + }, "@denotest/esm-basic@1.0.0": { "integrity": esm_basic_integrity, "dependencies": {} @@ -1164,6 +1173,22 @@ fn lock_deno_json_package_json_deps_workspace() { } }, "remote": {}, + "workspace": { + "packageJson": { + "dependencies": [ + "npm:@denotest/cjs-default-export@1" + ] + }, + "members": { + "package-a": { + "packageJson": { + "dependencies": [ + "npm:@denotest/esm-basic@1" + ] + } + } + } + } })); // run a command that causes discovery of the root package.json beside the lockfile @@ -1201,6 +1226,15 @@ fn lock_deno_json_package_json_deps_workspace() { "dependencies": [ "npm:@denotest/cjs-default-export@1" ] + }, + "members": { + "package-a": { + "packageJson": { + "dependencies": [ + "npm:@denotest/esm-basic@1" + ] + } + } } } }); diff --git a/tests/integration/watcher_tests.rs b/tests/integration/watcher_tests.rs index 252411627..7864938f8 100644 --- a/tests/integration/watcher_tests.rs +++ b/tests/integration/watcher_tests.rs @@ -1547,7 +1547,7 @@ async fn run_watch_dynamic_imports() { .unwrap(); let (mut stdout_lines, mut stderr_lines) = child_lines(&mut child); wait_contains("Process started", &mut stderr_lines).await; - wait_contains("No package.json file found", &mut stderr_lines).await; + wait_contains("Finished config loading.", &mut stderr_lines).await; wait_contains( "Hopefully dynamic import will be watched...", @@ -1714,7 +1714,7 @@ console.log("Listening...") .unwrap(); let (mut stdout_lines, mut stderr_lines) = child_lines(&mut child); wait_contains("Process started", &mut stderr_lines).await; - wait_contains("No package.json file found", &mut stderr_lines).await; + wait_contains("Finished config loading.", &mut stderr_lines).await; wait_for_watcher("file_to_watch.js", &mut stderr_lines).await; wait_contains("Listening...", &mut stdout_lines).await; @@ -1787,7 +1787,7 @@ export function foo() { .unwrap(); let (mut stdout_lines, mut stderr_lines) = child_lines(&mut child); wait_contains("Process started", &mut stderr_lines).await; - wait_contains("No package.json file found", &mut stderr_lines).await; + wait_contains("Finished config loading.", &mut stderr_lines).await; wait_for_watcher("file_to_watch.js", &mut stderr_lines).await; wait_contains("5 <h1>Hello</h1>", &mut stdout_lines).await; @@ -1846,7 +1846,7 @@ export function foo() { .unwrap(); let (mut stdout_lines, mut stderr_lines) = child_lines(&mut child); wait_contains("Process started", &mut stderr_lines).await; - wait_contains("No package.json file found", &mut stderr_lines).await; + wait_contains("Finished config loading.", &mut stderr_lines).await; wait_for_watcher("file_to_watch.js", &mut stderr_lines).await; wait_contains("<h1>asd1</h1>", &mut stdout_lines).await; @@ -1912,7 +1912,7 @@ export function foo() { .unwrap(); let (mut stdout_lines, mut stderr_lines) = child_lines(&mut child); wait_contains("Process started", &mut stderr_lines).await; - wait_contains("No package.json file found", &mut stderr_lines).await; + wait_contains("Finished config loading.", &mut stderr_lines).await; wait_for_watcher("file_to_watch.js", &mut stderr_lines).await; wait_contains("2 <h1>asd1</h1>", &mut stdout_lines).await; diff --git a/tests/registry/npm/@types/lz-string/lz-string-1.3.33.tgz b/tests/registry/npm/@types/lz-string/lz-string-1.3.33.tgz Binary files differnew file mode 100644 index 000000000..e33d3bcdc --- /dev/null +++ b/tests/registry/npm/@types/lz-string/lz-string-1.3.33.tgz diff --git a/tests/registry/npm/@types/lz-string/lz-string-1.5.0.tgz b/tests/registry/npm/@types/lz-string/lz-string-1.5.0.tgz Binary files differnew file mode 100644 index 000000000..6d7a01381 --- /dev/null +++ b/tests/registry/npm/@types/lz-string/lz-string-1.5.0.tgz diff --git a/tests/registry/npm/@types/lz-string/registry.json b/tests/registry/npm/@types/lz-string/registry.json new file mode 100644 index 000000000..677c5d24a --- /dev/null +++ b/tests/registry/npm/@types/lz-string/registry.json @@ -0,0 +1,113 @@ +{ + "_id": "@types/lz-string", + "_rev": "554-923923210a37cca16c53a3e8dd472e22", + "name": "@types/lz-string", + "description": "Stub TypeScript definitions entry for lz-string, which provides its own types definitions", + "dist-tags": { + "latest": "1.5.0" + }, + "versions": { + "1.3.33": { + "name": "@types/lz-string", + "version": "1.3.33", + "description": "TypeScript definitions for lz-string", + "license": "MIT", + "contributors": [ + { + "name": "Roman Nikitin", + "url": "https://github.com/M0ns1gn0r", + "githubUsername": "M0ns1gn0r" + } + ], + "main": "", + "types": "index", + "repository": { + "type": "git", + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git" + }, + "scripts": {}, + "dependencies": {}, + "typesPublisherContentHash": "37e0f8cf2fb1fe08bdcc8e21278c91217d4a03d1cd6b32fc0eaec30757c6d4b1", + "typeScriptVersion": "2.0", + "_id": "@types/lz-string@1.3.33", + "dist": { + "integrity": "sha512-yWj3OnlKlwNpq9+Jh/nJkVAD3ta8Abk2kIRpjWpVkDlAD43tn6Q6xk5hurp84ndcq54jBDBGCD/WcIR0pspG0A==", + "shasum": "de2d6105ea7bcaf67dd1d9451d580700d30473fc", + "tarball": "http://localhost:4260/@types/lz-string/lz-string-1.3.33.tgz", + "fileCount": 4, + "unpackedSize": 5960, + "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcZIpFCRA9TVsSAnZWagAAYm8QAJCahktTDI8BUR8q+Qra\nzsvv7Vbb20Ti7uoh97yzJiEC8UEWCGnxpZouWr3xoy0FjByYIvGmHqslGohP\nksiikCXiy+5pfT0Yi3M4QeADPlQjqUVTweCoeMmpUaHWGBdqG2kE6tnioCQy\nAL9n/YnQc10b5SE/XYgKHuBN/HJ5tx1Ejcg/o7qJG/2cUe/1K1asIMFUockV\ncgwFXFl8OSMTcA3Bs0C84zIdcaC4njVqUIQOWqdgKbe1vs+O/Zf/OdiYQh9f\nZZMXffwJKVpLSfhOTeDHeD1WMNmiww+FVIikeUIihp7Xahk9YbrLtE5BUSgG\nl9/vNfzUDW+J5oJb6n8k9WojHjte00inzMa1O7QVT7cUC+e5Nup1df0VErNF\nVuaBMUy2o0LViCVcXOYUnDBQCoaKpQ8cIVhtl0VLFrOdyn+a0blcwaNNrvE1\nFKb+OgBqipIDwAx1QghV45MPtRzI/TLYeSZtHoOYVJ8zc11FzjaQ33NZj/5w\nVzMnRkmjpwF5j++JSOa3687iKJTgrJ6XHYliYpxRRpJY3Oa4Nl0/G+xMm1BS\n0ueZuqpM+h2ZMuG7TQOeDKtTll7tsuKwy2UlkkP2uJOVurqJkCvcK/ImG25W\nKENAcoJvsk956vlbvJCdqvIcV5OF5XhgQh10gaAfHl+pJiLbCBhHpeWd95+Y\n5/3T\r\n=MjUN\r\n-----END PGP SIGNATURE-----\r\n", + "signatures": [ + { + "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", + "sig": "MEUCIHlPUpoP+v+OWyats51tKkKMx97XrotlO8GzoVtS22/KAiEAxLb7ultFaZZIfGVCNeHE/X+J9I58zkNA6a8LKcm2Wns=" + } + ] + }, + "maintainers": [ + { + "name": "types", + "email": "ts-npm-types@microsoft.com" + } + ], + "_npmUser": { + "name": "types", + "email": "ts-npm-types@microsoft.com" + }, + "directories": {}, + "_npmOperationalInternal": { + "host": "s3://npm-registry-packages", + "tmp": "tmp/lz-string_1.3.33_1550092868900_0.5979975733337666" + }, + "_hasShrinkwrap": false + }, + "1.5.0": { + "name": "@types/lz-string", + "version": "1.5.0", + "description": "Stub TypeScript definitions entry for lz-string, which provides its own types definitions", + "main": "", + "scripts": {}, + "license": "MIT", + "dependencies": { + "lz-string": "*" + }, + "deprecated": "This is a stub types definition. lz-string provides its own type definitions, so you do not need this installed.", + "_id": "@types/lz-string@1.5.0", + "dist": { + "integrity": "sha512-s84fKOrzqqNCAPljhVyC5TjAo6BH4jKHw9NRNFNiRUY5QSgZCmVm5XILlWbisiKl+0OcS7eWihmKGS5akc2iQw==", + "shasum": "2f15d2dd9dbfb344f3d31aee5a82cf350b037e5f", + "tarball": "http://localhost:4260/@types/lz-string/lz-string-1.5.0.tgz", + "fileCount": 4, + "unpackedSize": 1754, + "signatures": [ + { + "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", + "sig": "MEQCIFwugI1BNDwbq90OnD5/morYlSnSQheJEnyTkclzw0SKAiAThdPB2+I/hjRlN5URdZcK4v0XXcVnh5xvMSf7SgQZ8A==" + } + ], + "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkECMgACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmopOQ//U+7G8WFrWQ3ecjTZrMAAqmwWNK1jgA3r0PonmwkiDjQlNAHj\r\nXAfJK8YSuFBrl8buIAkoJT9i+H6bpHIShj5fA4FKVtA1ihcwclAdvvoilwH2\r\nNCvoFeZZgrZB6y5e6AvGDHY67C2DzQ9XhfqYM0myyXS+of2gfznAPVqXwGCs\r\nWW39ee/WAbBEoN2Z1/hEAh+W51hV0HUjs39sbupo0vOHy9GdYuVJtTMeqesF\r\nmCfDDaM1FxbsMFccy8qRsihD26iwBMRa+W3+208gCc0i9xs8wRc+8GQcAGWd\r\nxSrTEgRd8hfBs6bxDKlSD3Qg7pTq3L+HvlUZGL2AHSbC6k/MCNduHhxEcrrj\r\nssFE4iuCievfQsd0CC4rI/8s5MDGwdQ+nldv0rYjsSphjLgHDly0LE1kAbNv\r\nxZWFXmFb7318wmbC38KYDn1I0b6YndHQFu1usVJ+Z107H/mxWRZeRg0THlD8\r\n3LuLEkCJqRddGmLkSQkJ6IZtX8H9EuuhU4ny6Xb3FYFhnXWmw7YSuvrrfSgs\r\nPlLlscCRsXgWYPzQ7h8mOyE4MoHfrjzcgFKIUgWPvW6EprDPAKu28vIXnn7j\r\nG0CiCYL+IWWTqa6pKkOJsE1ILkPYTZj/592zfGPzspl9Kfb/4+IaDMmApBVO\r\n51TMBjyXgYYDajmh6y8/U389X93/bIV/wjY=\r\n=935O\r\n-----END PGP SIGNATURE-----\r\n" + }, + "_npmUser": { + "name": "types", + "email": "ts-npm-types@microsoft.com" + }, + "directories": {}, + "maintainers": [ + { + "name": "types", + "email": "ts-npm-types@microsoft.com" + } + ], + "_npmOperationalInternal": { + "host": "s3://npm-registry-packages", + "tmp": "tmp/lz-string_1.5.0_1678779167950_0.5151061207876493" + }, + "_hasShrinkwrap": false + } + }, + "license": "MIT", + "readmeFilename": "", + "users": { + "flumpus-dev": true + } +} diff --git a/tests/registry/npm/lz-string/lz-string-1.3.6.tgz b/tests/registry/npm/lz-string/lz-string-1.3.6.tgz Binary files differnew file mode 100644 index 000000000..153b8733c --- /dev/null +++ b/tests/registry/npm/lz-string/lz-string-1.3.6.tgz diff --git a/tests/registry/npm/lz-string/lz-string-1.5.0.tgz b/tests/registry/npm/lz-string/lz-string-1.5.0.tgz Binary files differnew file mode 100644 index 000000000..3c1c8907f --- /dev/null +++ b/tests/registry/npm/lz-string/lz-string-1.5.0.tgz diff --git a/tests/registry/npm/lz-string/registry.json b/tests/registry/npm/lz-string/registry.json new file mode 100644 index 000000000..5bf86f4ce --- /dev/null +++ b/tests/registry/npm/lz-string/registry.json @@ -0,0 +1,165 @@ +{ + "_id": "lz-string", + "_rev": "45-a265b69aa69ae37972e7a7931a9be325", + "name": "lz-string", + "description": "LZ-based compression algorithm", + "dist-tags": { + "latest": "1.5.0" + }, + "versions": { + "1.3.6": { + "name": "lz-string", + "version": "1.3.6", + "license": "WTFPL", + "description": "LZ-based compression algorithm", + "homepage": "http://pieroxy.net/blog/pages/lz-string/index.html", + "keywords": [ + "lz", + "compression", + "string" + ], + "main": "libs/lz-string.js", + "bin": { + "lz-string": "bin/bin.js" + }, + "scripts": {}, + "dependencies": {}, + "devDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/pieroxy/lz-string.git" + }, + "bugs": { + "url": "https://github.com/pieroxy/lz-string/issues" + }, + "directories": { + "test": "tests" + }, + "author": { + "name": "pieroxy", + "email": "pieroxy@pieroxy.net" + }, + "_id": "lz-string@1.3.6", + "dist": { + "shasum": "cc91b00d3264b15402e428e76dfeb709193bc10f", + "tarball": "http://localhost:4260/lz-string/lz-string-1.3.6.tgz", + "integrity": "sha512-gIHN4Nkmln8SrIRAXJ3qzGH7gJ8WjAORiwD+SB3PYW4n4ri+gP257pXSeyw/VGOV+6ZLIkZmNfK4xT6e2U5QIQ==", + "signatures": [ + { + "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", + "sig": "MEQCICsj8exNp9xi4L5Kz31ojhaj18oeqnD4vzlhr/RMaAIiAiA/3mY8M6oycukeCebQdfWQtZC640OyMjQO11da2GnGGg==" + } + ] + }, + "_from": "./", + "_npmVersion": "1.3.10", + "_npmUser": { + "name": "pieroxy", + "email": "pieroxy@pieroxy.net" + }, + "maintainers": [ + { + "name": "pieroxy", + "email": "pieroxy@pieroxy.net" + } + ] + }, + "1.5.0": { + "name": "lz-string", + "version": "1.5.0", + "license": "MIT", + "filename": "lz-string.js", + "description": "LZ-based compression algorithm", + "homepage": "http://pieroxy.net/blog/pages/lz-string/index.html", + "keywords": [ + "lz", + "compression", + "string" + ], + "main": "libs/lz-string.js", + "typings": "typings/lz-string.d.ts", + "bin": { + "lz-string": "bin/bin.js" + }, + "scripts": {}, + "dependencies": {}, + "devDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/pieroxy/lz-string.git" + }, + "bugs": { + "url": "https://github.com/pieroxy/lz-string/issues" + }, + "directories": { + "test": "tests" + }, + "author": { + "name": "pieroxy", + "email": "pieroxy@pieroxy.net" + }, + "autoupdate": { + "source": "git", + "target": "git://github.com/pieroxy/lz-string.git", + "basePath": "libs/", + "files": [ + "lz-string.js", + "lz-string.min.js", + "base64-string.js" + ] + }, + "gitHead": "4a94308c1e684fb98866f7ba1288f3db6d9f8801", + "_id": "lz-string@1.5.0", + "_nodeVersion": "16.19.1", + "_npmVersion": "8.19.3", + "dist": { + "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", + "shasum": "c1ab50f77887b712621201ba9fd4e3a6ed099941", + "tarball": "http://localhost:4260/lz-string/lz-string-1.5.0.tgz", + "fileCount": 16, + "unpackedSize": 175825, + "signatures": [ + { + "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", + "sig": "MEQCIDFXe2mJhe/c2RygpDTZFwYF+ZLzmWmrobWbcX05nZzgAiB2NY0LGdJ8X/8K5Y24goCdb/HvaDnCxn4BdQm7jfU/Jw==" + } + ], + "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkAwBbACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrCaw/+L77yb5aRlRo8abeR0BMuhftlzyMGzGh+asUdX+afBEOGYTyJ\r\n2XM9fqdpZrtJv3+q9D+gqnLg7MoRQQkmvC+U0HTHEWtEJNaIH1at/IMhi+xB\r\n5/3Jho9VOtLhPto1/ld1CVu0JTxdUTDiTjpE26a4wdd7qMDhjaSJkypjtutn\r\nfwZXUs2YzKZQ1h6RlLSpB2b19KwiVjFsqnV+tIgs1WmjcrC7RxqEtA2yDdt5\r\nfWDM3lLgSGjFkedydnOskMNqLaL9COVzQ8iuFXGeS/NJvhi64gKDcGFl2ztx\r\nQS30dC/ud+EkF3omjN/cFhAnBCcXLvK52MxglR4+Ph4QAa4f3NhbUZbc1i4G\r\nf3Qa8GxOPHAAfR4X7z4E2fKlpybz7it3Sl5SJ8RQo3X24TGR69rM4Flc7G7S\r\ncNUtFXu/zJLmxYlc3u0Qcbx8sbdkg65V9y0n1aFXpwlofPbSqjOp/M4F5Yu4\r\nqQjGV6n8fz7CUb5ZpcEWFgztd+pi+7G0hhbKWrznOPxss9LWjr1j5PbIsY/9\r\nfZNeHynSv7Bkx2X7Cr7UPVZr9zNWLXdT7bxcI3ielAUVAeQRtRB9ostiCGvL\r\nChEZ3dZmIbYAeeSgL/175rpseCxPotDpLJ9xMBcyozfC1bbedA2LFbIkDzwA\r\nDKmVP8Nl733GahX08ZwxYSsoIU6oh9hYTeQ=\r\n=6NYt\r\n-----END PGP SIGNATURE-----\r\n" + }, + "_npmUser": { + "name": "pieroxy", + "email": "pieroxy@pieroxy.net" + }, + "maintainers": [ + { + "name": "pieroxy", + "email": "pieroxy@pieroxy.net" + } + ], + "_npmOperationalInternal": { + "host": "s3://npm-registry-packages", + "tmp": "tmp/lz-string_1.5.0_1677918299665_0.8929158378621742" + }, + "_hasShrinkwrap": false + } + }, + "maintainers": [], + "time": {}, + "repository": {}, + "users": {}, + "homepage": "http://pieroxy.net/blog/pages/lz-string/index.html", + "keywords": [ + "lz", + "compression", + "string" + ], + "license": "MIT", + "readmeFilename": "README.md", + "author": { + "name": "pieroxy", + "email": "pieroxy@pieroxy.net" + }, + "bugs": { + "url": "https://github.com/pieroxy/lz-string/issues" + } +} diff --git a/tests/specs/bench/workspace/__test__.jsonc b/tests/specs/bench/workspace/__test__.jsonc new file mode 100644 index 000000000..fa1bd69da --- /dev/null +++ b/tests/specs/bench/workspace/__test__.jsonc @@ -0,0 +1,13 @@ +{ + "tests": { + "root": { + "args": "bench", + "output": "root.out" + }, + "package": { + "args": "bench", + "cwd": "package-b", + "output": "package_b.out" + } + } +} diff --git a/tests/specs/bench/workspace/deno.json b/tests/specs/bench/workspace/deno.json new file mode 100644 index 000000000..b72d88442 --- /dev/null +++ b/tests/specs/bench/workspace/deno.json @@ -0,0 +1,6 @@ +{ + "workspace": [ + "./package-a", + "./package-b" + ] +} diff --git a/tests/specs/bench/workspace/package-a/deno.json b/tests/specs/bench/workspace/package-a/deno.json new file mode 100644 index 000000000..e6e03ae85 --- /dev/null +++ b/tests/specs/bench/workspace/package-a/deno.json @@ -0,0 +1,5 @@ +{ + "name": "@scope/a", + "version": "1.0.0", + "exports": "./mod.ts" +} diff --git a/tests/specs/bench/workspace/package-a/mod.bench.ts b/tests/specs/bench/workspace/package-a/mod.bench.ts new file mode 100644 index 000000000..5fbf79e66 --- /dev/null +++ b/tests/specs/bench/workspace/package-a/mod.bench.ts @@ -0,0 +1,7 @@ +import { add } from "./mod.ts"; + +Deno.bench("add", () => { + if (add(1, 2) !== 3) { + throw new Error("failed"); + } +}); diff --git a/tests/specs/bench/workspace/package-a/mod.ts b/tests/specs/bench/workspace/package-a/mod.ts new file mode 100644 index 000000000..8d9b8a22a --- /dev/null +++ b/tests/specs/bench/workspace/package-a/mod.ts @@ -0,0 +1,3 @@ +export function add(a: number, b: number): number { + return a + b; +} diff --git a/tests/specs/bench/workspace/package-b/deno.json b/tests/specs/bench/workspace/package-b/deno.json new file mode 100644 index 000000000..f131c191b --- /dev/null +++ b/tests/specs/bench/workspace/package-b/deno.json @@ -0,0 +1,5 @@ +{ + "name": "@scope/b", + "version": "1.0.0", + "exports": "./mod.ts" +} diff --git a/tests/specs/bench/workspace/package-b/mod.bench.ts b/tests/specs/bench/workspace/package-b/mod.bench.ts new file mode 100644 index 000000000..ca972c39e --- /dev/null +++ b/tests/specs/bench/workspace/package-b/mod.bench.ts @@ -0,0 +1,7 @@ +import { addOne } from "./mod.ts"; + +Deno.bench("addOne", () => { + if (addOne(1) !== 2) { + throw new Error("failed"); + } +}); diff --git a/tests/specs/bench/workspace/package-b/mod.ts b/tests/specs/bench/workspace/package-b/mod.ts new file mode 100644 index 000000000..53148ac2f --- /dev/null +++ b/tests/specs/bench/workspace/package-b/mod.ts @@ -0,0 +1,5 @@ +import { add } from "@scope/a"; + +export function addOne(a: number): number { + return add(a, 1); +} diff --git a/tests/specs/bench/workspace/package_b.out b/tests/specs/bench/workspace/package_b.out new file mode 100644 index 000000000..bb452e3e9 --- /dev/null +++ b/tests/specs/bench/workspace/package_b.out @@ -0,0 +1,9 @@ +Check file:///[WILDLINE]/package-b/mod.bench.ts +cpu: [WILDLINE] +runtime: [WILDLINE] + +file:///[WILDLINE]/package-b/mod.bench.ts +benchmark[WILDLINE] +---[WILDLINE] +addOne[WILDLINE] + diff --git a/tests/specs/bench/workspace/root.out b/tests/specs/bench/workspace/root.out new file mode 100644 index 000000000..897cd7d3c --- /dev/null +++ b/tests/specs/bench/workspace/root.out @@ -0,0 +1,16 @@ +Check file:///[WILDLINE]/package-a/mod.bench.ts +Check file:///[WILDLINE]/package-b/mod.bench.ts +cpu: [WILDLINE] +runtime: [WILDLINE] + +file:///[WILDLINE]/package-a/mod.bench.ts +benchmark[WILDLINE] +---[WILDLINE] +add[WILDLINE] + + +file:///[WILDLINE]/package-b/mod.bench.ts +benchmark[WILDLINE] +---[WILDLINE] +addOne[WILDLINE] + diff --git a/tests/specs/check/workspace/__test__.jsonc b/tests/specs/check/workspace/__test__.jsonc new file mode 100644 index 000000000..5df2fd70e --- /dev/null +++ b/tests/specs/check/workspace/__test__.jsonc @@ -0,0 +1,22 @@ +{ + "tests": { + "root": { + // todo(dsherret): should be possible to not provide args here + "args": "check package-a/mod.ts package-b/mod.ts", + "output": "root.out", + "exitCode": 1 + }, + "package_a": { + "args": "check mod.ts", + "cwd": "package-a", + "output": "package_a.out", + "exitCode": 0 + }, + "package_b": { + "args": "check mod.ts", + "cwd": "package-b", + "output": "package_b.out", + "exitCode": 1 + } + } +} diff --git a/tests/specs/check/workspace/deno.json b/tests/specs/check/workspace/deno.json new file mode 100644 index 000000000..b72d88442 --- /dev/null +++ b/tests/specs/check/workspace/deno.json @@ -0,0 +1,6 @@ +{ + "workspace": [ + "./package-a", + "./package-b" + ] +} diff --git a/tests/specs/check/workspace/package-a/deno.json b/tests/specs/check/workspace/package-a/deno.json new file mode 100644 index 000000000..e6e03ae85 --- /dev/null +++ b/tests/specs/check/workspace/package-a/deno.json @@ -0,0 +1,5 @@ +{ + "name": "@scope/a", + "version": "1.0.0", + "exports": "./mod.ts" +} diff --git a/tests/specs/check/workspace/package-a/mod.ts b/tests/specs/check/workspace/package-a/mod.ts new file mode 100644 index 000000000..8d9b8a22a --- /dev/null +++ b/tests/specs/check/workspace/package-a/mod.ts @@ -0,0 +1,3 @@ +export function add(a: number, b: number): number { + return a + b; +} diff --git a/tests/specs/check/workspace/package-b/deno.json b/tests/specs/check/workspace/package-b/deno.json new file mode 100644 index 000000000..f131c191b --- /dev/null +++ b/tests/specs/check/workspace/package-b/deno.json @@ -0,0 +1,5 @@ +{ + "name": "@scope/b", + "version": "1.0.0", + "exports": "./mod.ts" +} diff --git a/tests/specs/check/workspace/package-b/mod.ts b/tests/specs/check/workspace/package-b/mod.ts new file mode 100644 index 000000000..554ba5674 --- /dev/null +++ b/tests/specs/check/workspace/package-b/mod.ts @@ -0,0 +1,4 @@ +import { add } from "@scope/a"; + +const test: string = add(1, 2); +console.log(test); diff --git a/tests/specs/check/workspace/package_a.out b/tests/specs/check/workspace/package_a.out new file mode 100644 index 000000000..faecec870 --- /dev/null +++ b/tests/specs/check/workspace/package_a.out @@ -0,0 +1 @@ +Check file:///[WILDLINE]/package-a/mod.ts diff --git a/tests/specs/check/workspace/package_b.out b/tests/specs/check/workspace/package_b.out new file mode 100644 index 000000000..8db6c5476 --- /dev/null +++ b/tests/specs/check/workspace/package_b.out @@ -0,0 +1,5 @@ +Check file:///[WILDLINE]/package-b/mod.ts +error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. +const test: string = add(1, 2); + ~~~~ + at [WILDLINE] diff --git a/tests/specs/check/workspace/root.out b/tests/specs/check/workspace/root.out new file mode 100644 index 000000000..21ae7acd3 --- /dev/null +++ b/tests/specs/check/workspace/root.out @@ -0,0 +1,6 @@ +Check file:///[WILDLINE]/package-a/mod.ts +Check file:///[WILDLINE]/package-b/mod.ts +error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. +const test: string = add(1, 2); + ~~~~ + at [WILDLINE] diff --git a/tests/specs/compile/npmrc/.npmrc b/tests/specs/compile/npmrc_auto_install/.npmrc index 13552ad61..13552ad61 100644 --- a/tests/specs/compile/npmrc/.npmrc +++ b/tests/specs/compile/npmrc_auto_install/.npmrc diff --git a/tests/specs/compile/npmrc_auto_install/__test__.jsonc b/tests/specs/compile/npmrc_auto_install/__test__.jsonc new file mode 100644 index 000000000..f4ba8ee28 --- /dev/null +++ b/tests/specs/compile/npmrc_auto_install/__test__.jsonc @@ -0,0 +1,22 @@ +{ + "tempDir": true, + "steps": [{ + "if": "unix", + "args": "compile --output main main.js", + "output": "[WILDCARD]" + }, { + "if": "unix", + "commandName": "./main", + "args": [], + "output": "main.out" + }, { + "if": "windows", + "args": "compile --output main.exe main.js", + "output": "[WILDCARD]" + }, { + "if": "windows", + "commandName": "./main.exe", + "args": [], + "output": "main.out" + }] +} diff --git a/tests/specs/compile/npmrc_auto_install/deno.json b/tests/specs/compile/npmrc_auto_install/deno.json new file mode 100644 index 000000000..176354f98 --- /dev/null +++ b/tests/specs/compile/npmrc_auto_install/deno.json @@ -0,0 +1,3 @@ +{ + "nodeModulesDir": true +} diff --git a/tests/specs/compile/npmrc/main.js b/tests/specs/compile/npmrc_auto_install/main.js index 66b393636..66b393636 100644 --- a/tests/specs/compile/npmrc/main.js +++ b/tests/specs/compile/npmrc_auto_install/main.js diff --git a/tests/specs/compile/npmrc/main.out b/tests/specs/compile/npmrc_auto_install/main.out index bbe210bdb..bbe210bdb 100644 --- a/tests/specs/compile/npmrc/main.out +++ b/tests/specs/compile/npmrc_auto_install/main.out diff --git a/tests/specs/compile/npmrc/package.json b/tests/specs/compile/npmrc_auto_install/package.json index 274d1ed7f..274d1ed7f 100644 --- a/tests/specs/compile/npmrc/package.json +++ b/tests/specs/compile/npmrc_auto_install/package.json diff --git a/tests/specs/compile/npmrc_byonm/.npmrc b/tests/specs/compile/npmrc_byonm/.npmrc new file mode 100644 index 000000000..13552ad61 --- /dev/null +++ b/tests/specs/compile/npmrc_byonm/.npmrc @@ -0,0 +1,4 @@ +@denotest:registry=http://localhost:4261/ +//localhost:4261/:_authToken=private-reg-token +@denotest2:registry=http://localhost:4262/ +//localhost:4262/:_authToken=private-reg-token2 diff --git a/tests/specs/compile/npmrc/__test__.jsonc b/tests/specs/compile/npmrc_byonm/__test__.jsonc index 470e5299c..470e5299c 100644 --- a/tests/specs/compile/npmrc/__test__.jsonc +++ b/tests/specs/compile/npmrc_byonm/__test__.jsonc diff --git a/tests/specs/compile/npmrc/install.out b/tests/specs/compile/npmrc_byonm/install.out index 5c2ff3562..5c2ff3562 100644 --- a/tests/specs/compile/npmrc/install.out +++ b/tests/specs/compile/npmrc_byonm/install.out diff --git a/tests/specs/compile/npmrc_byonm/main.js b/tests/specs/compile/npmrc_byonm/main.js new file mode 100644 index 000000000..66b393636 --- /dev/null +++ b/tests/specs/compile/npmrc_byonm/main.js @@ -0,0 +1,8 @@ +import { getValue, setValue } from "@denotest/basic"; +import * as test from "@denotest2/basic"; + +console.log(getValue()); +setValue(42); +console.log(getValue()); + +console.log(test.getValue()); diff --git a/tests/specs/compile/npmrc_byonm/main.out b/tests/specs/compile/npmrc_byonm/main.out new file mode 100644 index 000000000..bbe210bdb --- /dev/null +++ b/tests/specs/compile/npmrc_byonm/main.out @@ -0,0 +1,3 @@ +0 +42 +0 diff --git a/tests/specs/compile/npmrc_byonm/package.json b/tests/specs/compile/npmrc_byonm/package.json new file mode 100644 index 000000000..274d1ed7f --- /dev/null +++ b/tests/specs/compile/npmrc_byonm/package.json @@ -0,0 +1,8 @@ +{ + "name": "npmrc_test", + "version": "0.0.1", + "dependencies": { + "@denotest/basic": "1.0.0", + "@denotest2/basic": "1.0.0" + } +} diff --git a/tests/specs/fmt/workspace/__test__.jsonc b/tests/specs/fmt/workspace/__test__.jsonc new file mode 100644 index 000000000..80e3639f9 --- /dev/null +++ b/tests/specs/fmt/workspace/__test__.jsonc @@ -0,0 +1,26 @@ +{ + "tests": { + "root_fmt": { + "tempDir": true, + "args": "fmt", + "output": "root_fmt.out" + }, + "root_check": { + "args": "fmt --check", + "exitCode": 1, + "output": "root_check.out" + }, + "sub_dir_fmt": { + "tempDir": true, + "args": "fmt", + "cwd": "a", + "output": "a_fmt.out" + }, + "subdir_check": { + "args": "fmt --check", + "cwd": "a", + "exitCode": 1, + "output": "a_check.out" + } + } +} diff --git a/tests/specs/fmt/workspace/a/a.ts b/tests/specs/fmt/workspace/a/a.ts new file mode 100644 index 000000000..7b2a34601 --- /dev/null +++ b/tests/specs/fmt/workspace/a/a.ts @@ -0,0 +1 @@ +console.log("a"); diff --git a/tests/specs/fmt/workspace/a/deno.json b/tests/specs/fmt/workspace/a/deno.json new file mode 100644 index 000000000..0dd8856d7 --- /dev/null +++ b/tests/specs/fmt/workspace/a/deno.json @@ -0,0 +1,5 @@ +{ + "fmt": { + "semiColons": false + } +} diff --git a/tests/specs/fmt/workspace/a_check.out b/tests/specs/fmt/workspace/a_check.out new file mode 100644 index 000000000..150f18b2e --- /dev/null +++ b/tests/specs/fmt/workspace/a_check.out @@ -0,0 +1,6 @@ + +from [WILDLINE]a.ts: +1 | -console.log("a"); +1 | +console.log('a') + +error: Found 1 not formatted file in 2 files diff --git a/tests/specs/fmt/workspace/a_fmt.out b/tests/specs/fmt/workspace/a_fmt.out new file mode 100644 index 000000000..18da23175 --- /dev/null +++ b/tests/specs/fmt/workspace/a_fmt.out @@ -0,0 +1,2 @@ +[WILDLINE]a.ts +Checked 2 files diff --git a/tests/specs/fmt/workspace/b/b.ts b/tests/specs/fmt/workspace/b/b.ts new file mode 100644 index 000000000..8609d0755 --- /dev/null +++ b/tests/specs/fmt/workspace/b/b.ts @@ -0,0 +1 @@ +console.log('a'); diff --git a/tests/specs/fmt/workspace/b/deno.json b/tests/specs/fmt/workspace/b/deno.json new file mode 100644 index 000000000..388b14749 --- /dev/null +++ b/tests/specs/fmt/workspace/b/deno.json @@ -0,0 +1,5 @@ +{ + "fmt": { + "singleQuote": false + } +} diff --git a/tests/specs/fmt/workspace/deno.json b/tests/specs/fmt/workspace/deno.json new file mode 100644 index 000000000..2b030605d --- /dev/null +++ b/tests/specs/fmt/workspace/deno.json @@ -0,0 +1,9 @@ +{ + "workspace": [ + "./a", + "./b" + ], + "fmt": { + "singleQuote": true + } +} diff --git a/tests/specs/fmt/workspace/root.ts b/tests/specs/fmt/workspace/root.ts new file mode 100644 index 000000000..9300c8169 --- /dev/null +++ b/tests/specs/fmt/workspace/root.ts @@ -0,0 +1 @@ +console.log("root") diff --git a/tests/specs/fmt/workspace/root_check.out b/tests/specs/fmt/workspace/root_check.out new file mode 100644 index 000000000..323f43f34 --- /dev/null +++ b/tests/specs/fmt/workspace/root_check.out @@ -0,0 +1,16 @@ + +from [WILDLINE]root.ts: +1 | -console.log("root") +1 | +console.log('root'); + + +from [WILDLINE]workspace[WILDCHAR]a[WILDCHAR]a.ts: +1 | -console.log("a"); +1 | +console.log('a') + + +from [WILDLINE]workspace[WILDCHAR]b[WILDCHAR]b.ts: +1 | -console.log('a'); +1 | +console.log("a"); + +error: Found 3 not formatted files in 7 files diff --git a/tests/specs/fmt/workspace/root_fmt.out b/tests/specs/fmt/workspace/root_fmt.out new file mode 100644 index 000000000..306ecada6 --- /dev/null +++ b/tests/specs/fmt/workspace/root_fmt.out @@ -0,0 +1,4 @@ +[WILDLINE]root.ts +[WILDLINE]a.ts +[WILDLINE]b.ts +Checked 6 files diff --git a/tests/specs/install/future_install_global/__test__.jsonc b/tests/specs/install/future_install_global/__test__.jsonc index be6fcab97..e646164c6 100644 --- a/tests/specs/install/future_install_global/__test__.jsonc +++ b/tests/specs/install/future_install_global/__test__.jsonc @@ -5,7 +5,7 @@ }, "steps": [ { - "args": "install --global --root ./bins --name deno-test-bin ./main.js", + "args": "install --global --root ./bins --name deno-test-bin ./pkg/main.js", "output": "install.out" }, { diff --git a/tests/specs/install/future_install_global/install.out b/tests/specs/install/future_install_global/install.out index adb8b4598..58cd88ada 100644 --- a/tests/specs/install/future_install_global/install.out +++ b/tests/specs/install/future_install_global/install.out @@ -1,5 +1,4 @@ Download http://localhost:4260/@denotest/esm-basic Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz -Initialize @denotest/esm-basic@1.0.0 ✅ Successfully installed deno-test-bin[WILDCARD] [WILDCARD] diff --git a/tests/specs/install/future_install_global/main.js b/tests/specs/install/future_install_global/main.js deleted file mode 100644 index 2ba55540b..000000000 --- a/tests/specs/install/future_install_global/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { setValue } from "@denotest/esm-basic"; - -setValue(5); diff --git a/tests/specs/install/no_future_install_global/main.js b/tests/specs/install/future_install_global/pkg/main.js index 6268d7136..6268d7136 100644 --- a/tests/specs/install/no_future_install_global/main.js +++ b/tests/specs/install/future_install_global/pkg/main.js diff --git a/tests/specs/install/future_install_global/package.json b/tests/specs/install/future_install_global/pkg/package.json index f3b6cb7be..57493f556 100644 --- a/tests/specs/install/future_install_global/package.json +++ b/tests/specs/install/future_install_global/pkg/package.json @@ -1,7 +1,6 @@ { "name": "deno-test-bin", "dependencies": { - "@denotest/esm-basic": "*" }, "type": "module" } diff --git a/tests/specs/install/no_future_install_global/__test__.jsonc b/tests/specs/install/no_future_install_global/__test__.jsonc index ca351ee0d..657cdab80 100644 --- a/tests/specs/install/no_future_install_global/__test__.jsonc +++ b/tests/specs/install/no_future_install_global/__test__.jsonc @@ -2,7 +2,7 @@ "tempDir": true, "steps": [ { - "args": "install --root ./bins --name deno-test-bin ./main.js", + "args": "install --root ./bins --name deno-test-bin ./pkg/main.js", "output": "install.out" }, { diff --git a/tests/specs/install/no_future_install_global/install.out b/tests/specs/install/no_future_install_global/install.out index f3a394c6f..b1933f536 100644 --- a/tests/specs/install/no_future_install_global/install.out +++ b/tests/specs/install/no_future_install_global/install.out @@ -1,5 +1,6 @@ ⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use the `-g` or `--global` flag. Download http://localhost:4260/@denotest/esm-basic Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz +[# there shouldn't be a line saying it initialized the node_modules folder here because this is a global install] ✅ Successfully installed deno-test-bin[WILDCARD] [WILDCARD] diff --git a/tests/specs/install/no_future_install_global/pkg/main.js b/tests/specs/install/no_future_install_global/pkg/main.js new file mode 100644 index 000000000..6268d7136 --- /dev/null +++ b/tests/specs/install/no_future_install_global/pkg/main.js @@ -0,0 +1,3 @@ +import { setValue } from "npm:@denotest/esm-basic"; + +setValue(5); diff --git a/tests/specs/install/no_future_install_global/package.json b/tests/specs/install/no_future_install_global/pkg/package.json index 9f465ad50..9f465ad50 100644 --- a/tests/specs/install/no_future_install_global/package.json +++ b/tests/specs/install/no_future_install_global/pkg/package.json diff --git a/tests/specs/lint/no_slow_types_workspace/deno.json b/tests/specs/lint/no_slow_types_workspace/deno.json index e3dd981e5..499731c1e 100644 --- a/tests/specs/lint/no_slow_types_workspace/deno.json +++ b/tests/specs/lint/no_slow_types_workspace/deno.json @@ -1,5 +1,5 @@ { - "workspaces": [ + "workspace": [ "./a", "./b", "./c" diff --git a/tests/specs/lint/workspace/__test__.jsonc b/tests/specs/lint/workspace/__test__.jsonc new file mode 100644 index 000000000..6581222c9 --- /dev/null +++ b/tests/specs/lint/workspace/__test__.jsonc @@ -0,0 +1,15 @@ +{ + "tests": { + "root": { + "args": "lint", + "exitCode": 1, + "output": "root.out" + }, + "subdir": { + "args": "lint", + "cwd": "package-a", + "exitCode": 1, + "output": "a.out" + } + } +} diff --git a/tests/specs/lint/workspace/a.out b/tests/specs/lint/workspace/a.out new file mode 100644 index 000000000..52f05af99 --- /dev/null +++ b/tests/specs/lint/workspace/a.out @@ -0,0 +1,32 @@ +error[no-eval]: `eval` call is not allowed + --> [WILDLINE]a.ts:1:1 + | +1 | eval(""); + | ^^^^^^^^ + = hint: Remove the use of `eval` + + docs: https://lint.deno.land/rules/no-eval + + +error[no-await-in-loop]: Unexpected `await` inside a loop. + --> [WILDLINE]a.ts:4:3 + | +4 | await Deno.open("test"); + | ^^^^^^^^^^^^^^^^^^^^^^^ + = hint: Remove `await` in loop body, store all promises generated and then `await Promise.all(storedPromises)` after the loop + + docs: https://lint.deno.land/rules/no-await-in-loop + + +error[no-explicit-any]: `any` type is not allowed + --> [WILDLINE]a.ts:9:25 + | +9 | export function test(): any { + | ^^^ + = hint: Use a specific type other than `any` + + docs: https://lint.deno.land/rules/no-explicit-any + + +Found 3 problems +Checked 1 file diff --git a/tests/specs/lint/workspace/deno.json b/tests/specs/lint/workspace/deno.json new file mode 100644 index 000000000..2dab3a4ec --- /dev/null +++ b/tests/specs/lint/workspace/deno.json @@ -0,0 +1,11 @@ +{ + "workspace": [ + "./package-a", + "./package-b" + ], + "lint": { + "rules": { + "include": ["no-eval"] + } + } +} diff --git a/tests/specs/lint/workspace/package-a/a.ts b/tests/specs/lint/workspace/package-a/a.ts new file mode 100644 index 000000000..52bd0cbc0 --- /dev/null +++ b/tests/specs/lint/workspace/package-a/a.ts @@ -0,0 +1,11 @@ +eval(""); + +for (let i = 0; i < 10; i++) { + await Deno.open("test"); +} + +const unused = 1; + +export function test(): any { + return {}; +} diff --git a/tests/specs/lint/workspace/package-a/deno.json b/tests/specs/lint/workspace/package-a/deno.json new file mode 100644 index 000000000..34130b647 --- /dev/null +++ b/tests/specs/lint/workspace/package-a/deno.json @@ -0,0 +1,12 @@ +{ + "lint": { + "rules": { + "include": [ + "no-await-in-loop" + ], + "exclude": [ + "no-unused-vars" + ] + } + } +} diff --git a/tests/specs/lint/workspace/package-b/b.ts b/tests/specs/lint/workspace/package-b/b.ts new file mode 100644 index 000000000..52bd0cbc0 --- /dev/null +++ b/tests/specs/lint/workspace/package-b/b.ts @@ -0,0 +1,11 @@ +eval(""); + +for (let i = 0; i < 10; i++) { + await Deno.open("test"); +} + +const unused = 1; + +export function test(): any { + return {}; +} diff --git a/tests/specs/lint/workspace/package-b/deno.json b/tests/specs/lint/workspace/package-b/deno.json new file mode 100644 index 000000000..93fdf6ca7 --- /dev/null +++ b/tests/specs/lint/workspace/package-b/deno.json @@ -0,0 +1,9 @@ +{ + "lint": { + "rules": { + "exclude": [ + "no-explicit-any" + ] + } + } +} diff --git a/tests/specs/lint/workspace/root.out b/tests/specs/lint/workspace/root.out new file mode 100644 index 000000000..1d892a93f --- /dev/null +++ b/tests/specs/lint/workspace/root.out @@ -0,0 +1,82 @@ +error[no-eval]: `eval` call is not allowed + --> [WILDLINE]root.ts:1:1 + | +1 | eval(""); + | ^^^^^^^^ + = hint: Remove the use of `eval` + + docs: https://lint.deno.land/rules/no-eval + + +error[no-unused-vars]: `unused` is never used + --> [WILDLINE]root.ts:7:7 + | +7 | const unused = 1; + | ^^^^^^ + = hint: If this is intentional, prefix it with an underscore like `_unused` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-explicit-any]: `any` type is not allowed + --> [WILDLINE]root.ts:9:25 + | +9 | export function test(): any { + | ^^^ + = hint: Use a specific type other than `any` + + docs: https://lint.deno.land/rules/no-explicit-any + + +error[no-eval]: `eval` call is not allowed + --> [WILDLINE]package-a[WILDCHAR]a.ts:1:1 + | +1 | eval(""); + | ^^^^^^^^ + = hint: Remove the use of `eval` + + docs: https://lint.deno.land/rules/no-eval + + +error[no-await-in-loop]: Unexpected `await` inside a loop. + --> [WILDLINE]package-a[WILDCHAR]a.ts:4:3 + | +4 | await Deno.open("test"); + | ^^^^^^^^^^^^^^^^^^^^^^^ + = hint: Remove `await` in loop body, store all promises generated and then `await Promise.all(storedPromises)` after the loop + + docs: https://lint.deno.land/rules/no-await-in-loop + + +error[no-explicit-any]: `any` type is not allowed + --> [WILDLINE]package-a[WILDCHAR]a.ts:9:25 + | +9 | export function test(): any { + | ^^^ + = hint: Use a specific type other than `any` + + docs: https://lint.deno.land/rules/no-explicit-any + + +error[no-eval]: `eval` call is not allowed + --> [WILDLINE]package-b[WILDCHAR]b.ts:1:1 + | +1 | eval(""); + | ^^^^^^^^ + = hint: Remove the use of `eval` + + docs: https://lint.deno.land/rules/no-eval + + +error[no-unused-vars]: `unused` is never used + --> [WILDLINE]b.ts:7:7 + | +7 | const unused = 1; + | ^^^^^^ + = hint: If this is intentional, prefix it with an underscore like `_unused` + + docs: https://lint.deno.land/rules/no-unused-vars + + +Found 8 problems +Checked 3 files diff --git a/tests/specs/lint/workspace/root.ts b/tests/specs/lint/workspace/root.ts new file mode 100644 index 000000000..52bd0cbc0 --- /dev/null +++ b/tests/specs/lint/workspace/root.ts @@ -0,0 +1,11 @@ +eval(""); + +for (let i = 0; i < 10; i++) { + await Deno.open("test"); +} + +const unused = 1; + +export function test(): any { + return {}; +} diff --git a/tests/specs/lint/workspace_no_slow_types/__test__.jsonc b/tests/specs/lint/workspace_no_slow_types/__test__.jsonc new file mode 100644 index 000000000..489ee52ab --- /dev/null +++ b/tests/specs/lint/workspace_no_slow_types/__test__.jsonc @@ -0,0 +1,27 @@ +{ + "tests": { + "root": { + "args": "lint", + "exitCode": 1, + "output": "root.out" + }, + "package_a": { + "args": "lint", + "cwd": "a", + "exitCode": 1, + "output": "a.out" + }, + "package_b": { + "args": "lint", + "cwd": "b", + "exitCode": 1, + "output": "b.out" + }, + "package_c": { + "args": "lint", + "cwd": "c", + "exitCode": 0, + "output": "Checked 1 file\n" + } + } +} diff --git a/tests/specs/lint/workspace_no_slow_types/a.out b/tests/specs/lint/workspace_no_slow_types/a.out new file mode 100644 index 000000000..12c6715be --- /dev/null +++ b/tests/specs/lint/workspace_no_slow_types/a.out @@ -0,0 +1,14 @@ +error[no-slow-types]: missing explicit return type in the public API + --> [WILDLINE]a.ts:1:17 + | +1 | export function noReturnType() { + | ^^^^^^^^^^^^ this function is missing an explicit return type + | + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +Found 1 problem +Checked 1 file diff --git a/tests/specs/lint/workspace_no_slow_types/a/a.ts b/tests/specs/lint/workspace_no_slow_types/a/a.ts new file mode 100644 index 000000000..6db944d6c --- /dev/null +++ b/tests/specs/lint/workspace_no_slow_types/a/a.ts @@ -0,0 +1,3 @@ +export function noReturnType() { + return Math.random(); +} diff --git a/tests/specs/lint/workspace_no_slow_types/a/deno.json b/tests/specs/lint/workspace_no_slow_types/a/deno.json new file mode 100644 index 000000000..9547d1bd9 --- /dev/null +++ b/tests/specs/lint/workspace_no_slow_types/a/deno.json @@ -0,0 +1,5 @@ +{ + "name": "@scope/a", + "version": "1.0.0", + "exports": "./a.ts" +} diff --git a/tests/specs/lint/workspace_no_slow_types/b.out b/tests/specs/lint/workspace_no_slow_types/b.out new file mode 100644 index 000000000..e3e2d575d --- /dev/null +++ b/tests/specs/lint/workspace_no_slow_types/b.out @@ -0,0 +1,14 @@ +error[no-slow-types]: missing explicit return type in the public API + --> [WILDLINE]b.ts:7:17 + | +7 | export function doesNotHaveReturnType() { + | ^^^^^^^^^^^^^^^^^^^^^ this function is missing an explicit return type + | + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +Found 1 problem +Checked 1 file diff --git a/tests/specs/lint/workspace_no_slow_types/b/b.ts b/tests/specs/lint/workspace_no_slow_types/b/b.ts new file mode 100644 index 000000000..05cb08628 --- /dev/null +++ b/tests/specs/lint/workspace_no_slow_types/b/b.ts @@ -0,0 +1,9 @@ +import { noReturnType } from "@scope/a"; + +export function hasReturnType(): number { + return noReturnType(); +} + +export function doesNotHaveReturnType() { + return noReturnType(); +} diff --git a/tests/specs/lint/workspace_no_slow_types/b/deno.json b/tests/specs/lint/workspace_no_slow_types/b/deno.json new file mode 100644 index 000000000..a27c1e5cd --- /dev/null +++ b/tests/specs/lint/workspace_no_slow_types/b/deno.json @@ -0,0 +1,5 @@ +{ + "name": "@scope/b", + "version": "1.0.0", + "exports": "./b.ts" +} diff --git a/tests/specs/lint/workspace_no_slow_types/c/c.ts b/tests/specs/lint/workspace_no_slow_types/c/c.ts new file mode 100644 index 000000000..3f5f46171 --- /dev/null +++ b/tests/specs/lint/workspace_no_slow_types/c/c.ts @@ -0,0 +1,6 @@ +import { noReturnType } from "@scope/a"; +import { hasReturnType } from "@scope/b"; + +export function myExport(): number { + return noReturnType() + hasReturnType(); +} diff --git a/tests/specs/lint/workspace_no_slow_types/c/deno.json b/tests/specs/lint/workspace_no_slow_types/c/deno.json new file mode 100644 index 000000000..618250b98 --- /dev/null +++ b/tests/specs/lint/workspace_no_slow_types/c/deno.json @@ -0,0 +1,5 @@ +{ + "name": "@scope/c", + "version": "1.0.0", + "exports": "./c.ts" +} diff --git a/tests/specs/lint/workspace_no_slow_types/deno.json b/tests/specs/lint/workspace_no_slow_types/deno.json new file mode 100644 index 000000000..499731c1e --- /dev/null +++ b/tests/specs/lint/workspace_no_slow_types/deno.json @@ -0,0 +1,7 @@ +{ + "workspace": [ + "./a", + "./b", + "./c" + ] +} diff --git a/tests/specs/lint/workspace_no_slow_types/root.out b/tests/specs/lint/workspace_no_slow_types/root.out new file mode 100644 index 000000000..50fda50c3 --- /dev/null +++ b/tests/specs/lint/workspace_no_slow_types/root.out @@ -0,0 +1,26 @@ +error[no-slow-types]: missing explicit return type in the public API + --> [WILDLINE]a.ts:1:17 + | +1 | export function noReturnType() { + | ^^^^^^^^^^^^ this function is missing an explicit return type + | + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +error[no-slow-types]: missing explicit return type in the public API + --> [WILDLINE]b.ts:7:17 + | +7 | export function doesNotHaveReturnType() { + | ^^^^^^^^^^^^^^^^^^^^^ this function is missing an explicit return type + | + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +Found 2 problems +Checked 3 files diff --git a/tests/specs/npm/check_prefers_non_types_node_pkg/__test__.jsonc b/tests/specs/npm/check_prefers_non_types_node_pkg/__test__.jsonc index ed3827ef6..8c4d0fb20 100644 --- a/tests/specs/npm/check_prefers_non_types_node_pkg/__test__.jsonc +++ b/tests/specs/npm/check_prefers_non_types_node_pkg/__test__.jsonc @@ -1,7 +1,28 @@ { - "envs": { - "DENO_FUTURE": "1" - }, - "args": "check --quiet main.ts", - "output": "" + "tempDir": true, + "tests": { + "byonm": { + "envs": { + "DENO_FUTURE": "1" + }, + "steps": [{ + "args": "install", + "output": "[WILDCARD]" + }, { + "args": "check --quiet main.ts", + "exitCode": 1, + "output": "expected.out" + }] + }, + "auto_install": { + "args": "check --node-modules-dir=true --quiet main.ts", + "exitCode": 1, + "output": "expected.out" + }, + "global_folder": { + "args": "check --node-modules-dir=false --quiet main.ts", + "exitCode": 1, + "output": "expected.out" + } + } } diff --git a/tests/specs/npm/check_prefers_non_types_node_pkg/expected.out b/tests/specs/npm/check_prefers_non_types_node_pkg/expected.out new file mode 100644 index 000000000..37d41aae2 --- /dev/null +++ b/tests/specs/npm/check_prefers_non_types_node_pkg/expected.out @@ -0,0 +1,4 @@ +error: TS2345 [ERROR]: Argument of type 'number' is not assignable to parameter of type 'string'. +console.log(compressToEncodedURIComponent(123)); + ~~~ + at file:///[WILDLINE] diff --git a/tests/specs/npm/check_prefers_non_types_node_pkg/main.ts b/tests/specs/npm/check_prefers_non_types_node_pkg/main.ts index 8774bdbfc..f28d132d1 100644 --- a/tests/specs/npm/check_prefers_non_types_node_pkg/main.ts +++ b/tests/specs/npm/check_prefers_non_types_node_pkg/main.ts @@ -1,3 +1,5 @@ +// this lz-string@1.5 pkg has types only in the regular package and not the @types/lz-string pkg import { compressToEncodedURIComponent } from "lz-string"; -console.log(compressToEncodedURIComponent("Hello, World!")); +// cause a deliberate type checking error +console.log(compressToEncodedURIComponent(123)); diff --git a/tests/specs/npm/check_prefers_non_types_node_pkg/node_modules/@types/lz-string/package.json b/tests/specs/npm/check_prefers_non_types_node_pkg/node_modules/@types/lz-string/package.json deleted file mode 100644 index afe623e00..000000000 --- a/tests/specs/npm/check_prefers_non_types_node_pkg/node_modules/@types/lz-string/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "@types/lz-string", - "version": "1.5.0", - "description": "Stub TypeScript definitions entry for lz-string, which provides its own types definitions", - "main": "", - "scripts": {}, - "license": "MIT", - "dependencies": { - "lz-string": "*" - }, - "deprecated": "This is a stub types definition. lz-string provides its own type definitions, so you do not need this installed." -} diff --git a/tests/specs/npm/check_prefers_non_types_node_pkg/node_modules/lz-string/index.d.ts b/tests/specs/npm/check_prefers_non_types_node_pkg/node_modules/lz-string/index.d.ts deleted file mode 100644 index b6abfd8ba..000000000 --- a/tests/specs/npm/check_prefers_non_types_node_pkg/node_modules/lz-string/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function compressToEncodedURIComponent(input: string): string; diff --git a/tests/specs/npm/check_prefers_non_types_node_pkg/node_modules/lz-string/index.js b/tests/specs/npm/check_prefers_non_types_node_pkg/node_modules/lz-string/index.js deleted file mode 100644 index 603b710ba..000000000 --- a/tests/specs/npm/check_prefers_non_types_node_pkg/node_modules/lz-string/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports.compressToEncodedURIComponent = (a) => a; diff --git a/tests/specs/npm/check_prefers_non_types_node_pkg/node_modules/lz-string/package.json b/tests/specs/npm/check_prefers_non_types_node_pkg/node_modules/lz-string/package.json deleted file mode 100644 index f8bfd5d98..000000000 --- a/tests/specs/npm/check_prefers_non_types_node_pkg/node_modules/lz-string/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "lz-string", - "version": "1.5.0" -}
\ No newline at end of file diff --git a/tests/specs/npm/check_prefers_non_types_node_pkg/package.json b/tests/specs/npm/check_prefers_non_types_node_pkg/package.json index ea3b2d26f..a812a973e 100644 --- a/tests/specs/npm/check_prefers_non_types_node_pkg/package.json +++ b/tests/specs/npm/check_prefers_non_types_node_pkg/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "lz-string": "*", - "@types/lz-string": "*" + "lz-string": "1.5", + "@types/lz-string": "1.5" } } diff --git a/tests/specs/npm/check_types_in_types_pkg/__test__.jsonc b/tests/specs/npm/check_types_in_types_pkg/__test__.jsonc new file mode 100644 index 000000000..7b7a429f4 --- /dev/null +++ b/tests/specs/npm/check_types_in_types_pkg/__test__.jsonc @@ -0,0 +1,28 @@ +{ + "tempDir": true, + "tests": { + "byonm": { + "envs": { + "DENO_FUTURE": "1" + }, + "steps": [{ + "args": "install", + "output": "[WILDCARD]" + }, { + "args": "check --quiet main.ts", + "exitCode": 1, + "output": "expected.out" + }] + }, + "auto_install": { + "args": "check --node-modules-dir=true --quiet main_auto_install.ts", + "exitCode": 1, + "output": "expected.out" + }, + "global_folder": { + "args": "check --node-modules-dir=false --quiet main_auto_install.ts", + "exitCode": 1, + "output": "expected.out" + } + } +} diff --git a/tests/specs/npm/check_types_in_types_pkg/expected.out b/tests/specs/npm/check_types_in_types_pkg/expected.out new file mode 100644 index 000000000..37d41aae2 --- /dev/null +++ b/tests/specs/npm/check_types_in_types_pkg/expected.out @@ -0,0 +1,4 @@ +error: TS2345 [ERROR]: Argument of type 'number' is not assignable to parameter of type 'string'. +console.log(compressToEncodedURIComponent(123)); + ~~~ + at file:///[WILDLINE] diff --git a/tests/specs/npm/check_types_in_types_pkg/main.ts b/tests/specs/npm/check_types_in_types_pkg/main.ts new file mode 100644 index 000000000..adc164ea5 --- /dev/null +++ b/tests/specs/npm/check_types_in_types_pkg/main.ts @@ -0,0 +1,5 @@ +// this lz-string@1.3 pkg doesn't have types, but the @types/lz-string@1.3 does +import { compressToEncodedURIComponent } from "lz-string"; + +// cause a deliberate type checking error +console.log(compressToEncodedURIComponent(123)); diff --git a/tests/specs/npm/check_types_in_types_pkg/main_auto_install.ts b/tests/specs/npm/check_types_in_types_pkg/main_auto_install.ts new file mode 100644 index 000000000..af47e13ac --- /dev/null +++ b/tests/specs/npm/check_types_in_types_pkg/main_auto_install.ts @@ -0,0 +1,6 @@ +// this lz-string@1.3 pkg doesn't have types, but the @types/lz-string@1.3 does +// @deno-types="@types/lz-string" +import { compressToEncodedURIComponent } from "lz-string"; + +// cause a deliberate type checking error +console.log(compressToEncodedURIComponent(123)); diff --git a/tests/specs/npm/check_types_in_types_pkg/package.json b/tests/specs/npm/check_types_in_types_pkg/package.json new file mode 100644 index 000000000..e8079d112 --- /dev/null +++ b/tests/specs/npm/check_types_in_types_pkg/package.json @@ -0,0 +1,6 @@ +{ + "dependencies": { + "lz-string": "1.3", + "@types/lz-string": "1.3" + } +} diff --git a/tests/specs/npm/workspace_basic/__test__.jsonc b/tests/specs/npm/workspace_basic/__test__.jsonc new file mode 100644 index 000000000..79e059ca1 --- /dev/null +++ b/tests/specs/npm/workspace_basic/__test__.jsonc @@ -0,0 +1,35 @@ +{ + "tempDir": true, + "tests": { + "global_cache": { + "args": "run --node-modules-dir=false b/main.ts", + "output": "b/main_global_cache.out" + }, + "node_modules_dir": { + "args": "run --node-modules-dir=true b/main.ts", + "output": "b/main_node_modules_dir.out" + }, + "byonm": { + "envs": { + "DENO_FUTURE": "1" + }, + "steps": [{ + "args": "install", + "output": "[WILDCARD]" + }, { + "args": "run b/main.ts", + "output": "b/main_byonm.out" + }] + }, + "exports_sub_path_not_exists": { + "args": "run b/exports-sub-path-not-exists.ts", + "output": "b/exports-sub-path-not-exists.out", + "exitCode": 1 + }, + "no_exports_sub_path_not_exists": { + "args": "run b/no-exports-sub-path-not-exists.ts", + "output": "b/no-exports-sub-path-not-exists.out", + "exitCode": 1 + } + } +} diff --git a/tests/specs/npm/workspace_basic/a/mod.ts b/tests/specs/npm/workspace_basic/a/mod.ts new file mode 100644 index 000000000..9f8d1c594 --- /dev/null +++ b/tests/specs/npm/workspace_basic/a/mod.ts @@ -0,0 +1,6 @@ +import { getValue, setValue } from "@denotest/esm-basic"; + +export function sayHello() { + setValue(5); + console.log("Hello", getValue()); +} diff --git a/tests/specs/npm/workspace_basic/a/package.json b/tests/specs/npm/workspace_basic/a/package.json new file mode 100644 index 000000000..1467823cf --- /dev/null +++ b/tests/specs/npm/workspace_basic/a/package.json @@ -0,0 +1,10 @@ +{ + "name": "@denotest/a", + "version": "1.0.0", + "dependencies": { + "@denotest/esm-basic": "*" + }, + "exports": { + ".": "./mod.ts" + } +} diff --git a/tests/specs/npm/workspace_basic/b/exports-sub-path-not-exists.out b/tests/specs/npm/workspace_basic/b/exports-sub-path-not-exists.out new file mode 100644 index 000000000..5e61cdfc3 --- /dev/null +++ b/tests/specs/npm/workspace_basic/b/exports-sub-path-not-exists.out @@ -0,0 +1,2 @@ +error: [ERR_PACKAGE_PATH_NOT_EXPORTED] Package subpath './non-existent' is not defined by "exports" in '[WILDLINE]package.json' imported from '[WILDLINE]exports-sub-path-not-exists.ts' + at file:///[WILDLINE]exports-sub-path-not-exists.ts:1:20 diff --git a/tests/specs/npm/workspace_basic/b/exports-sub-path-not-exists.ts b/tests/specs/npm/workspace_basic/b/exports-sub-path-not-exists.ts new file mode 100644 index 000000000..716f0f97d --- /dev/null +++ b/tests/specs/npm/workspace_basic/b/exports-sub-path-not-exists.ts @@ -0,0 +1,2 @@ +import * as a from "@denotest/a/non-existent"; +console.log(a); diff --git a/tests/specs/npm/workspace_basic/b/main.ts b/tests/specs/npm/workspace_basic/b/main.ts new file mode 100644 index 000000000..03956388c --- /dev/null +++ b/tests/specs/npm/workspace_basic/b/main.ts @@ -0,0 +1,9 @@ +import * as a1 from "@denotest/a"; +import * as a2 from "npm:@denotest/a@1"; +import * as a3 from "npm:@denotest/a@workspace"; +import * as c from "@denotest/c"; + +a1.sayHello(); +a2.sayHello(); +a3.sayHello(); +c.sayHello(); diff --git a/tests/specs/npm/workspace_basic/b/main_byonm.out b/tests/specs/npm/workspace_basic/b/main_byonm.out new file mode 100644 index 000000000..3a311dcd7 --- /dev/null +++ b/tests/specs/npm/workspace_basic/b/main_byonm.out @@ -0,0 +1,4 @@ +Hello 5 +Hello 5 +Hello 5 +C: Hi! diff --git a/tests/specs/npm/workspace_basic/b/main_global_cache.out b/tests/specs/npm/workspace_basic/b/main_global_cache.out new file mode 100644 index 000000000..1ca11026a --- /dev/null +++ b/tests/specs/npm/workspace_basic/b/main_global_cache.out @@ -0,0 +1,6 @@ +Download http://localhost:4260/@denotest/esm-basic +Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz +Hello 5 +Hello 5 +Hello 5 +C: Hi! diff --git a/tests/specs/npm/workspace_basic/b/main_node_modules_dir.out b/tests/specs/npm/workspace_basic/b/main_node_modules_dir.out new file mode 100644 index 000000000..82a49b9fe --- /dev/null +++ b/tests/specs/npm/workspace_basic/b/main_node_modules_dir.out @@ -0,0 +1,7 @@ +Download http://localhost:4260/@denotest/esm-basic +Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz +Initialize @denotest/esm-basic@1.0.0 +Hello 5 +Hello 5 +Hello 5 +C: Hi! diff --git a/tests/specs/npm/workspace_basic/b/no-exports-sub-path-not-exists.out b/tests/specs/npm/workspace_basic/b/no-exports-sub-path-not-exists.out new file mode 100644 index 000000000..f98aa34cb --- /dev/null +++ b/tests/specs/npm/workspace_basic/b/no-exports-sub-path-not-exists.out @@ -0,0 +1,3 @@ +[# not the best error, but it did resolve because there was no exports specified] +error: Module not found "file:///[WILDLINE]/c/non-existent". + at file:///[WILDLINE]/b/no-exports-sub-path-not-exists.ts:1:20 diff --git a/tests/specs/npm/workspace_basic/b/no-exports-sub-path-not-exists.ts b/tests/specs/npm/workspace_basic/b/no-exports-sub-path-not-exists.ts new file mode 100644 index 000000000..960d32870 --- /dev/null +++ b/tests/specs/npm/workspace_basic/b/no-exports-sub-path-not-exists.ts @@ -0,0 +1,2 @@ +import * as c from "@denotest/c/non-existent"; +console.log(c); diff --git a/tests/specs/npm/workspace_basic/b/package.json b/tests/specs/npm/workspace_basic/b/package.json new file mode 100644 index 000000000..4b876d5b9 --- /dev/null +++ b/tests/specs/npm/workspace_basic/b/package.json @@ -0,0 +1,8 @@ +{ + "name": "@denotest/b", + "version": "1.0.0", + "dependencies": { + "@denotest/a": "1", + "@denotest/c": "workspace:*" + } +} diff --git a/tests/specs/npm/workspace_basic/c/index.js b/tests/specs/npm/workspace_basic/c/index.js new file mode 100644 index 000000000..f412f7d4b --- /dev/null +++ b/tests/specs/npm/workspace_basic/c/index.js @@ -0,0 +1,3 @@ +export function sayHello() { + console.log("C: Hi!"); +} diff --git a/tests/specs/npm/workspace_basic/c/package.json b/tests/specs/npm/workspace_basic/c/package.json new file mode 100644 index 000000000..7d5ca9abf --- /dev/null +++ b/tests/specs/npm/workspace_basic/c/package.json @@ -0,0 +1,4 @@ +{ + "name": "@denotest/c", + "version": "1.0.0" +} diff --git a/tests/specs/npm/workspace_basic/package.json b/tests/specs/npm/workspace_basic/package.json new file mode 100644 index 000000000..e3dd981e5 --- /dev/null +++ b/tests/specs/npm/workspace_basic/package.json @@ -0,0 +1,7 @@ +{ + "workspaces": [ + "./a", + "./b", + "./c" + ] +} diff --git a/tests/specs/publish/byonm_dep/publish.out b/tests/specs/publish/byonm_dep/publish.out index a7433f86f..64cf90921 100644 --- a/tests/specs/publish/byonm_dep/publish.out +++ b/tests/specs/publish/byonm_dep/publish.out @@ -2,6 +2,6 @@ Check file:///[WILDLINE]/mod.ts Checking for slow types in the public API... Check file:///[WILDLINE]/mod.ts Simulating publish of @scope/package@0.0.0 with files: - file:///[WILDLINE]/deno.jsonc (300B) - file:///[WILDLINE]/mod.ts (129B) + file:///[WILDLINE]/deno.jsonc ([WILDLINE]) + file:///[WILDLINE]/mod.ts ([WILDLINE]) Warning Aborting due to --dry-run diff --git a/tests/specs/publish/workspace/__test__.jsonc b/tests/specs/publish/workspace/__test__.jsonc index 7b1c04d56..706b08ccd 100644 --- a/tests/specs/publish/workspace/__test__.jsonc +++ b/tests/specs/publish/workspace/__test__.jsonc @@ -1,10 +1,13 @@ { - "steps": [{ - "args": "publish --token 'sadfasdf'", - "output": "workspace.out" - }, { - "cwd": "./bar", - "args": "publish --token 'sadfasdf'", - "output": "workspace_individual.out" - }] + "tests": { + "workspace": { + "args": "publish --token 'sadfasdf'", + "output": "workspace.out" + }, + "individual": { + "cwd": "./bar", + "args": "publish --token 'sadfasdf'", + "output": "workspace_individual.out" + } + } } diff --git a/tests/specs/publish/workspace/deno.json b/tests/specs/publish/workspace/deno.json index 57602aab5..a23790570 100644 --- a/tests/specs/publish/workspace/deno.json +++ b/tests/specs/publish/workspace/deno.json @@ -1,5 +1,5 @@ { - "workspaces": [ + "workspace": [ "foo", "bar" ] diff --git a/tests/specs/publish/workspace/workspace.out b/tests/specs/publish/workspace/workspace.out index 8c57bc2dd..3114e36db 100644 --- a/tests/specs/publish/workspace/workspace.out +++ b/tests/specs/publish/workspace/workspace.out @@ -1,9 +1,9 @@ Publishing a workspace... -Check file:///[WILDCARD]/foo/mod.ts -Check file:///[WILDCARD]/bar/mod.ts +Check file:///[WILDLINE]/bar/mod.ts +Check file:///[WILDLINE]/foo/mod.ts Checking for slow types in the public API... -Check file:///[WILDCARD]/foo/mod.ts -Check file:///[WILDCARD]/bar/mod.ts +Check file:///[WILDLINE]/bar/mod.ts +Check file:///[WILDLINE]/foo/mod.ts Publishing @foo/bar@1.0.0 ... Successfully published @foo/bar@1.0.0 Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details diff --git a/tests/specs/publish/workspace/workspace_individual.out b/tests/specs/publish/workspace/workspace_individual.out index edb6b53aa..2cb071709 100644 --- a/tests/specs/publish/workspace/workspace_individual.out +++ b/tests/specs/publish/workspace/workspace_individual.out @@ -1,6 +1,6 @@ -Check file:///[WILDCARD]/bar/mod.ts +Check file:///[WILDLINE]/bar/mod.ts Checking for slow types in the public API... -Check file:///[WILDCARD]/bar/mod.ts +Check file:///[WILDLINE]/bar/mod.ts Publishing @foo/bar@1.0.0 ... Successfully published @foo/bar@1.0.0 Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details diff --git a/tests/specs/run/no_deno_json/__test__.jsonc b/tests/specs/run/no_deno_json/__test__.jsonc index 67867f023..5da0209b9 100644 --- a/tests/specs/run/no_deno_json/__test__.jsonc +++ b/tests/specs/run/no_deno_json/__test__.jsonc @@ -1,36 +1,43 @@ { "tempDir": true, - "steps": [{ - // --no-config - "args": "run -L debug -A --no-config noconfig.ts", - "output": "noconfig.out", - "cwd": "code" - }, { - // --no-npm - "args": "run -L debug -A --no-npm noconfig.ts", - "output": "noconfig.out", - "cwd": "code" - }, { - // not auto-discovered with env var - "args": "run -L debug -A noconfig.ts", - "output": "noconfig.out", - "cwd": "code", - "envs": { - "DENO_NO_PACKAGE_JSON": "1" + "tests": { + "no_config": { + // --no-config + "args": "run -L debug -A --no-config noconfig.ts", + "output": "noconfig.out", + "cwd": "code" + }, + "no_npm": { + // --no-npm + "args": "run -L debug -A --no-npm noconfig.ts", + "output": "noconfig.out", + "cwd": "code" + }, + "no_pkg_json_env_var": { + // not auto-discovered with env var + "args": "run -L debug -A noconfig.ts", + "output": "no_package_json.out", + "cwd": "code", + "envs": { + "DENO_NO_PACKAGE_JSON": "1" + } + }, + "no_pkg_json_imports": { + // this should not use --quiet because we should ensure no package.json install occurs + "args": "run -A no_package_json_imports.ts", + "output": "no_package_json_imports.out", + "cwd": "code" + }, + "auto_discovered": { + // auto-discovered node_modules relative package.json + "args": "run -A main.js", + "output": "code/sub_dir/main.out", + "cwd": "code/sub_dir" + }, + "auto_discovered_arg": { + // auto-discovered for local script arg + "args": "run -L debug -A code/main.ts", // notice this is not in the sub dir + "output": "main.out" } - }, { - // this should not use --quiet because we should ensure no package.json install occurs - "args": "run -A no_package_json_imports.ts", - "output": "no_package_json_imports.out", - "cwd": "code" - }, { - // auto-discovered node_modules relative package.json - "args": "run -A main.js", - "output": "code/sub_dir/main.out", - "cwd": "code/sub_dir" - }, { - // auto-discovered for local script arg - "args": "run -L debug -A code/main.ts", // notice this is not in the sub dir - "output": "main.out" - }] + } } diff --git a/tests/specs/run/no_deno_json/no_package_json.out b/tests/specs/run/no_deno_json/no_package_json.out new file mode 100644 index 000000000..b9f9a6dea --- /dev/null +++ b/tests/specs/run/no_deno_json/no_package_json.out @@ -0,0 +1,4 @@ +[WILDCARD]package.json auto-discovery is disabled +[WILDCARD] +success +[WILDCARD] diff --git a/tests/specs/run/no_deno_json/noconfig.out b/tests/specs/run/no_deno_json/noconfig.out index b9f9a6dea..000ce402b 100644 --- a/tests/specs/run/no_deno_json/noconfig.out +++ b/tests/specs/run/no_deno_json/noconfig.out @@ -1,4 +1,3 @@ -[WILDCARD]package.json auto-discovery is disabled [WILDCARD] success [WILDCARD] diff --git a/tests/specs/run/workspaces/basic/deno.json b/tests/specs/run/workspaces/basic/deno.json index b971c4f3d..a39778a6d 100644 --- a/tests/specs/run/workspaces/basic/deno.json +++ b/tests/specs/run/workspaces/basic/deno.json @@ -1,5 +1,5 @@ { - "workspaces": [ + "workspace": [ "foo", "bar" ], diff --git a/tests/specs/run/workspaces/basic/main.out b/tests/specs/run/workspaces/basic/main.out index 57d8c9f1e..9806f7d63 100644 --- a/tests/specs/run/workspaces/basic/main.out +++ b/tests/specs/run/workspaces/basic/main.out @@ -2,19 +2,19 @@ "imports": { "chalk": "npm:chalk", "chalk/": "npm:/chalk/", - "qwerqwer": "jsr:qwerqwer@^0.0.0", - "qwerqwer/": "jsr:/qwerqwer@^0.0.0/", "asdfasdfasdf": "jsr:asdfasdfasdf@^0.0.0", - "asdfasdfasdf/": "jsr:/asdfasdfasdf@^0.0.0/" + "asdfasdfasdf/": "jsr:/asdfasdfasdf@^0.0.0/", + "qwerqwer": "jsr:qwerqwer@^0.0.0", + "qwerqwer/": "jsr:/qwerqwer@^0.0.0/" }, "scopes": { - "./foo/": { - "~/": "./foo/", - "foo/": "./foo/bar/" - }, "./bar/": { "@/": "./bar/", "secret_mod/": "./bar/some_mod/" + }, + "./foo/": { + "~/": "./foo/", + "foo/": "./foo/bar/" } } } diff --git a/tests/specs/run/workspaces/member_outside_root_dir/__test__.jsonc b/tests/specs/run/workspaces/member_outside_root_dir/__test__.jsonc index a7669c1ec..3b7f35c62 100644 --- a/tests/specs/run/workspaces/member_outside_root_dir/__test__.jsonc +++ b/tests/specs/run/workspaces/member_outside_root_dir/__test__.jsonc @@ -1,5 +1,5 @@ { - "args": "run -A main.ts", + "args": "run -A sub_dir/child/main.ts", "output": "main.out", "tempDir": true, "exitCode": 1 diff --git a/tests/specs/run/workspaces/member_outside_root_dir/main.out b/tests/specs/run/workspaces/member_outside_root_dir/main.out index 205d95aea..72f0b0b45 100644 --- a/tests/specs/run/workspaces/member_outside_root_dir/main.out +++ b/tests/specs/run/workspaces/member_outside_root_dir/main.out @@ -1 +1,3 @@ -error: Workspace member '../other_folder' is outside root configuration directory[WILDCARD]
\ No newline at end of file +error: Workspace member must be nested in a directory under the workspace. + Member: file:///[WILDLINE]/sub_dir/other_folder/ + Workspace: file:///[WILDLINE]/sub_dir/child/ diff --git a/tests/specs/run/workspaces/member_outside_root_dir/deno.json b/tests/specs/run/workspaces/member_outside_root_dir/sub_dir/child/deno.json index 25feefad8..189d212b5 100644 --- a/tests/specs/run/workspaces/member_outside_root_dir/deno.json +++ b/tests/specs/run/workspaces/member_outside_root_dir/sub_dir/child/deno.json @@ -1,5 +1,5 @@ { - "workspaces": [ + "workspace": [ "foo", "../other_folder" ], diff --git a/tests/specs/run/workspaces/member_outside_root_dir/foo/bar/hello.ts b/tests/specs/run/workspaces/member_outside_root_dir/sub_dir/child/foo/bar/hello.ts index c8a7e57c4..c8a7e57c4 100644 --- a/tests/specs/run/workspaces/member_outside_root_dir/foo/bar/hello.ts +++ b/tests/specs/run/workspaces/member_outside_root_dir/sub_dir/child/foo/bar/hello.ts diff --git a/tests/specs/run/workspaces/member_outside_root_dir/foo/deno.json b/tests/specs/run/workspaces/member_outside_root_dir/sub_dir/child/foo/deno.json index 46d84f06f..46d84f06f 100644 --- a/tests/specs/run/workspaces/member_outside_root_dir/foo/deno.json +++ b/tests/specs/run/workspaces/member_outside_root_dir/sub_dir/child/foo/deno.json diff --git a/tests/specs/run/workspaces/member_outside_root_dir/foo/fizz/buzz.ts b/tests/specs/run/workspaces/member_outside_root_dir/sub_dir/child/foo/fizz/buzz.ts index 4e03777d1..4e03777d1 100644 --- a/tests/specs/run/workspaces/member_outside_root_dir/foo/fizz/buzz.ts +++ b/tests/specs/run/workspaces/member_outside_root_dir/sub_dir/child/foo/fizz/buzz.ts diff --git a/tests/specs/run/workspaces/member_outside_root_dir/foo/mod.ts b/tests/specs/run/workspaces/member_outside_root_dir/sub_dir/child/foo/mod.ts index d7b16dcc0..d7b16dcc0 100644 --- a/tests/specs/run/workspaces/member_outside_root_dir/foo/mod.ts +++ b/tests/specs/run/workspaces/member_outside_root_dir/sub_dir/child/foo/mod.ts diff --git a/tests/specs/run/workspaces/member_outside_root_dir/main.ts b/tests/specs/run/workspaces/member_outside_root_dir/sub_dir/child/main.ts index 182fd8517..182fd8517 100644 --- a/tests/specs/run/workspaces/member_outside_root_dir/main.ts +++ b/tests/specs/run/workspaces/member_outside_root_dir/sub_dir/child/main.ts diff --git a/tests/specs/run/workspaces/members_are_imports/deno.json b/tests/specs/run/workspaces/members_are_imports/deno.json index 56105365a..51d1d21de 100644 --- a/tests/specs/run/workspaces/members_are_imports/deno.json +++ b/tests/specs/run/workspaces/members_are_imports/deno.json @@ -1,5 +1,5 @@ { - "workspaces": [ + "workspace": [ "foo", "bar" ], diff --git a/tests/specs/run/workspaces/nested_member/__test__.jsonc b/tests/specs/run/workspaces/nested_member/__test__.jsonc index a7669c1ec..fe02eacbc 100644 --- a/tests/specs/run/workspaces/nested_member/__test__.jsonc +++ b/tests/specs/run/workspaces/nested_member/__test__.jsonc @@ -2,5 +2,5 @@ "args": "run -A main.ts", "output": "main.out", "tempDir": true, - "exitCode": 1 + "exitCode": 0 } diff --git a/tests/specs/run/workspaces/nested_member/bar/deno.json b/tests/specs/run/workspaces/nested_member/bar/deno.json index ef3bfc37a..3bc0e52ec 100644 --- a/tests/specs/run/workspaces/nested_member/bar/deno.json +++ b/tests/specs/run/workspaces/nested_member/bar/deno.json @@ -4,5 +4,6 @@ "imports": { "@/": "./", "secret_mod/": "./some_mod/" - } + }, + "exports": "./mod.ts" } diff --git a/tests/specs/run/workspaces/nested_member/deno.json b/tests/specs/run/workspaces/nested_member/deno.json index 6d9c09d4d..8108d54fc 100644 --- a/tests/specs/run/workspaces/nested_member/deno.json +++ b/tests/specs/run/workspaces/nested_member/deno.json @@ -1,5 +1,5 @@ { - "workspaces": [ + "workspace": [ "foo", "foo/bar" ] diff --git a/tests/specs/run/workspaces/nested_member/foo/bar/deno.json b/tests/specs/run/workspaces/nested_member/foo/bar/deno.json index d40328b36..d4948ddbb 100644 --- a/tests/specs/run/workspaces/nested_member/foo/bar/deno.json +++ b/tests/specs/run/workspaces/nested_member/foo/bar/deno.json @@ -3,5 +3,6 @@ "version": "0.0.0", "imports": { "chalk": "npm:chalk" - } + }, + "exports": "./hello.ts" } diff --git a/tests/specs/run/workspaces/nested_member/foo/deno.json b/tests/specs/run/workspaces/nested_member/foo/deno.json index 68e053b02..6bc959c4d 100644 --- a/tests/specs/run/workspaces/nested_member/foo/deno.json +++ b/tests/specs/run/workspaces/nested_member/foo/deno.json @@ -3,5 +3,6 @@ "version": "0.0.0", "imports": { "~/": "./" - } + }, + "exports": "./mod.ts" } diff --git a/tests/specs/run/workspaces/nested_member/main.out b/tests/specs/run/workspaces/nested_member/main.out index 98598a306..ec46186a7 100644 --- a/tests/specs/run/workspaces/nested_member/main.out +++ b/tests/specs/run/workspaces/nested_member/main.out @@ -1 +1,4 @@ -error: Workspace member 'foo/bar' is nested within other workspace member 'foo' +Download http://localhost:4260/chalk +Download http://localhost:4260/chalk/chalk-5.0.1.tgz +buzz from foo +[Function: chalk] createChalk { level: 0 } diff --git a/tests/specs/task/workspace/__test__.jsonc b/tests/specs/task/workspace/__test__.jsonc new file mode 100644 index 000000000..b08f35afc --- /dev/null +++ b/tests/specs/task/workspace/__test__.jsonc @@ -0,0 +1,52 @@ +{ + "tests": { + "root": { + "args": "task", + "output": "root.out", + "exitCode": 1 + }, + "package_a": { + "args": "task", + "cwd": "package-a", + "output": "package-a.out", + "exitCode": 1 + }, + "package_b": { + "args": "task", + "cwd": "package-b", + "output": "package-b.out", + "exitCode": 1 + }, + "scripts": { + "args": "task", + "cwd": "scripts", + "output": "scripts.out", + "exitCode": 1 + }, + "package_b_tasks": { + "steps": [{ + "args": "task --quiet pkg-json-root", + "cwd": "package-b", + // uses the workspace as cwd + "output": "pkg-json [WILDLINE]workspace\n" + }, { + "args": "task --quiet pkg-json-root-2", + "cwd": "package-b", + // uses package-b as cwd + "output": "override [WILDLINE]package-b\n" + }, { + "args": "task --quiet echo-package-b", + "cwd": "package-b", + "output": "hi [WILDLINE]package-b\n" + }, { + "args": "task --quiet echo-root", + "cwd": "package-b", + "output": "override root [WILDLINE]package-b\n" + }, { + "args": "task --quiet echo-root", + "cwd": "package-a", + "output": "[WILDLINE]workspace\n" + }] + } + } +} diff --git a/tests/specs/task/workspace/deno.json b/tests/specs/task/workspace/deno.json new file mode 100644 index 000000000..aead0490e --- /dev/null +++ b/tests/specs/task/workspace/deno.json @@ -0,0 +1,9 @@ +{ + "workspace": [ + "./package-a", + "./package-b" + ], + "tasks": { + "echo-root": "echo $PWD" + } +} diff --git a/tests/specs/task/workspace/package-a.out b/tests/specs/task/workspace/package-a.out new file mode 100644 index 000000000..f68d5d24b --- /dev/null +++ b/tests/specs/task/workspace/package-a.out @@ -0,0 +1,9 @@ +Available tasks: +- echo-package-b + echo 'bye' +- pkg-json-root (workspace package.json) + echo pkg-json $PWD +- pkg-json-root-2 (workspace package.json) + echo hi +- echo-root (workspace) + echo $PWD diff --git a/tests/specs/task/workspace/package-a/deno.json b/tests/specs/task/workspace/package-a/deno.json new file mode 100644 index 000000000..5167ad857 --- /dev/null +++ b/tests/specs/task/workspace/package-a/deno.json @@ -0,0 +1,5 @@ +{ + "tasks": { + "echo-package-b": "echo 'bye'" + } +} diff --git a/tests/specs/task/workspace/package-b.out b/tests/specs/task/workspace/package-b.out new file mode 100644 index 000000000..4abd90d23 --- /dev/null +++ b/tests/specs/task/workspace/package-b.out @@ -0,0 +1,11 @@ +Available tasks: +- echo-package-b + echo 'hi' $PWD +- echo-root + echo 'override root' $PWD +- pkg-json-root-2 (package.json) + echo override $PWD +- package-b-json (package.json) + echo 'hi from pkg json' +- pkg-json-root (workspace package.json) + echo pkg-json $PWD diff --git a/tests/specs/task/workspace/package-b/deno.json b/tests/specs/task/workspace/package-b/deno.json new file mode 100644 index 000000000..0c6420834 --- /dev/null +++ b/tests/specs/task/workspace/package-b/deno.json @@ -0,0 +1,6 @@ +{ + "tasks": { + "echo-package-b": "echo 'hi' $PWD", + "echo-root": "echo 'override root' $PWD" + } +} diff --git a/tests/specs/task/workspace/package-b/package.json b/tests/specs/task/workspace/package-b/package.json new file mode 100644 index 000000000..bc1bdc712 --- /dev/null +++ b/tests/specs/task/workspace/package-b/package.json @@ -0,0 +1,6 @@ +{ + "scripts": { + "pkg-json-root-2": "echo override $PWD", + "package-b-json": "echo 'hi from pkg json'" + } +} diff --git a/tests/specs/task/workspace/package.json b/tests/specs/task/workspace/package.json new file mode 100644 index 000000000..a468ec494 --- /dev/null +++ b/tests/specs/task/workspace/package.json @@ -0,0 +1,6 @@ +{ + "scripts": { + "pkg-json-root": "echo pkg-json $PWD", + "pkg-json-root-2": "echo hi" + } +} diff --git a/tests/specs/task/workspace/root.out b/tests/specs/task/workspace/root.out new file mode 100644 index 000000000..808106c92 --- /dev/null +++ b/tests/specs/task/workspace/root.out @@ -0,0 +1,7 @@ +Available tasks: +- echo-root + echo $PWD +- pkg-json-root (package.json) + echo pkg-json $PWD +- pkg-json-root-2 (package.json) + echo hi diff --git a/tests/specs/task/workspace/scripts.out b/tests/specs/task/workspace/scripts.out new file mode 100644 index 000000000..808106c92 --- /dev/null +++ b/tests/specs/task/workspace/scripts.out @@ -0,0 +1,7 @@ +Available tasks: +- echo-root + echo $PWD +- pkg-json-root (package.json) + echo pkg-json $PWD +- pkg-json-root-2 (package.json) + echo hi diff --git a/tests/specs/task/workspace/scripts/main.ts b/tests/specs/task/workspace/scripts/main.ts new file mode 100644 index 000000000..9c11c78bb --- /dev/null +++ b/tests/specs/task/workspace/scripts/main.ts @@ -0,0 +1 @@ +console.log("some file"); diff --git a/tests/specs/test/workspace/__test__.jsonc b/tests/specs/test/workspace/__test__.jsonc new file mode 100644 index 000000000..87fd3d46d --- /dev/null +++ b/tests/specs/test/workspace/__test__.jsonc @@ -0,0 +1,20 @@ +{ + "tests": { + "root": { + "args": "test", + "output": "root.out", + "exitCode": 1 + }, + "package_a": { + "args": "test", + "cwd": "package-a", + "output": "package_a.out" + }, + "package_b": { + "args": "test", + "cwd": "package-b", + "output": "package_b.out", + "exitCode": 1 + } + } +} diff --git a/tests/specs/test/workspace/deno.json b/tests/specs/test/workspace/deno.json new file mode 100644 index 000000000..b72d88442 --- /dev/null +++ b/tests/specs/test/workspace/deno.json @@ -0,0 +1,6 @@ +{ + "workspace": [ + "./package-a", + "./package-b" + ] +} diff --git a/tests/specs/test/workspace/package-a/deno.json b/tests/specs/test/workspace/package-a/deno.json new file mode 100644 index 000000000..e6e03ae85 --- /dev/null +++ b/tests/specs/test/workspace/package-a/deno.json @@ -0,0 +1,5 @@ +{ + "name": "@scope/a", + "version": "1.0.0", + "exports": "./mod.ts" +} diff --git a/tests/specs/test/workspace/package-a/mod.test.ts b/tests/specs/test/workspace/package-a/mod.test.ts new file mode 100644 index 000000000..7ef57fbee --- /dev/null +++ b/tests/specs/test/workspace/package-a/mod.test.ts @@ -0,0 +1,7 @@ +import { add } from "./mod.ts"; + +Deno.test("add", () => { + if (add(1, 2) !== 3) { + throw new Error("failed"); + } +}); diff --git a/tests/specs/test/workspace/package-a/mod.ts b/tests/specs/test/workspace/package-a/mod.ts new file mode 100644 index 000000000..8d9b8a22a --- /dev/null +++ b/tests/specs/test/workspace/package-a/mod.ts @@ -0,0 +1,3 @@ +export function add(a: number, b: number): number { + return a + b; +} diff --git a/tests/specs/test/workspace/package-b/deno.json b/tests/specs/test/workspace/package-b/deno.json new file mode 100644 index 000000000..f131c191b --- /dev/null +++ b/tests/specs/test/workspace/package-b/deno.json @@ -0,0 +1,5 @@ +{ + "name": "@scope/b", + "version": "1.0.0", + "exports": "./mod.ts" +} diff --git a/tests/specs/test/workspace/package-b/mod.test.ts b/tests/specs/test/workspace/package-b/mod.test.ts new file mode 100644 index 000000000..f1499a626 --- /dev/null +++ b/tests/specs/test/workspace/package-b/mod.test.ts @@ -0,0 +1,11 @@ +import { addOne } from "./mod.ts"; + +Deno.test("addOne", () => { + if (addOne(1) !== 2) { + throw new Error("failed"); + } +}); + +Deno.test("fail", () => { + throw new Error("failed"); +}); diff --git a/tests/specs/test/workspace/package-b/mod.ts b/tests/specs/test/workspace/package-b/mod.ts new file mode 100644 index 000000000..53148ac2f --- /dev/null +++ b/tests/specs/test/workspace/package-b/mod.ts @@ -0,0 +1,5 @@ +import { add } from "@scope/a"; + +export function addOne(a: number): number { + return add(a, 1); +} diff --git a/tests/specs/test/workspace/package_a.out b/tests/specs/test/workspace/package_a.out new file mode 100644 index 000000000..6ebcdfb10 --- /dev/null +++ b/tests/specs/test/workspace/package_a.out @@ -0,0 +1,6 @@ +Check file:///[WILDLINE]/package-a/mod.test.ts +running 1 test from ./mod.test.ts +add ... ok ([WILDLINE]) + +ok | 1 passed | 0 failed ([WILDLINE]) + diff --git a/tests/specs/test/workspace/package_b.out b/tests/specs/test/workspace/package_b.out new file mode 100644 index 000000000..6c13427ee --- /dev/null +++ b/tests/specs/test/workspace/package_b.out @@ -0,0 +1,20 @@ +Check file:///[WILDLINE]/package-b/mod.test.ts +running 2 tests from ./mod.test.ts +addOne ... ok ([WILDLINE]) +fail ... FAILED ([WILDLINE]) + + ERRORS + +fail => ./mod.test.ts:9:6 +error: Error: failed + throw new Error("failed"); + ^ + at file:///[WILDLINE]/package-b/mod.test.ts:10:9 + + FAILURES + +fail => ./mod.test.ts:9:6 + +FAILED | 1 passed | 1 failed ([WILDLINE]) + +error: Test failed diff --git a/tests/specs/test/workspace/root.out b/tests/specs/test/workspace/root.out new file mode 100644 index 000000000..30bda3ac6 --- /dev/null +++ b/tests/specs/test/workspace/root.out @@ -0,0 +1,23 @@ +Check file:///[WILDLINE]/package-a/mod.test.ts +Check file:///[WILDLINE]/package-b/mod.test.ts +running 1 test from ./package-a/mod.test.ts +add ... ok ([WILDLINE]) +running 2 tests from ./package-b/mod.test.ts +addOne ... ok ([WILDLINE]) +fail ... FAILED ([WILDLINE]) + + ERRORS + +fail => ./package-b/mod.test.ts:9:6 +error: Error: failed + throw new Error("failed"); + ^ + at file:///[WILDLINE]/package-b/mod.test.ts:10:9 + + FAILURES + +fail => ./package-b/mod.test.ts:9:6 + +FAILED | 2 passed | 1 failed ([WILDLINE]) + +error: Test failed diff --git a/tests/specs/workspaces/lockfile/__test__.jsonc b/tests/specs/workspaces/lockfile/__test__.jsonc new file mode 100644 index 000000000..706b44f01 --- /dev/null +++ b/tests/specs/workspaces/lockfile/__test__.jsonc @@ -0,0 +1,24 @@ +{ + "tempDir": true, + "steps": [{ + "cwd": "pkg", + "args": "test", + "output": "test_pkg.out" + }, { + // the lockfile should always go to the workspace root + "args": [ + "eval", + "try { Deno.readTextFileSync('pkg/deno.lock'); console.log('should not run'); } catch {} console.log(Deno.readTextFileSync('deno.lock'))" + ], + "output": "expected-lock.out" + }, { + "args": "test", + "output": "test_root.out" + }, { + "args": [ + "eval", + "try { Deno.readTextFileSync('pkg/deno.lock'); console.log('should not run'); } catch {} console.log(Deno.readTextFileSync('deno.lock'))" + ], + "output": "expected-lock.out" + }] +} diff --git a/tests/specs/workspaces/lockfile/deno.json b/tests/specs/workspaces/lockfile/deno.json new file mode 100644 index 000000000..79c36f622 --- /dev/null +++ b/tests/specs/workspaces/lockfile/deno.json @@ -0,0 +1,6 @@ +{ + "workspace": [ + "./pkg", + "./pkg-no-deps" + ] +} diff --git a/tests/specs/workspaces/lockfile/expected-lock.out b/tests/specs/workspaces/lockfile/expected-lock.out new file mode 100644 index 000000000..dcc479a20 --- /dev/null +++ b/tests/specs/workspaces/lockfile/expected-lock.out @@ -0,0 +1,24 @@ +{ + "version": "3", + "packages": { + "specifiers": { + "jsr:@denotest/add@1": "jsr:@denotest/add@1.0.0" + }, + "jsr": { + "@denotest/add@1.0.0": { + "integrity": "3b2e675c1ad7fba2a45bc251992e01aff08a3c974ac09079b11e6a5b95d4bfcb" + } + } + }, + "remote": {}, + "workspace": { + "members": { + "pkg": { + "dependencies": [ + "jsr:@denotest/add@1" + ] + } + } + } +} + diff --git a/tests/specs/workspaces/lockfile/integration.test.ts b/tests/specs/workspaces/lockfile/integration.test.ts new file mode 100644 index 000000000..91e921b33 --- /dev/null +++ b/tests/specs/workspaces/lockfile/integration.test.ts @@ -0,0 +1,7 @@ +import { add } from "@scope/pkg"; + +Deno.test("should add", () => { + if (add(1, 2) !== 3) { + throw new Error("failed"); + } +}); diff --git a/tests/specs/workspaces/lockfile/pkg-no-deps/deno.jsonc b/tests/specs/workspaces/lockfile/pkg-no-deps/deno.jsonc new file mode 100644 index 000000000..123cc3b9a --- /dev/null +++ b/tests/specs/workspaces/lockfile/pkg-no-deps/deno.jsonc @@ -0,0 +1,7 @@ +{ + // this package shouldn't be included in the lockfile members + // because it has no dependencies + "name": "@scope/pkg2", + "version": "1.0.0", + "exports": "./mod.ts" +} diff --git a/tests/specs/workspaces/lockfile/pkg-no-deps/mod.ts b/tests/specs/workspaces/lockfile/pkg-no-deps/mod.ts new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/specs/workspaces/lockfile/pkg-no-deps/mod.ts diff --git a/tests/specs/workspaces/lockfile/pkg/deno.jsonc b/tests/specs/workspaces/lockfile/pkg/deno.jsonc new file mode 100644 index 000000000..7bd6ab450 --- /dev/null +++ b/tests/specs/workspaces/lockfile/pkg/deno.jsonc @@ -0,0 +1,8 @@ +{ + "name": "@scope/pkg", + "version": "1.0.0", + "exports": "./mod.ts", + "imports": { + "@denotest/add": "jsr:@denotest/add@1" + } +} diff --git a/tests/specs/workspaces/lockfile/pkg/mod.test.ts b/tests/specs/workspaces/lockfile/pkg/mod.test.ts new file mode 100644 index 000000000..9e7a8c445 --- /dev/null +++ b/tests/specs/workspaces/lockfile/pkg/mod.test.ts @@ -0,0 +1,7 @@ +import { add } from "./mod.ts"; + +Deno.test("should add", () => { + if (add(1, 2) !== 3) { + throw new Error("failed"); + } +}); diff --git a/tests/specs/workspaces/lockfile/pkg/mod.ts b/tests/specs/workspaces/lockfile/pkg/mod.ts new file mode 100644 index 000000000..f69572b49 --- /dev/null +++ b/tests/specs/workspaces/lockfile/pkg/mod.ts @@ -0,0 +1,5 @@ +import * as denotestAdd from "@denotest/add"; + +export function add(a: number, b: number) { + return denotestAdd.add(a, b); +} diff --git a/tests/specs/workspaces/lockfile/test_pkg.out b/tests/specs/workspaces/lockfile/test_pkg.out new file mode 100644 index 000000000..da13b7cca --- /dev/null +++ b/tests/specs/workspaces/lockfile/test_pkg.out @@ -0,0 +1,9 @@ +Download http://127.0.0.1:4250/@denotest/add/meta.json +Download http://127.0.0.1:4250/@denotest/add/1.0.0_meta.json +Download http://127.0.0.1:4250/@denotest/add/1.0.0/mod.ts +Check file:///[WILDLINE]/mod.test.ts +running 1 test from ./mod.test.ts +should add ... ok ([WILDLINE]) + +ok | 1 passed | 0 failed ([WILDLINE]) + diff --git a/tests/specs/workspaces/lockfile/test_root.out b/tests/specs/workspaces/lockfile/test_root.out new file mode 100644 index 000000000..2c62b615b --- /dev/null +++ b/tests/specs/workspaces/lockfile/test_root.out @@ -0,0 +1,9 @@ +Check file:///[WILDLINE]/integration.test.ts +Check file:///[WILDLINE]/pkg/mod.test.ts +running 1 test from ./integration.test.ts +should add ... ok ([WILDLINE]) +running 1 test from ./pkg/mod.test.ts +should add ... ok ([WILDLINE]) + +ok | 2 passed | 0 failed ([WILDLINE]) + diff --git a/tests/specs/workspaces/non_fatal_diagnostics/__test__.jsonc b/tests/specs/workspaces/non_fatal_diagnostics/__test__.jsonc new file mode 100644 index 000000000..ab79054b8 --- /dev/null +++ b/tests/specs/workspaces/non_fatal_diagnostics/__test__.jsonc @@ -0,0 +1,13 @@ +{ + "tests": { + "root": { + "args": "lint", + "output": "lint.out" + }, + "subdir": { + "cwd": "sub", + "args": "lint", + "output": "lint.out" + } + } +} diff --git a/tests/specs/workspaces/non_fatal_diagnostics/deno.json b/tests/specs/workspaces/non_fatal_diagnostics/deno.json new file mode 100644 index 000000000..983a9a3e9 --- /dev/null +++ b/tests/specs/workspaces/non_fatal_diagnostics/deno.json @@ -0,0 +1,5 @@ +{ + "workspace": [ + "./sub" + ] +} diff --git a/tests/specs/workspaces/non_fatal_diagnostics/lint.out b/tests/specs/workspaces/non_fatal_diagnostics/lint.out new file mode 100644 index 000000000..28ac6b0eb --- /dev/null +++ b/tests/specs/workspaces/non_fatal_diagnostics/lint.out @@ -0,0 +1,5 @@ +The 'compilerOptions' field can only be specified in the root workspace deno.json file. + at file:///[WILDLINE]/sub/deno.json +The 'lint.report' field can only be specified in the root workspace deno.json file. + at file:///[WILDLINE]/sub/deno.json +Checked 1 file diff --git a/tests/specs/workspaces/non_fatal_diagnostics/sub/deno.json b/tests/specs/workspaces/non_fatal_diagnostics/sub/deno.json new file mode 100644 index 000000000..0a21df89f --- /dev/null +++ b/tests/specs/workspaces/non_fatal_diagnostics/sub/deno.json @@ -0,0 +1,8 @@ +{ + "lint": { + "report": "compact" + }, + "compilerOptions": { + "strict": true + } +} diff --git a/tests/specs/workspaces/non_fatal_diagnostics/sub/main.ts b/tests/specs/workspaces/non_fatal_diagnostics/sub/main.ts new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/specs/workspaces/non_fatal_diagnostics/sub/main.ts diff --git a/tests/specs/workspaces/vendor/__test__.jsonc b/tests/specs/workspaces/vendor/__test__.jsonc new file mode 100644 index 000000000..cd44b361b --- /dev/null +++ b/tests/specs/workspaces/vendor/__test__.jsonc @@ -0,0 +1,13 @@ +{ + "tempDir": true, + "steps": [{ + "args": "run --quiet package-a/mod.ts", + "output": "3\n" + }, { + "args": "run --allow-write=. --allow-read=. modify_vendor.ts", + "output": "[WILDLINE]" + }, { + "args": "run --quiet package-a/mod.ts", + "output": "4\n" + }] +} diff --git a/tests/specs/workspaces/vendor/deno.json b/tests/specs/workspaces/vendor/deno.json new file mode 100644 index 000000000..62bf7dff9 --- /dev/null +++ b/tests/specs/workspaces/vendor/deno.json @@ -0,0 +1,9 @@ +{ + "vendor": true, + "workspace": [ + "package-a" + ], + "imports": { + "@denotest/add": "jsr:@denotest/add" + } +} diff --git a/tests/specs/workspaces/vendor/modify_vendor.ts b/tests/specs/workspaces/vendor/modify_vendor.ts new file mode 100644 index 000000000..3b6dafe14 --- /dev/null +++ b/tests/specs/workspaces/vendor/modify_vendor.ts @@ -0,0 +1,7 @@ +Deno.writeTextFileSync( + "./vendor/http_127.0.0.1_4250/@denotest/add/1.0.0/mod.ts", + `export function add(a: number, b: number): number { + return a + b + 1; // evil add +} +`, +); diff --git a/tests/specs/workspaces/vendor/package-a/deno.json b/tests/specs/workspaces/vendor/package-a/deno.json new file mode 100644 index 000000000..fe4300ad6 --- /dev/null +++ b/tests/specs/workspaces/vendor/package-a/deno.json @@ -0,0 +1,5 @@ +{ + "name": "@scope/pkg", + "version": "1.0.0", + "exports": "./mod.ts" +} diff --git a/tests/specs/workspaces/vendor/package-a/mod.ts b/tests/specs/workspaces/vendor/package-a/mod.ts new file mode 100644 index 000000000..1ca631410 --- /dev/null +++ b/tests/specs/workspaces/vendor/package-a/mod.ts @@ -0,0 +1,3 @@ +import { add } from "@denotest/add"; + +console.log(add(1, 2)); diff --git a/tests/testdata/compile/dynamic_imports/main_unanalyzable.ts b/tests/testdata/compile/dynamic_imports/main_unanalyzable.ts index d87d917c2..34fb76dc4 100644 --- a/tests/testdata/compile/dynamic_imports/main_unanalyzable.ts +++ b/tests/testdata/compile/dynamic_imports/main_unanalyzable.ts @@ -14,5 +14,7 @@ const IMPORT_PATH_FILE_PATH = join( setTimeout(async () => { console.log("Dynamic importing"); const importPath = (await Deno.readTextFile(IMPORT_PATH_FILE_PATH)).trim(); - import(importPath).then(() => console.log("Dynamic import done.")); + import(import.meta.resolve(importPath)).then(() => + console.log("Dynamic import done.") + ); }, 0); diff --git a/tests/testdata/compile/node_modules_symlink_outside/main_compile_file.out b/tests/testdata/compile/node_modules_symlink_outside/main_compile_file.out index 1154c3256..e5b39a752 100644 --- a/tests/testdata/compile/node_modules_symlink_outside/main_compile_file.out +++ b/tests/testdata/compile/node_modules_symlink_outside/main_compile_file.out @@ -1,2 +1,2 @@ Compile file:///[WILDCARD]/node_modules_symlink_outside/main.ts to [WILDCARD] -Warning Symlink target is outside '[WILDCARD]node_modules_symlink_outside[WILDCARD]node_modules'. Inlining symlink at '[WILDCARD]node_modules_symlink_outside[WILDCARD]node_modules[WILDCARD]test.txt' to '[WILDCARD]node_modules_symlink_outside[WILDCARD]test.txt' as file. +Warning Symlink target is outside '[WILDCARD]compile'. Inlining symlink at '[WILDCARD]node_modules_symlink_outside[WILDCARD]node_modules[WILDCARD]test.txt' to '[WILDCARD]target.txt' as file. diff --git a/tests/testdata/compile/node_modules_symlink_outside/main_compile_folder.out b/tests/testdata/compile/node_modules_symlink_outside/main_compile_folder.out index 83db2ef40..2067bf1c6 100644 --- a/tests/testdata/compile/node_modules_symlink_outside/main_compile_folder.out +++ b/tests/testdata/compile/node_modules_symlink_outside/main_compile_folder.out @@ -2,5 +2,5 @@ Download http://localhost:4260/@denotest/esm-basic Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz Initialize @denotest/esm-basic@1.0.0 Check file:///[WILDCARD]/node_modules_symlink_outside/main.ts -Compile file:///[WILDCARD]/node_modules_symlink_outside/main.ts to [WILDCARD] -Warning Symlink target is outside '[WILDCARD]node_modules_symlink_outside[WILDCARD]node_modules'. Excluding symlink at '[WILDCARD]node_modules_symlink_outside[WILDCARD]node_modules[WILDCARD]some_folder' with target '[WILDCARD]node_modules_symlink_outside[WILDCARD]some_folder'. +Compile file:///[WILDCARD]/node_modules_symlink_outside/main.ts to [WILDLINE] +Warning Symlink target is outside '[WILDLINE]compile'. Excluding symlink at '[WILDLINE]node_modules_symlink_outside[WILDLINE]node_modules[WILDLINE]symlink_dir' with target '[WILDLINE]some_folder'. diff --git a/tests/testdata/package_json/invalid_value/error.ts.out b/tests/testdata/package_json/invalid_value/error.ts.out index 2fd0940fe..80893ede0 100644 --- a/tests/testdata/package_json/invalid_value/error.ts.out +++ b/tests/testdata/package_json/invalid_value/error.ts.out @@ -1,6 +1,4 @@ -error: Parsing version constraints in the application-level package.json is more strict at the moment. - -Invalid npm version requirement. Unexpected character. +error: Invalid npm version requirement. Unexpected character. invalid stuff that won't parse ~ at file:///[WILDCARD]/error.ts:2:23 diff --git a/tests/testdata/package_json/invalid_value/task.out b/tests/testdata/package_json/invalid_value/task.out index dd4a04b0d..79249d175 100644 --- a/tests/testdata/package_json/invalid_value/task.out +++ b/tests/testdata/package_json/invalid_value/task.out @@ -1,5 +1,2 @@ -Warning Ignoring dependency '@denotest/cjs-default-export' in package.json because its version requirement failed to parse: Invalid npm version requirement. Unexpected character. - invalid stuff that won't parse - ~ Task test echo 1 1 diff --git a/tests/testdata/run/with_package_json/with_stop/main.out b/tests/testdata/run/with_package_json/with_stop/main.out index b199faf8d..f5eb79ca6 100644 --- a/tests/testdata/run/with_package_json/with_stop/main.out +++ b/tests/testdata/run/with_package_json/with_stop/main.out @@ -1,5 +1,4 @@ [WILDCARD]Config file found at '[WILDCARD]with_package_json[WILDCARD]with_stop[WILDCARD]some[WILDCARD]nested[WILDCARD]deno.json' -[WILDCARD]No package.json file found [WILDCARD] error: Relative import path "chalk" not prefixed with / or ./ or ../ at file:///[WILDCARD]with_package_json/with_stop/some/nested/dir/main.ts:3:19 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 |