mirror of
https://github.com/denoland/deno.git
synced 2025-10-01 06:31:15 +00:00
Check file changes during test (denoland/deno_std#476)
Original: 7daa887b09
This commit is contained in:
parent
e729d442fb
commit
21684c679b
2 changed files with 67 additions and 29 deletions
39
test.ts
39
test.ts
|
@ -21,4 +21,41 @@ import "./textproto/test.ts";
|
|||
import "./util/test.ts";
|
||||
import "./ws/test.ts";
|
||||
|
||||
import "./testing/main.ts";
|
||||
import { xrun } from "./prettier/util.ts";
|
||||
import { red, green } from "./colors/mod.ts";
|
||||
import { runTests } from "./testing/mod.ts";
|
||||
|
||||
async function run(): Promise<void> {
|
||||
const startTime = Date.now();
|
||||
await runTests();
|
||||
await checkSourceFileChanges(startTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether any source file is changed since the given start time.
|
||||
* If some files are changed, this function exits with 1.
|
||||
*/
|
||||
async function checkSourceFileChanges(startTime: number): Promise<void> {
|
||||
console.log("test checkSourceFileChanges ...");
|
||||
const changed = new TextDecoder()
|
||||
.decode(await xrun({ args: ["git", "ls-files"], stdout: "piped" }).output())
|
||||
.trim()
|
||||
.split("\n")
|
||||
.filter(file => {
|
||||
const stat = Deno.lstatSync(file);
|
||||
if (stat != null) {
|
||||
return (stat as any).modified * 1000 > startTime;
|
||||
}
|
||||
});
|
||||
if (changed.length > 0) {
|
||||
console.log(red("FAILED"));
|
||||
console.log(
|
||||
`Error: Some source files are modified during test: ${changed.join(", ")}`
|
||||
);
|
||||
Deno.exit(1);
|
||||
} else {
|
||||
console.log(green("ok"));
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue