diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-03-03 18:27:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-03 18:27:05 -0400 |
commit | 84bafd11d52609e74a52df8e57752d5e3c25f717 (patch) | |
tree | cdc282ab3a808bc29987cdb45c0b462ae1e080ec /cli/tests | |
parent | 5c43e2a665c9dae7aff3ba757e589f10ec3aa062 (diff) |
fix: lazily surface errors in package.json deps parsing (#17974)
Closes #17941
Diffstat (limited to 'cli/tests')
7 files changed, 63 insertions, 0 deletions
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index b60efc94d..3b1f740b2 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -13,6 +13,7 @@ use trust_dns_client::serialize::txt::Lexer; use trust_dns_client::serialize::txt::Parser; use util::assert_contains; use util::env_vars_for_npm_tests_no_sync_download; +use util::TestContextBuilder; itest!(stdout_write_all { args: "run --quiet run/stdout_write_all.ts", @@ -2836,6 +2837,36 @@ itest!(package_json_with_deno_json { http_server: true, }); +#[test] +fn package_json_error_dep_value_test() { + let context = TestContextBuilder::for_npm() + .use_copy_temp_dir("package_json/invalid_value") + .cwd("package_json/invalid_value") + .build(); + + // should run fine when not referencing a failing dep entry + context + .new_command() + .args("run ok.ts") + .run() + .assert_matches_file("package_json/invalid_value/ok.ts.out"); + + // should fail when referencing a failing dep entry + context + .new_command() + .args("run error.ts") + .run() + .assert_exit_code(1) + .assert_matches_file("package_json/invalid_value/error.ts.out"); + + // should output a warning about the failing dep entry + context + .new_command() + .args("task test") + .run() + .assert_matches_file("package_json/invalid_value/task.out"); +} + itest!(wasm_streaming_panic_test { args: "run run/wasm_streaming_panic_test.js", output: "run/wasm_streaming_panic_test.js.out", diff --git a/cli/tests/testdata/package_json/invalid_value/error.ts b/cli/tests/testdata/package_json/invalid_value/error.ts new file mode 100644 index 000000000..fd75d633c --- /dev/null +++ b/cli/tests/testdata/package_json/invalid_value/error.ts @@ -0,0 +1,4 @@ +// the package.json will error when importing +import * as test from "@denotest/cjs-default-export"; + +console.log(test); diff --git a/cli/tests/testdata/package_json/invalid_value/error.ts.out b/cli/tests/testdata/package_json/invalid_value/error.ts.out new file mode 100644 index 000000000..866388e60 --- /dev/null +++ b/cli/tests/testdata/package_json/invalid_value/error.ts.out @@ -0,0 +1,6 @@ +error: Parsing version constraints in the application-level package.json is more strict at the moment. + +Invalid npm specifier version requirement. Unexpected character. + invalid stuff that won't parse + ~ + at file:///[WILDCARD]/error.ts:2:23 diff --git a/cli/tests/testdata/package_json/invalid_value/ok.ts b/cli/tests/testdata/package_json/invalid_value/ok.ts new file mode 100644 index 000000000..ce517439f --- /dev/null +++ b/cli/tests/testdata/package_json/invalid_value/ok.ts @@ -0,0 +1,4 @@ +import * as test from "@denotest/esm-basic"; + +test.setValue(2); +console.log(test.getValue()); diff --git a/cli/tests/testdata/package_json/invalid_value/ok.ts.out b/cli/tests/testdata/package_json/invalid_value/ok.ts.out new file mode 100644 index 000000000..3c7e2792f --- /dev/null +++ b/cli/tests/testdata/package_json/invalid_value/ok.ts.out @@ -0,0 +1,3 @@ +Download http://localhost:4545/npm/registry/@denotest/esm-basic +Download http://localhost:4545/npm/registry/@denotest/esm-basic/1.0.0.tgz +2 diff --git a/cli/tests/testdata/package_json/invalid_value/package.json b/cli/tests/testdata/package_json/invalid_value/package.json new file mode 100644 index 000000000..c8857649e --- /dev/null +++ b/cli/tests/testdata/package_json/invalid_value/package.json @@ -0,0 +1,9 @@ +{ + "scripts": { + "test": "echo 1" + }, + "dependencies": { + "@denotest/esm-basic": "*", + "@denotest/cjs-default-export": "invalid stuff that won't parse" + } +} diff --git a/cli/tests/testdata/package_json/invalid_value/task.out b/cli/tests/testdata/package_json/invalid_value/task.out new file mode 100644 index 000000000..914dc27c6 --- /dev/null +++ b/cli/tests/testdata/package_json/invalid_value/task.out @@ -0,0 +1,6 @@ +Warning Ignoring dependency '@denotest/cjs-default-export' in package.json because its version requirement failed to parse: Invalid npm specifier version requirement. Unexpected character. + invalid stuff that won't parse + ~ +Warning Currently only basic package.json `scripts` are supported. Programs like `rimraf` or `cross-env` will not work correctly. This will be fixed in the upcoming release. +Task test echo 1 +1 |