summaryrefslogtreecommitdiff
path: root/testing/runner_test.ts
diff options
context:
space:
mode:
authorNayeem Rahman <muhammed.9939@gmail.com>2019-10-02 18:59:27 +0100
committerRyan Dahl <ry@tinyclouds.org>2019-10-02 13:59:27 -0400
commit2f90225c89926932a34eb40758e2af0d1742e1f8 (patch)
tree21466759c5a9ff26cff1397736fc6a10ff9880fd /testing/runner_test.ts
parentaca225330521840d63835bb1ba27ce13a7f65093 (diff)
Implement expandGlob() and expandGlobSync() (denoland/deno_std#617)
fs/glob.ts: - Improve prototypes for expandGlob() and expandGlobSync() from denoland/deno_std#604. - Rename glob() to globToRegExp(). - Add normalizeGlob() and joinGlobs(). - Extract GlobToRegExpOptions from GlobOptions, remove the strict and filepath options. fs/globrex.ts: - Add GlobrexOptions. fs/path/constants.ts: - Add SEP_PATTERN. fs/walk.ts: - Add WalkOptions::includeFiles - Default WalkOptions::includeDirs to true. - Don't traverse directories matching a skip pattern. - Remove walkSync()'s default root value. prettier: - Refactor to use expandGlob(). testing: - Make findTestModules() an async generator. Original: https://github.com/denoland/deno_std/commit/8c90bd9d0b1c78b023d36462ffaa9446ef22490c
Diffstat (limited to 'testing/runner_test.ts')
-rw-r--r--testing/runner_test.ts29
1 files changed, 23 insertions, 6 deletions
diff --git a/testing/runner_test.ts b/testing/runner_test.ts
index 9b6214918..e2617b155 100644
--- a/testing/runner_test.ts
+++ b/testing/runner_test.ts
@@ -3,17 +3,30 @@ import { test } from "./mod.ts";
import { findTestModules } from "./runner.ts";
import { isWindows } from "../fs/path/constants.ts";
import { assertEquals } from "../testing/asserts.ts";
+const { cwd } = Deno;
function urlToFilePath(url: URL): string {
// Since `new URL('file:///C:/a').pathname` is `/C:/a`, remove leading slash.
return url.pathname.slice(url.protocol == "file:" && isWindows ? 1 : 0);
}
+async function findTestModulesArray(
+ include: string[],
+ exclude: string[],
+ root: string = cwd()
+): Promise<string[]> {
+ const result = [];
+ for await (const testModule of findTestModules(include, exclude, root)) {
+ result.push(testModule);
+ }
+ return result;
+}
+
const TEST_DATA_URL = new URL("testdata", import.meta.url);
const TEST_DATA_PATH = urlToFilePath(TEST_DATA_URL);
test(async function findTestModulesDir1(): Promise<void> {
- const urls = await findTestModules(["."], [], TEST_DATA_PATH);
+ const urls = await findTestModulesArray(["."], [], TEST_DATA_PATH);
assertEquals(urls.sort(), [
`${TEST_DATA_URL}/bar_test.js`,
`${TEST_DATA_URL}/foo_test.ts`,
@@ -27,7 +40,7 @@ test(async function findTestModulesDir1(): Promise<void> {
});
test(async function findTestModulesDir2(): Promise<void> {
- const urls = await findTestModules(["subdir"], [], TEST_DATA_PATH);
+ const urls = await findTestModulesArray(["subdir"], [], TEST_DATA_PATH);
assertEquals(urls.sort(), [
`${TEST_DATA_URL}/subdir/bar_test.js`,
`${TEST_DATA_URL}/subdir/foo_test.ts`,
@@ -37,7 +50,11 @@ test(async function findTestModulesDir2(): Promise<void> {
});
test(async function findTestModulesGlob(): Promise<void> {
- const urls = await findTestModules(["**/*_test.{js,ts}"], [], TEST_DATA_PATH);
+ const urls = await findTestModulesArray(
+ ["**/*_test.{js,ts}"],
+ [],
+ TEST_DATA_PATH
+ );
assertEquals(urls.sort(), [
`${TEST_DATA_URL}/bar_test.js`,
`${TEST_DATA_URL}/foo_test.ts`,
@@ -47,7 +64,7 @@ test(async function findTestModulesGlob(): Promise<void> {
});
test(async function findTestModulesExcludeDir(): Promise<void> {
- const urls = await findTestModules(["."], ["subdir"], TEST_DATA_PATH);
+ const urls = await findTestModulesArray(["."], ["subdir"], TEST_DATA_PATH);
assertEquals(urls.sort(), [
`${TEST_DATA_URL}/bar_test.js`,
`${TEST_DATA_URL}/foo_test.ts`,
@@ -57,7 +74,7 @@ test(async function findTestModulesExcludeDir(): Promise<void> {
});
test(async function findTestModulesExcludeGlob(): Promise<void> {
- const urls = await findTestModules(["."], ["**/foo*"], TEST_DATA_PATH);
+ const urls = await findTestModulesArray(["."], ["**/foo*"], TEST_DATA_PATH);
assertEquals(urls.sort(), [
`${TEST_DATA_URL}/bar_test.js`,
`${TEST_DATA_URL}/subdir/bar_test.js`,
@@ -73,6 +90,6 @@ test(async function findTestModulesRemote(): Promise<void> {
"https://example.com/colors_test.ts",
"http://example.com/printf_test.ts"
];
- const matches = await findTestModules(urls, []);
+ const matches = await findTestModulesArray(urls, []);
assertEquals(matches, urls);
});