forked from denoland/std
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.ts
executable file
·63 lines (59 loc) · 1.74 KB
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env deno run -A
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import "./archive/tar_test.ts";
import "./bytes/test.ts";
import "./bundle/test.ts";
import "./colors/test.ts";
import "./datetime/test.ts";
import "./encoding/test.ts";
import "./examples/test.ts";
import "./flags/test.ts";
import "./fs/test.ts";
import "./http/test.ts";
import "./io/test.ts";
import "./installer/test.ts";
import "./log/test.ts";
import "./media_types/test.ts";
import "./mime/test.ts";
import "./multipart/test.ts";
import "./prettier/test.ts";
import "./strings/test.ts";
import "./testing/test.ts";
import "./textproto/test.ts";
import "./util/test.ts";
import "./ws/test.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();