From f5e46c9bf2f50d66a953fa133161fc829cecff06 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Sat, 10 Feb 2024 13:22:13 -0700 Subject: chore: move cli/tests/ -> tests/ (#22369) This looks like a massive PR, but it's only a move from cli/tests -> tests, and updates of relative paths for files. This is the first step towards aggregate all of the integration test files under tests/, which will lead to a set of integration tests that can run without the CLI binary being built. While we could leave these tests under `cli`, it would require us to keep a more complex directory structure for the various test runners. In addition, we have a lot of complexity to ignore various test files in the `cli` project itself (cargo publish exclusion rules, autotests = false, etc). And finally, the `tests/` folder will eventually house the `test_ffi`, `test_napi` and other testing code, reducing the size of the root repo directory. For easier review, the extremely large and noisy "move" is in the first commit (with no changes -- just a move), while the remainder of the changes to actual files is in the second commit. --- tests/testdata/package_json/basic/fail_check.check.out | 4 ++++ tests/testdata/package_json/basic/fail_check.ts | 3 +++ tests/testdata/package_json/basic/lib.bench.out | 11 +++++++++++ tests/testdata/package_json/basic/lib.bench.ts | 7 +++++++ tests/testdata/package_json/basic/lib.test.out | 9 +++++++++ tests/testdata/package_json/basic/lib.test.ts | 7 +++++++ tests/testdata/package_json/basic/lib.ts | 9 +++++++++ tests/testdata/package_json/basic/main.cache.out | 3 +++ tests/testdata/package_json/basic/main.check.out | 4 ++++ tests/testdata/package_json/basic/main.info.out | 8 ++++++++ tests/testdata/package_json/basic/main.ts | 3 +++ tests/testdata/package_json/basic/package.json | 5 +++++ tests/testdata/package_json/deno_json/deno.json | 5 +++++ tests/testdata/package_json/deno_json/main.check.out | 11 +++++++++++ tests/testdata/package_json/deno_json/main.out | 2 ++ tests/testdata/package_json/deno_json/main.ts | 9 +++++++++ tests/testdata/package_json/deno_json/other.ts | 3 +++ tests/testdata/package_json/deno_json/package.json | 5 +++++ tests/testdata/package_json/invalid_value/error.ts | 4 ++++ tests/testdata/package_json/invalid_value/error.ts.out | 6 ++++++ tests/testdata/package_json/invalid_value/ok.ts | 4 ++++ tests/testdata/package_json/invalid_value/ok.ts.out | 4 ++++ tests/testdata/package_json/invalid_value/package.json | 9 +++++++++ tests/testdata/package_json/invalid_value/task.out | 5 +++++ 24 files changed, 140 insertions(+) create mode 100644 tests/testdata/package_json/basic/fail_check.check.out create mode 100644 tests/testdata/package_json/basic/fail_check.ts create mode 100644 tests/testdata/package_json/basic/lib.bench.out create mode 100644 tests/testdata/package_json/basic/lib.bench.ts create mode 100644 tests/testdata/package_json/basic/lib.test.out create mode 100644 tests/testdata/package_json/basic/lib.test.ts create mode 100644 tests/testdata/package_json/basic/lib.ts create mode 100644 tests/testdata/package_json/basic/main.cache.out create mode 100644 tests/testdata/package_json/basic/main.check.out create mode 100644 tests/testdata/package_json/basic/main.info.out create mode 100644 tests/testdata/package_json/basic/main.ts create mode 100644 tests/testdata/package_json/basic/package.json create mode 100644 tests/testdata/package_json/deno_json/deno.json create mode 100644 tests/testdata/package_json/deno_json/main.check.out create mode 100644 tests/testdata/package_json/deno_json/main.out create mode 100644 tests/testdata/package_json/deno_json/main.ts create mode 100644 tests/testdata/package_json/deno_json/other.ts create mode 100644 tests/testdata/package_json/deno_json/package.json create mode 100644 tests/testdata/package_json/invalid_value/error.ts create mode 100644 tests/testdata/package_json/invalid_value/error.ts.out create mode 100644 tests/testdata/package_json/invalid_value/ok.ts create mode 100644 tests/testdata/package_json/invalid_value/ok.ts.out create mode 100644 tests/testdata/package_json/invalid_value/package.json create mode 100644 tests/testdata/package_json/invalid_value/task.out (limited to 'tests/testdata/package_json') diff --git a/tests/testdata/package_json/basic/fail_check.check.out b/tests/testdata/package_json/basic/fail_check.check.out new file mode 100644 index 000000000..03997a051 --- /dev/null +++ b/tests/testdata/package_json/basic/fail_check.check.out @@ -0,0 +1,4 @@ +error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. +const _test: string = getValue(); + ~~~~~ + at file:///[WILDCARD]/fail_check.ts:3:7 diff --git a/tests/testdata/package_json/basic/fail_check.ts b/tests/testdata/package_json/basic/fail_check.ts new file mode 100644 index 000000000..cef10763d --- /dev/null +++ b/tests/testdata/package_json/basic/fail_check.ts @@ -0,0 +1,3 @@ +import { getValue } from "./lib.ts"; + +const _test: string = getValue(); diff --git a/tests/testdata/package_json/basic/lib.bench.out b/tests/testdata/package_json/basic/lib.bench.out new file mode 100644 index 000000000..fa9c5efc6 --- /dev/null +++ b/tests/testdata/package_json/basic/lib.bench.out @@ -0,0 +1,11 @@ +Download http://localhost:4545/npm/registry/@denotest/esm-basic +Download http://localhost:4545/npm/registry/@denotest/esm-basic/1.0.0.tgz +Initialize @denotest/esm-basic@1.0.0 +Check file:///[WILDCARD]/lib.bench.ts +cpu: [WILDCARD] +runtime: [WILDCARD] + +file:///[WILDCARD]/lib.bench.ts +[WILDCARD] +---------------------------------------------------------------- ----------------------------- +should add [WILDCARD] diff --git a/tests/testdata/package_json/basic/lib.bench.ts b/tests/testdata/package_json/basic/lib.bench.ts new file mode 100644 index 000000000..e6b79d025 --- /dev/null +++ b/tests/testdata/package_json/basic/lib.bench.ts @@ -0,0 +1,7 @@ +import { add } from "./lib.ts"; + +Deno.bench("should add", () => { + if (add(1, 2) !== 3) { + throw new Error("Fail"); + } +}); diff --git a/tests/testdata/package_json/basic/lib.test.out b/tests/testdata/package_json/basic/lib.test.out new file mode 100644 index 000000000..fa1cbb0f7 --- /dev/null +++ b/tests/testdata/package_json/basic/lib.test.out @@ -0,0 +1,9 @@ +Download http://localhost:4545/npm/registry/@denotest/esm-basic +Download http://localhost:4545/npm/registry/@denotest/esm-basic/1.0.0.tgz +Initialize @denotest/esm-basic@1.0.0 +Check file://[WILDCARD]/lib.test.ts +running 1 test from [WILDCARD]lib.test.ts +should add ... ok ([WILDCARD]) + +ok | 1 passed | 0 failed ([WILDCARD]) + diff --git a/tests/testdata/package_json/basic/lib.test.ts b/tests/testdata/package_json/basic/lib.test.ts new file mode 100644 index 000000000..4e833e1f3 --- /dev/null +++ b/tests/testdata/package_json/basic/lib.test.ts @@ -0,0 +1,7 @@ +import { add } from "./lib.ts"; + +Deno.test("should add", () => { + if (add(1, 2) !== 3) { + throw new Error("Fail"); + } +}); diff --git a/tests/testdata/package_json/basic/lib.ts b/tests/testdata/package_json/basic/lib.ts new file mode 100644 index 000000000..1deed81f7 --- /dev/null +++ b/tests/testdata/package_json/basic/lib.ts @@ -0,0 +1,9 @@ +import * as test from "@denotest/esm-basic"; + +export function add(a: number, b: number) { + return a + b; +} + +export function getValue() { + return test.getValue(); +} diff --git a/tests/testdata/package_json/basic/main.cache.out b/tests/testdata/package_json/basic/main.cache.out new file mode 100644 index 000000000..1c729e2a3 --- /dev/null +++ b/tests/testdata/package_json/basic/main.cache.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 +Initialize @denotest/esm-basic@1.0.0 diff --git a/tests/testdata/package_json/basic/main.check.out b/tests/testdata/package_json/basic/main.check.out new file mode 100644 index 000000000..a506cb0ed --- /dev/null +++ b/tests/testdata/package_json/basic/main.check.out @@ -0,0 +1,4 @@ +Download http://localhost:4545/npm/registry/@denotest/esm-basic +Download http://localhost:4545/npm/registry/@denotest/esm-basic/1.0.0.tgz +Initialize @denotest/esm-basic@1.0.0 +Check file://[WILDCARD]/main.ts diff --git a/tests/testdata/package_json/basic/main.info.out b/tests/testdata/package_json/basic/main.info.out new file mode 100644 index 000000000..892c0612a --- /dev/null +++ b/tests/testdata/package_json/basic/main.info.out @@ -0,0 +1,8 @@ +local: [WILDCARD]main.ts +type: TypeScript +dependencies: 2 unique +size: [WILDCARD] + +file:///[WILDCARD]/main.ts (63B) +└─┬ file:///[WILDCARD]/lib.ts (166B) + └── npm:/@denotest/esm-basic@1.0.0 (471B) diff --git a/tests/testdata/package_json/basic/main.ts b/tests/testdata/package_json/basic/main.ts new file mode 100644 index 000000000..e241f3002 --- /dev/null +++ b/tests/testdata/package_json/basic/main.ts @@ -0,0 +1,3 @@ +import { getValue } from "./lib.ts"; + +console.log(getValue()); diff --git a/tests/testdata/package_json/basic/package.json b/tests/testdata/package_json/basic/package.json new file mode 100644 index 000000000..54ca824d6 --- /dev/null +++ b/tests/testdata/package_json/basic/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@denotest/esm-basic": "*" + } +} diff --git a/tests/testdata/package_json/deno_json/deno.json b/tests/testdata/package_json/deno_json/deno.json new file mode 100644 index 000000000..8a89da280 --- /dev/null +++ b/tests/testdata/package_json/deno_json/deno.json @@ -0,0 +1,5 @@ +{ + "imports": { + "other": "./other.ts" + } +} diff --git a/tests/testdata/package_json/deno_json/main.check.out b/tests/testdata/package_json/deno_json/main.check.out new file mode 100644 index 000000000..53b6869c0 --- /dev/null +++ b/tests/testdata/package_json/deno_json/main.check.out @@ -0,0 +1,11 @@ +error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. +const _strValue1: string = NUMBER_VALUE; + ~~~~~~~~~~ + at file:///[WILDCARD]/main.ts:8:7 + +TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. +const _strValue2: string = test.getValue(); + ~~~~~~~~~~ + at file:///[WILDCARD]/main.ts:9:7 + +Found 2 errors. diff --git a/tests/testdata/package_json/deno_json/main.out b/tests/testdata/package_json/deno_json/main.out new file mode 100644 index 000000000..1191247b6 --- /dev/null +++ b/tests/testdata/package_json/deno_json/main.out @@ -0,0 +1,2 @@ +1 +2 diff --git a/tests/testdata/package_json/deno_json/main.ts b/tests/testdata/package_json/deno_json/main.ts new file mode 100644 index 000000000..7768ff3fc --- /dev/null +++ b/tests/testdata/package_json/deno_json/main.ts @@ -0,0 +1,9 @@ +import { NUMBER_VALUE } from "other"; +import * as test from "@denotest/esm-basic"; + +test.setValue(2); +console.log(test.getValue()); + +// these should cause type errors +const _strValue1: string = NUMBER_VALUE; +const _strValue2: string = test.getValue(); diff --git a/tests/testdata/package_json/deno_json/other.ts b/tests/testdata/package_json/deno_json/other.ts new file mode 100644 index 000000000..997d84adf --- /dev/null +++ b/tests/testdata/package_json/deno_json/other.ts @@ -0,0 +1,3 @@ +console.log(1); + +export const NUMBER_VALUE = 1; diff --git a/tests/testdata/package_json/deno_json/package.json b/tests/testdata/package_json/deno_json/package.json new file mode 100644 index 000000000..54ca824d6 --- /dev/null +++ b/tests/testdata/package_json/deno_json/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@denotest/esm-basic": "*" + } +} diff --git a/tests/testdata/package_json/invalid_value/error.ts b/tests/testdata/package_json/invalid_value/error.ts new file mode 100644 index 000000000..fd75d633c --- /dev/null +++ b/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/tests/testdata/package_json/invalid_value/error.ts.out b/tests/testdata/package_json/invalid_value/error.ts.out new file mode 100644 index 000000000..faa811a30 --- /dev/null +++ b/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 specifier 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/ok.ts b/tests/testdata/package_json/invalid_value/ok.ts new file mode 100644 index 000000000..ce517439f --- /dev/null +++ b/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/tests/testdata/package_json/invalid_value/ok.ts.out b/tests/testdata/package_json/invalid_value/ok.ts.out new file mode 100644 index 000000000..17d9bba00 --- /dev/null +++ b/tests/testdata/package_json/invalid_value/ok.ts.out @@ -0,0 +1,4 @@ +Download http://localhost:4545/npm/registry/@denotest/esm-basic +Download http://localhost:4545/npm/registry/@denotest/esm-basic/1.0.0.tgz +Initialize @denotest/esm-basic@1.0.0 +2 diff --git a/tests/testdata/package_json/invalid_value/package.json b/tests/testdata/package_json/invalid_value/package.json new file mode 100644 index 000000000..c8857649e --- /dev/null +++ b/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/tests/testdata/package_json/invalid_value/task.out b/tests/testdata/package_json/invalid_value/task.out new file mode 100644 index 000000000..28e3c770d --- /dev/null +++ b/tests/testdata/package_json/invalid_value/task.out @@ -0,0 +1,5 @@ +Warning Ignoring dependency '@denotest/cjs-default-export' in package.json because its version requirement failed to parse: Invalid specifier version requirement. Unexpected character. + invalid stuff that won't parse + ~ +Task test echo 1 +1 -- cgit v1.2.3