-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
673e7a6
commit 8e0e230
Showing
6 changed files
with
61 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v20.17.0 | ||
v22.10.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
{ | ||
"deno.enable": true, | ||
"deno.enablePaths": [ | ||
"./crates/ruff_fmt/test_deno" | ||
"./crates/ruff_fmt/test_deno", | ||
"./crates/ruff_fmt/scripts/update_tests.ts" | ||
], | ||
"rust-analyzer.cargo.target": "wasm32-unknown-unknown" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env -S deno run --allow-read --allow-write | ||
import { walk } from "jsr:@std/fs/walk"; | ||
|
||
import init, { format } from "../pkg/ruff_fmt.js"; | ||
|
||
await init(); | ||
|
||
const test_root = new URL(import.meta.resolve("../test_data")); | ||
|
||
for await (const entry of walk(test_root, { | ||
includeDirs: false, | ||
exts: ["py", "pyi"], | ||
})) { | ||
if (entry.name.startsWith(".")) { | ||
continue; | ||
} | ||
|
||
const expect_path = entry.path + ".expect"; | ||
const input = Deno.readTextFileSync(entry.path); | ||
|
||
const actual = format(input, entry.path); | ||
Deno.writeTextFileSync(expect_path, actual); | ||
} | ||
console.log("done"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,29 @@ | ||
/// <reference lib="deno.ns" /> | ||
import { assertEquals } from "https://deno.land/std@0.201.0/assert/mod.ts"; | ||
import { walk } from "https://deno.land/std@0.201.0/fs/walk.ts"; | ||
import { relative } from "https://deno.land/std@0.201.0/path/mod.ts"; | ||
import { assertEquals } from "jsr:@std/assert"; | ||
import { walk } from "jsr:@std/fs/walk"; | ||
|
||
import init, { format } from "../pkg/ruff_fmt.js"; | ||
|
||
await init(); | ||
|
||
const update = Deno.args.includes("--update"); | ||
|
||
const test_root = new URL("../test_data", import.meta.url); | ||
const test_root = new URL(import.meta.resolve("../test_data")); | ||
Deno.chdir(test_root); | ||
|
||
for await (const entry of walk(test_root, { | ||
for await (const entry of walk(".", { | ||
includeDirs: false, | ||
exts: ["py", "pyi"], | ||
})) { | ||
const expect_path = entry.path + ".expect"; | ||
const input = Deno.readTextFileSync(entry.path); | ||
if (entry.name.startsWith(".")) { | ||
continue; | ||
} | ||
|
||
if (update) { | ||
const actual = format(input, entry.path); | ||
Deno.writeTextFileSync(expect_path, actual); | ||
} else { | ||
const expected = Deno.readTextFileSync(expect_path); | ||
const input_path = entry.path; | ||
const expect_path = input_path + ".expect"; | ||
|
||
const test_name = relative(test_root.pathname, entry.path); | ||
const input = Deno.readTextFileSync(input_path); | ||
const expected = Deno.readTextFileSync(expect_path); | ||
|
||
Deno.test(test_name, () => { | ||
const actual = format(input, entry.path); | ||
assertEquals(actual, expected); | ||
}); | ||
} | ||
Deno.test(input_path, () => { | ||
const actual = format(input, entry.path); | ||
assertEquals(actual, expected); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters