2021-01-10 21:59:07 -05:00
|
|
|
// Copyright 2018-2021 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-10 02:57:49 +08: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 12:33:09 +02: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 12:33:09 +02: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 12:33:09 +02:00
|
|
|
Deno.test("catSmoke", async function (): Promise<void> {
|
2020-06-12 20:23:38 +01:00
|
|
|
const p = Deno.run({
|
2020-03-22 03:14:18 +05:30
|
|
|
cmd: [
|
2019-08-14 02:03:29 +02:00
|
|
|
Deno.execPath(),
|
2019-07-29 17:46:21 +09:00
|
|
|
"run",
|
2020-11-20 18:01:58 +01:00
|
|
|
"--quiet",
|
2019-07-29 17:46:21 +09:00
|
|
|
"--allow-read",
|
2020-09-10 02:57:49 +08:00
|
|
|
relative(Deno.cwd(), resolve(moduleDir, "cat.ts")),
|
|
|
|
relative(Deno.cwd(), resolve(moduleDir, "..", "README.md")),
|
2019-07-29 17:46:21 +09:00
|
|
|
],
|
2020-03-19 00:25:55 +01:00
|
|
|
stdout: "null",
|
2020-03-29 04:03:49 +11: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-19 00:25:55 +01:00
|
|
|
p.close();
|
2018-12-19 13:50:48 -05:00
|
|
|
});
|