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

feat(lint): add Deno.run to no-deprecated-deno-api #18869

Merged
merged 3 commits into from
Apr 27, 2023
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 Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"]
deno_doc = "0.62.0"
deno_emit = "0.20.0"
deno_graph = "=0.48.1"
deno_lint = { version = "0.44.0", features = ["docs"] }
deno_lint = { version = "0.45.0", features = ["docs"] }
deno_lockfile.workspace = true
deno_npm.workspace = true
deno_runtime = { workspace = true, features = ["dont_create_runtime_snapshot", "include_js_files_for_snapshotting"] }
Expand Down
2 changes: 2 additions & 0 deletions cli/tests/testdata/coverage/complex_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Deno.test("complex", function () {
Deno.test("sub process with stdin", async () => {
// ensure launching deno run with stdin doesn't affect coverage
const code = "console.log('5')";
// deno-lint-ignore no-deprecated-deno-api
const p = await Deno.run({
cmd: [Deno.execPath(), "run", "-"],
stdin: "piped",
Expand All @@ -25,6 +26,7 @@ Deno.test("sub process with stdin", async () => {
Deno.test("sub process with deno eval", async () => {
// ensure launching deno eval doesn't affect coverage
const code = "console.log('5')";
// deno-lint-ignore no-deprecated-deno-api
const p = await Deno.run({
cmd: [Deno.execPath(), "eval", code],
stdout: "piped",
Expand Down
1 change: 1 addition & 0 deletions cli/tests/testdata/test/captured_output.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Deno.test("output", async () => {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [Deno.execPath(), "eval", "console.log(0); console.error(1);"],
});
Expand Down
2 changes: 2 additions & 0 deletions cli/tests/unit/http_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2085,6 +2085,7 @@ Deno.test({
"--header",
"Accept-Encoding: deflate, gzip",
];
// deno-lint-ignore no-deprecated-deno-api
const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
const status = await proc.status();
assert(status.success);
Expand Down Expand Up @@ -2147,6 +2148,7 @@ Deno.test({
"--header",
"Accept-Encoding: deflate, gzip",
];
// deno-lint-ignore no-deprecated-deno-api
const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
const status = await proc.status();
assert(status.success);
Expand Down
29 changes: 29 additions & 0 deletions cli/tests/unit/process_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Deno.test(
{ permissions: { read: true, run: false } },
function runPermissions() {
assertThrows(() => {
// deno-lint-ignore no-deprecated-deno-api
Deno.run({
cmd: [Deno.execPath(), "eval", "console.log('hello world')"],
});
Expand All @@ -21,6 +22,7 @@ Deno.test(
Deno.test(
{ permissions: { run: true, read: true } },
async function runSuccess() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
// freeze the array to ensure it's not modified
cmd: Object.freeze([
Expand All @@ -43,6 +45,7 @@ Deno.test(
Deno.test(
{ permissions: { run: true, read: true } },
async function runUrl() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
new URL(`file:///${Deno.execPath()}`),
Expand All @@ -66,6 +69,7 @@ Deno.test(
async function runStdinRid0(): Promise<
void
> {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [Deno.execPath(), "eval", "console.log('hello world')"],
stdin: 0,
Expand All @@ -85,20 +89,23 @@ Deno.test(
{ permissions: { run: true, read: true } },
function runInvalidStdio() {
assertThrows(() =>
// deno-lint-ignore no-deprecated-deno-api
Deno.run({
cmd: [Deno.execPath(), "eval", "console.log('hello world')"],
// @ts-expect-error because Deno.run should throw on invalid stdin.
stdin: "a",
})
);
assertThrows(() =>
// deno-lint-ignore no-deprecated-deno-api
Deno.run({
cmd: [Deno.execPath(), "eval", "console.log('hello world')"],
// @ts-expect-error because Deno.run should throw on invalid stdout.
stdout: "b",
})
);
assertThrows(() =>
// deno-lint-ignore no-deprecated-deno-api
Deno.run({
cmd: [Deno.execPath(), "eval", "console.log('hello world')"],
// @ts-expect-error because Deno.run should throw on invalid stderr.
Expand All @@ -111,6 +118,7 @@ Deno.test(
Deno.test(
{ permissions: { run: true, read: true } },
async function runCommandFailedWithCode() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [Deno.execPath(), "eval", "Deno.exit(41 + 1)"],
});
Expand All @@ -127,6 +135,7 @@ Deno.test(
permissions: { run: true, read: true },
},
async function runCommandFailedWithSignal() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
Expand All @@ -150,6 +159,7 @@ Deno.test(
Deno.test({ permissions: { run: true } }, function runNotFound() {
let error;
try {
// deno-lint-ignore no-deprecated-deno-api
Deno.run({ cmd: ["this file hopefully doesn't exist"] });
} catch (e) {
error = e;
Expand Down Expand Up @@ -181,6 +191,7 @@ tryExit();
`;

Deno.writeFileSync(`${cwd}/${programFile}`, enc.encode(program));
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cwd,
cmd: [Deno.execPath(), "run", "--allow-read", programFile],
Expand All @@ -204,6 +215,7 @@ Deno.test(
async function runStdinPiped(): Promise<
void
> {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
Expand Down Expand Up @@ -235,6 +247,7 @@ Deno.test(
async function runStdoutPiped(): Promise<
void
> {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
Expand Down Expand Up @@ -271,6 +284,7 @@ Deno.test(
async function runStderrPiped(): Promise<
void
> {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
Expand Down Expand Up @@ -305,6 +319,7 @@ Deno.test(
Deno.test(
{ permissions: { run: true, read: true } },
async function runOutput() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
Expand All @@ -325,6 +340,7 @@ Deno.test(
async function runStderrOutput(): Promise<
void
> {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
Expand All @@ -350,6 +366,7 @@ Deno.test(
write: true,
});

// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
Expand Down Expand Up @@ -382,6 +399,7 @@ Deno.test(
await Deno.writeFile(fileName, encoder.encode("hello"));
const file = await Deno.open(fileName);

// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
Expand All @@ -401,6 +419,7 @@ Deno.test(
Deno.test(
{ permissions: { run: true, read: true } },
async function runEnv() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
Expand All @@ -423,6 +442,7 @@ Deno.test(
Deno.test(
{ permissions: { run: true, read: true } },
async function runClose() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
Expand All @@ -446,6 +466,7 @@ Deno.test(
Deno.test(
{ permissions: { run: true, read: true } },
async function runKillAfterStatus() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [Deno.execPath(), "eval", 'console.log("hello")'],
});
Expand Down Expand Up @@ -502,6 +523,7 @@ Deno.test(
Deno.test(
{ permissions: { run: true, read: true } },
async function killSuccess() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [Deno.execPath(), "eval", "setTimeout(() => {}, 10000)"],
});
Expand All @@ -525,6 +547,7 @@ Deno.test(
);

Deno.test({ permissions: { run: true, read: true } }, function killFailed() {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [Deno.execPath(), "eval", "setTimeout(() => {}, 10000)"],
});
Expand All @@ -542,6 +565,7 @@ Deno.test({ permissions: { run: true, read: true } }, function killFailed() {
Deno.test(
{ permissions: { run: true, read: true, env: true } },
async function clearEnv(): Promise<void> {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
Expand Down Expand Up @@ -574,6 +598,7 @@ Deno.test(
ignore: Deno.build.os === "windows",
},
async function uid(): Promise<void> {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
"id",
Expand All @@ -587,6 +612,7 @@ Deno.test(

if (currentUid !== "0") {
assertThrows(() => {
// deno-lint-ignore no-deprecated-deno-api
Deno.run({
cmd: [
"echo",
Expand All @@ -605,6 +631,7 @@ Deno.test(
ignore: Deno.build.os === "windows",
},
async function gid(): Promise<void> {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
"id",
Expand All @@ -618,6 +645,7 @@ Deno.test(

if (currentGid !== "0") {
assertThrows(() => {
// deno-lint-ignore no-deprecated-deno-api
Deno.run({
cmd: [
"echo",
Expand All @@ -636,6 +664,7 @@ Deno.test(
ignore: Deno.build.os === "windows",
},
async function non_existent_cwd(): Promise<void> {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({
cmd: [
Deno.execPath(),
Expand Down
2 changes: 1 addition & 1 deletion third_party