diff options
Diffstat (limited to 'tests/specs/run/patch')
-rw-r--r-- | tests/specs/run/patch/__test__.jsonc | 25 | ||||
-rw-r--r-- | tests/specs/run/patch/add/deno.json | 5 | ||||
-rw-r--r-- | tests/specs/run/patch/add/mod.test.ts | 9 | ||||
-rw-r--r-- | tests/specs/run/patch/add/mod.ts | 4 | ||||
-rw-r--r-- | tests/specs/run/patch/modify_version.ts | 3 | ||||
-rw-r--r-- | tests/specs/run/patch/my-pkg/deno.json | 11 | ||||
-rw-r--r-- | tests/specs/run/patch/my-pkg/mod.test.ts | 7 | ||||
-rw-r--r-- | tests/specs/run/patch/my-pkg/mod.ts | 2 | ||||
-rw-r--r-- | tests/specs/run/patch/not_matching_version.out | 11 | ||||
-rw-r--r-- | tests/specs/run/patch/test.out | 10 |
10 files changed, 87 insertions, 0 deletions
diff --git a/tests/specs/run/patch/__test__.jsonc b/tests/specs/run/patch/__test__.jsonc new file mode 100644 index 000000000..00ae3baac --- /dev/null +++ b/tests/specs/run/patch/__test__.jsonc @@ -0,0 +1,25 @@ +{ + "tempDir": true, + "tests": { + "matching_version": { + "cwd": "./my-pkg", + "steps": [{ + "args": "test", + "output": "test.out" + }, { + "args": "lint", + "output": "Checked 2 files\n" + }] + }, + "not_matching_version": { + "steps": [{ + "args": "run --allow-read=. --allow-write=. modify_version.ts", + "output": "[WILDCARD]" + }, { + "cwd": "./my-pkg", + "args": "test", + "output": "not_matching_version.out" + }] + } + } +} diff --git a/tests/specs/run/patch/add/deno.json b/tests/specs/run/patch/add/deno.json new file mode 100644 index 000000000..05d24d7b5 --- /dev/null +++ b/tests/specs/run/patch/add/deno.json @@ -0,0 +1,5 @@ +{ + "name": "@denotest/add", + "version": "1.0.0", + "exports": "./mod.ts" +} diff --git a/tests/specs/run/patch/add/mod.test.ts b/tests/specs/run/patch/add/mod.test.ts new file mode 100644 index 000000000..3d3804e07 --- /dev/null +++ b/tests/specs/run/patch/add/mod.test.ts @@ -0,0 +1,9 @@ +import { add } from "./mod.ts"; + +// this test should not be run or linted +Deno.test("add", () => { + let unusedVar = 5; // purposefully causing a lint error to ensure it's not linted + if (add(1, 2) !== 3) { + throw new Error("fail"); + } +}); diff --git a/tests/specs/run/patch/add/mod.ts b/tests/specs/run/patch/add/mod.ts new file mode 100644 index 000000000..97a779a44 --- /dev/null +++ b/tests/specs/run/patch/add/mod.ts @@ -0,0 +1,4 @@ +export function add(a: number, b: number): number { + console.log("adding", a, "and", b); + return a + b; +} diff --git a/tests/specs/run/patch/modify_version.ts b/tests/specs/run/patch/modify_version.ts new file mode 100644 index 000000000..3d59aa1b9 --- /dev/null +++ b/tests/specs/run/patch/modify_version.ts @@ -0,0 +1,3 @@ +const data = JSON.parse(Deno.readTextFileSync("./add/deno.json")); +data.version = "2.0.0"; +Deno.writeTextFileSync("./add/deno.json", JSON.stringify(data, null, 2)); diff --git a/tests/specs/run/patch/my-pkg/deno.json b/tests/specs/run/patch/my-pkg/deno.json new file mode 100644 index 000000000..0303c9974 --- /dev/null +++ b/tests/specs/run/patch/my-pkg/deno.json @@ -0,0 +1,11 @@ +{ + "name": "@scope/my-pkg", + "version": "1.0.0", + "exports": "./mod.ts", + "imports": { + "@denotest/add": "jsr:@denotest/add@1" + }, + "patch": [ + "../add" + ] +} diff --git a/tests/specs/run/patch/my-pkg/mod.test.ts b/tests/specs/run/patch/my-pkg/mod.test.ts new file mode 100644 index 000000000..1c694298c --- /dev/null +++ b/tests/specs/run/patch/my-pkg/mod.test.ts @@ -0,0 +1,7 @@ +import { add } from "./mod.ts"; + +Deno.test("add", () => { + if (add(1, 2) !== 3) { + throw new Error("fail"); + } +}); diff --git a/tests/specs/run/patch/my-pkg/mod.ts b/tests/specs/run/patch/my-pkg/mod.ts new file mode 100644 index 000000000..41389ed65 --- /dev/null +++ b/tests/specs/run/patch/my-pkg/mod.ts @@ -0,0 +1,2 @@ +export { add } from "@denotest/add"; +import "@denotest/add"; // ensure it only warns once diff --git a/tests/specs/run/patch/not_matching_version.out b/tests/specs/run/patch/not_matching_version.out new file mode 100644 index 000000000..7a9ee6f39 --- /dev/null +++ b/tests/specs/run/patch/not_matching_version.out @@ -0,0 +1,11 @@ +Warning Patch '@denotest/add@2.0.0' was not used because it did not match '@denotest/add@1' + at file:///[WILDLINE]/my-pkg/mod.ts:1:21 +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 +add ... ok ([WILDLINE]) + +ok | 1 passed | 0 failed ([WILDLINE]) + diff --git a/tests/specs/run/patch/test.out b/tests/specs/run/patch/test.out new file mode 100644 index 000000000..4eb9f3383 --- /dev/null +++ b/tests/specs/run/patch/test.out @@ -0,0 +1,10 @@ +Check file:///[WILDLINE]/mod.test.ts +running 1 test from ./mod.test.ts +add ... +------- output ------- +adding 1 and 2 +----- output end ----- +add ... ok ([WILDLINE]) + +ok | 1 passed | 0 failed ([WILDLINE]) + |