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