Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update codebase to work with Deno RC #6018

Merged
merged 12 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ Example code snippets must:
[documentation checker tool](../_tools/check_docs.ts) and are flagged when
they throw an error.

Note: To skip running a specific code snippet, add `no-eval` to the starting
Note: To skip running a specific code snippet, add `ignore` to the starting
delimiter. E.g.

````ts
/**
* ```ts no-eval
* ```ts ignore
* (code snippet will not be run)
* ```
*/
Expand Down
19 changes: 9 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ jobs:
run: |
deno task test
rm deno.lock # remove deno.lock (v4) as it's incompatible with v3
env:
DENO_FUTURE: 1

- name: Run timezone-dependent tests
run: |
Expand All @@ -55,15 +53,16 @@ jobs:
# - name: Type check browser compatible modules
# run: deno task test:browser

- name: Generate lcov
run: deno task cov:gen
# TODO(iuioiua): Enable this once https://github.com/denoland/deno/pull/25736 is merged
# - name: Generate lcov
# run: deno task cov:gen

- name: Upload coverage
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
name: ${{ matrix.os }}-${{ matrix.deno }}
# - name: Upload coverage
# uses: codecov/codecov-action@v4
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# with:
# name: ${{ matrix.os }}-${{ matrix.deno }}

test-node:
runs-on: ${{ matrix.os }}
Expand Down
60 changes: 1 addition & 59 deletions _tools/check_docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,55 +194,6 @@ function assertHasParamTag(
}
}

async function assertSnippetEvals(
{
snippet,
document,
expectError,
}: {
snippet: string;
document: { jsDoc: JsDoc; location: Location };
expectError: boolean;
},
) {
const command = new Deno.Command(Deno.execPath(), {
args: [
"eval",
"--ext=ts",
"--unstable-webgpu",
"--check",
"--no-lock",
snippet,
],
stderr: "piped",
});
const timeoutId = setTimeout(() => {
// deno-lint-ignore no-console
console.warn(
`Snippet at ${document.location.filename}:${document.location.line} has been running for more than 10 seconds...\n${snippet}`,
);
}, 10_000);
try {
const { success, stderr } = await command.output();
const error = new TextDecoder().decode(stderr);
if (expectError) {
assert(
!success,
`Snippet is expected to have errors, but executed successfully: \n${snippet}\n${error}`,
document,
);
} else {
assert(
success,
`Failed to execute snippet: \n${snippet}\n${error}`,
document,
);
}
} finally {
clearTimeout(timeoutId);
}
}

function assertSnippetsWork(
doc: string,
document: { jsDoc: JsDoc; location: Location },
Expand All @@ -264,24 +215,15 @@ function assertSnippetsWork(
}
for (let snippet of snippets) {
const delim = snippet.split(NEWLINE)[0];
if (delim?.includes("no-eval")) continue;
// Trim the code block delimiters
snippet = snippet.split(NEWLINE).slice(1, -1).join(NEWLINE);
if (!delim?.includes("no-assert")) {
if (!(delim?.includes("no-assert") || delim?.includes("ignore"))) {
assert(
snippet.match(ASSERTION_IMPORT) !== null,
"Snippet must contain assertion from '@std/assert'",
document,
);
}
snippetPromises.push(
() =>
assertSnippetEvals({
snippet,
document,
expectError: delim?.includes("expect-error") ?? false,
}),
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion archive/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* archive file, while untar is the inverse utility to extract the files from an
* archive. Files are not compressed, only collected into the archive.
*
* ```ts no-eval
* ```ts ignore
* import { Tar } from "@std/archive/tar";
* import { Buffer } from "@std/io/buffer";
* import { copy } from "@std/io/copy";
Expand Down
6 changes: 3 additions & 3 deletions archive/tar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export interface TarDataWithSource extends TarData {
* * Sparse files are not supported
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { Tar } from "@std/archive/tar";
* import { Buffer } from "@std/io/buffer";
* import { copy } from "@std/io/copy";
Expand Down Expand Up @@ -277,7 +277,7 @@ export class Tar {
* reference to the content itself and potentially any related metadata.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { Tar } from "@std/archive/tar";
* import { Buffer } from "@std/io/buffer";
* import { copy } from "@std/io/copy";
Expand Down Expand Up @@ -429,7 +429,7 @@ export class Tar {
* @returns A reader instance for the tar archive.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { Tar } from "@std/archive/tar";
* import { Buffer } from "@std/io/buffer";
* import { copy } from "@std/io/copy";
Expand Down
16 changes: 8 additions & 8 deletions archive/untar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function parseHeader(buffer: Uint8Array): TarHeader {
* @experimental **UNSTABLE**: New API, yet to be vetted.
*
* @example Usage
* ```ts no-assert
* ```ts ignore
* import { TarEntry } from "@std/archive/untar";
* import { Buffer } from "@std/io/buffer";
*
Expand Down Expand Up @@ -139,7 +139,7 @@ export interface TarEntry extends TarMetaWithLinkName {}
* @experimental **UNSTABLE**: New API, yet to be vetted.
*
* @example Usage
* ```ts no-assert
* ```ts ignore
* import { TarEntry } from "@std/archive/untar";
* import { Buffer } from "@std/io/buffer";
*
Expand Down Expand Up @@ -192,7 +192,7 @@ export class TarEntry implements Reader {
* @returns Whether the entry has already been consumed.
*
* @example Usage
* ```ts
* ```ts ignore
* import { TarEntry } from "@std/archive/untar";
* import { Buffer } from "@std/io/buffer";
* import { assertEquals } from "@std/assert/equals";
Expand Down Expand Up @@ -232,7 +232,7 @@ export class TarEntry implements Reader {
* there are no more bytes to read.
*
* @example Usage
* ```ts
* ```ts ignore
* import { Tar, Untar } from "@std/archive";
* import { assertEquals } from "@std/assert/equals";
* import { Buffer } from "@std/io/buffer";
Expand Down Expand Up @@ -288,7 +288,7 @@ export class TarEntry implements Reader {
* Discords the current entry.
*
* @example Usage
* ```ts
* ```ts ignore
* import { Buffer } from "@std/io/buffer";
* import { TarEntry } from "@std/archive/untar";
* import { assertEquals } from "@std/assert/equals";
Expand Down Expand Up @@ -356,7 +356,7 @@ export class TarEntry implements Reader {
* the files.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { Untar } from "@std/archive/untar";
* import { ensureFile } from "@std/fs/ensure-file";
* import { ensureDir } from "@std/fs/ensure-dir";
Expand Down Expand Up @@ -484,7 +484,7 @@ export class Untar {
* or null if there are no more entries to extract.
*
* @example Usage
* ```ts
* ```ts ignore
* import { Tar, Untar } from "@std/archive";
* import { Buffer } from "@std/io/buffer";
* import { readAll } from "@std/io/read-all";
Expand Down Expand Up @@ -534,7 +534,7 @@ export class Untar {
* @returns An async iterator.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { Untar } from "@std/archive/untar";
* import { ensureFile } from "@std/fs/ensure-file";
* import { ensureDir } from "@std/fs/ensure-dir";
Expand Down
2 changes: 1 addition & 1 deletion assert/almost_equals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { AssertionError } from "./assertion_error.ts";
* expected value.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { assertAlmostEquals } from "@std/assert";
*
* assertAlmostEquals(0.01, 0.02); // Throws
Expand Down
2 changes: 1 addition & 1 deletion assert/array_includes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type ArrayLikeArg<T> = ArrayLike<T> & object;
* same type.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { assertArrayIncludes } from "@std/assert";
*
* assertArrayIncludes([1, 2], [2]); // Doesn't throw
Expand Down
2 changes: 1 addition & 1 deletion assert/assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AssertionError } from "./assertion_error.ts";
* Make an assertion, error will be thrown if `expr` does not have truthy value.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { assert } from "@std/assert";
*
* assert("hello".includes("ello")); // Doesn't throw
Expand Down
2 changes: 1 addition & 1 deletion assert/assertion_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Error thrown when an assertion fails.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { AssertionError } from "@std/assert";
*
* try {
Expand Down
4 changes: 2 additions & 2 deletions assert/equal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ function constructorsEqual(a: object, b: object) {
}

/**
* Deep equality comparison used in assertions
* Deep equality comparison used in assertions.
*
* @param c The actual value
* @param d The expected value
* @returns `true` if the values are deeply equal, `false` otherwise
*
* @example Usage
* ```ts
* import { equal } from "@std/assert";
* import { equal } from "@std/assert/equal";
*
* equal({ foo: "bar" }, { foo: "bar" }); // Returns `true`
* equal({ foo: "bar" }, { foo: "baz" }); // Returns `false
Expand Down
2 changes: 1 addition & 1 deletion assert/equals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { AssertionError } from "./assertion_error.ts";
* same type.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { assertEquals } from "@std/assert";
*
* assertEquals("world", "world"); // Doesn't throw
Expand Down
2 changes: 1 addition & 1 deletion assert/exists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AssertionError } from "./assertion_error.ts";
* If not then throw.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { assertExists } from "@std/assert";
*
* assertExists("something"); // Doesn't throw
Expand Down
2 changes: 1 addition & 1 deletion assert/fail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AssertionError } from "./assertion_error.ts";
* Forcefully throws a failed assertion.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { fail } from "@std/assert";
*
* fail("Deliberately failed!"); // Throws
Expand Down
2 changes: 1 addition & 1 deletion assert/false.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type Falsy = false | 0 | 0n | "" | null | undefined;
* Make an assertion, error will be thrown if `expr` have truthy value.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { assertFalse } from "@std/assert";
*
* assertFalse(false); // Doesn't throw
Expand Down
2 changes: 1 addition & 1 deletion assert/greater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { AssertionError } from "./assertion_error.ts";
* If not then throw.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { assertGreater } from "@std/assert";
*
* assertGreater(2, 1); // Doesn't throw
Expand Down
2 changes: 1 addition & 1 deletion assert/greater_or_equal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { AssertionError } from "./assertion_error.ts";
* If not then throw.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { assertGreaterOrEqual } from "@std/assert";
*
* assertGreaterOrEqual(2, 1); // Doesn't throw
Expand Down
2 changes: 1 addition & 1 deletion assert/instance_of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type GetConstructorType<T extends AnyConstructor> = InstanceType<T>;
* If not then throw.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { assertInstanceOf } from "@std/assert";
*
* assertInstanceOf(new Date(), Date); // Doesn't throw
Expand Down
2 changes: 1 addition & 1 deletion assert/is_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { stripAnsiCode } from "@std/internal/styles";
* error message can also be asserted.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { assertIsError } from "@std/assert";
*
* assertIsError(null); // Throws
Expand Down
2 changes: 1 addition & 1 deletion assert/less.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { AssertionError } from "./assertion_error.ts";
* If not then throw.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { assertLess } from "@std/assert";
*
* assertLess(1, 2); // Doesn't throw
Expand Down
2 changes: 1 addition & 1 deletion assert/less_or_equal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { AssertionError } from "./assertion_error.ts";
* If not then throw.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { assertLessOrEqual } from "@std/assert";
*
* assertLessOrEqual(1, 2); // Doesn't throw
Expand Down
2 changes: 1 addition & 1 deletion assert/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AssertionError } from "./assertion_error.ts";
* then throw.
*
* @example Usage
* ```ts no-eval
* ```ts ignore
* import { assertMatch } from "@std/assert";
*
* assertMatch("Raptor", /Raptor/); // Doesn't throw
Expand Down
Loading