2019-05-06 17:07:43 -04:00
|
|
|
#!/usr/bin/env deno run -A
|
2019-02-07 19:45:47 +03:00
|
|
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
2019-05-15 06:59:43 +09:00
|
|
|
import "./archive/tar_test.ts";
|
2019-05-24 19:44:13 +08:00
|
|
|
import "./bytes/test.ts";
|
2019-02-24 00:13:54 +08:00
|
|
|
import "./colors/test.ts";
|
|
|
|
import "./datetime/test.ts";
|
2019-05-23 20:48:54 +02:00
|
|
|
import "./encoding/test.ts";
|
2019-02-24 00:13:54 +08:00
|
|
|
import "./examples/test.ts";
|
|
|
|
import "./flags/test.ts";
|
2019-03-18 17:49:54 +01:00
|
|
|
import "./fs/test.ts";
|
|
|
|
import "./http/test.ts";
|
2019-04-13 21:24:36 +02:00
|
|
|
import "./io/test.ts";
|
2019-02-24 00:13:54 +08:00
|
|
|
import "./log/test.ts";
|
|
|
|
import "./media_types/test.ts";
|
2019-05-21 15:36:12 +02:00
|
|
|
import "./mime/test.ts";
|
2019-03-18 17:49:54 +01:00
|
|
|
import "./multipart/test.ts";
|
|
|
|
import "./prettier/test.ts";
|
|
|
|
import "./strings/test.ts";
|
2019-02-24 00:13:54 +08:00
|
|
|
import "./testing/test.ts";
|
|
|
|
import "./textproto/test.ts";
|
2019-05-20 09:17:26 -04:00
|
|
|
import "./util/test.ts";
|
2019-02-24 00:13:54 +08:00
|
|
|
import "./ws/test.ts";
|
2019-01-24 16:25:13 -05:00
|
|
|
|
2019-06-03 10:42:27 +09:00
|
|
|
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();
|