diff options
Diffstat (limited to 'tests/specs/workspaces')
21 files changed, 174 insertions, 0 deletions
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)); |