2020-01-02 15:13:47 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2019-03-06 19:42:24 -05:00
|
|
|
import { assertEquals } from "../testing/asserts.ts";
|
2020-09-27 06:22:32 -04:00
|
|
|
import { dirname, fromFileUrl, relative, resolve } from "../path/mod.ts";
|
2020-09-09 14:57:49 -04:00
|
|
|
|
|
|
|
const moduleDir = dirname(fromFileUrl(import.meta.url));
|
2018-12-19 13:50:48 -05:00
|
|
|
|
|
|
|
/** Example of how to do basic tests */
|
2020-04-28 06:33:09 -04:00
|
|
|
Deno.test("t1", function (): void {
|
2019-03-06 19:42:24 -05:00
|
|
|
assertEquals("hello", "hello");
|
2018-12-19 13:50:48 -05:00
|
|
|
});
|
|
|
|
|
2020-04-28 06:33:09 -04:00
|
|
|
Deno.test("t2", function (): void {
|
2019-03-06 19:42:24 -05:00
|
|
|
assertEquals("world", "world");
|
2018-12-19 13:50:48 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
/** A more complicated test that runs a subprocess. */
|
2020-04-28 06:33:09 -04:00
|
|
|
Deno.test("catSmoke", async function (): Promise<void> {
|
2020-06-12 15:23:38 -04:00
|
|
|
const p = Deno.run({
|
2020-03-21 17:44:18 -04:00
|
|
|
cmd: [
|
2019-08-13 20:03:29 -04:00
|
|
|
Deno.execPath(),
|
2019-07-29 04:46:21 -04:00
|
|
|
"run",
|
2020-11-20 12:01:58 -05:00
|
|
|
"--quiet",
|
2019-07-29 04:46:21 -04:00
|
|
|
"--allow-read",
|
2020-09-09 14:57:49 -04:00
|
|
|
relative(Deno.cwd(), resolve(moduleDir, "cat.ts")),
|
|
|
|
relative(Deno.cwd(), resolve(moduleDir, "..", "README.md")),
|
2019-07-29 04:46:21 -04:00
|
|
|
],
|
2020-03-18 19:25:55 -04:00
|
|
|
stdout: "null",
|
2020-03-28 13:03:49 -04:00
|
|
|
stderr: "null",
|
2018-12-19 13:50:48 -05:00
|
|
|
});
|
|
|
|
const s = await p.status();
|
2019-03-06 19:42:24 -05:00
|
|
|
assertEquals(s.code, 0);
|
2020-03-18 19:25:55 -04:00
|
|
|
p.close();
|
2018-12-19 13:50:48 -05:00
|
|
|
});
|