From 74c37e759ac03267975309c1425223289ebc925f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 19 Mar 2020 14:49:06 +0100 Subject: [PATCH] remove std/testing/runner.ts, use deno test for std/ tests (#4397) This introduces BREAKING CHANGE by removing "std/testing/runner.ts". Std tests are now run using "deno test" subcommand. --- cli/tests/std_tests.rs | 3 +- std/testing/runner_test.ts | 94 ------------------------- std/testing/testdata/bar.js | 1 - std/testing/testdata/bar_test.js | 1 - std/testing/testdata/foo.ts | 1 - std/testing/testdata/foo_test.ts | 1 - std/testing/testdata/subdir/bar.js | 1 - std/testing/testdata/subdir/bar_test.js | 1 - std/testing/testdata/subdir/foo.ts | 1 - std/testing/testdata/subdir/foo_test.ts | 1 - std/testing/testdata/subdir/test.js | 1 - std/testing/testdata/subdir/test.ts | 1 - std/testing/testdata/test.js | 1 - std/testing/testdata/test.ts | 1 - 14 files changed, 1 insertion(+), 108 deletions(-) delete mode 100644 std/testing/runner_test.ts delete mode 100644 std/testing/testdata/bar.js delete mode 100644 std/testing/testdata/bar_test.js delete mode 100644 std/testing/testdata/foo.ts delete mode 100644 std/testing/testdata/foo_test.ts delete mode 100644 std/testing/testdata/subdir/bar.js delete mode 100644 std/testing/testdata/subdir/bar_test.js delete mode 100644 std/testing/testdata/subdir/foo.ts delete mode 100644 std/testing/testdata/subdir/foo_test.ts delete mode 100644 std/testing/testdata/subdir/test.js delete mode 100644 std/testing/testdata/subdir/test.ts delete mode 100644 std/testing/testdata/test.js delete mode 100644 std/testing/testdata/test.ts diff --git a/cli/tests/std_tests.rs b/cli/tests/std_tests.rs index bb14f9c3aa..32906c2fa5 100644 --- a/cli/tests/std_tests.rs +++ b/cli/tests/std_tests.rs @@ -17,11 +17,10 @@ mod tests { cwd.push("std"); let mut deno = deno_cmd .current_dir(cwd) // note: std tests expect to run from "std" dir + .arg("test") .arg("--seed=86") // Some tests rely on specific random numbers. .arg("-A") // .arg("-Ldebug") - .arg("./testing/runner.ts") - .arg("--exclude=testing/testdata") .spawn() .expect("failed to spawn script"); let status = deno.wait().expect("failed to wait for the child process"); diff --git a/std/testing/runner_test.ts b/std/testing/runner_test.ts deleted file mode 100644 index f39e5d3268..0000000000 --- a/std/testing/runner_test.ts +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { assertEquals } from "../testing/asserts.ts"; -import { isWindows } from "../path/mod.ts"; -import { findTestModules } from "./runner.ts"; -const { cwd, test } = 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 { - 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 { - const urls = await findTestModulesArray(["."], [], TEST_DATA_PATH); - assertEquals(urls.sort(), [ - `${TEST_DATA_URL}/bar_test.js`, - `${TEST_DATA_URL}/foo_test.ts`, - `${TEST_DATA_URL}/subdir/bar_test.js`, - `${TEST_DATA_URL}/subdir/foo_test.ts`, - `${TEST_DATA_URL}/subdir/test.js`, - `${TEST_DATA_URL}/subdir/test.ts`, - `${TEST_DATA_URL}/test.js`, - `${TEST_DATA_URL}/test.ts` - ]); -}); - -test(async function findTestModulesDir2(): Promise { - 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`, - `${TEST_DATA_URL}/subdir/test.js`, - `${TEST_DATA_URL}/subdir/test.ts` - ]); -}); - -test(async function findTestModulesGlob(): Promise { - 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`, - `${TEST_DATA_URL}/subdir/bar_test.js`, - `${TEST_DATA_URL}/subdir/foo_test.ts` - ]); -}); - -test(async function findTestModulesExcludeDir(): Promise { - const urls = await findTestModulesArray(["."], ["subdir"], TEST_DATA_PATH); - assertEquals(urls.sort(), [ - `${TEST_DATA_URL}/bar_test.js`, - `${TEST_DATA_URL}/foo_test.ts`, - `${TEST_DATA_URL}/test.js`, - `${TEST_DATA_URL}/test.ts` - ]); -}); - -test(async function findTestModulesExcludeGlob(): Promise { - const urls = await findTestModulesArray(["."], ["**/foo*"], TEST_DATA_PATH); - assertEquals(urls.sort(), [ - `${TEST_DATA_URL}/bar_test.js`, - `${TEST_DATA_URL}/subdir/bar_test.js`, - `${TEST_DATA_URL}/subdir/test.js`, - `${TEST_DATA_URL}/subdir/test.ts`, - `${TEST_DATA_URL}/test.js`, - `${TEST_DATA_URL}/test.ts` - ]); -}); - -test(async function findTestModulesRemote(): Promise { - const urls = [ - "https://example.com/colors_test.ts", - "http://example.com/printf_test.ts" - ]; - const matches = await findTestModulesArray(urls, []); - assertEquals(matches, urls); -}); diff --git a/std/testing/testdata/bar.js b/std/testing/testdata/bar.js deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/std/testing/testdata/bar.js +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/std/testing/testdata/bar_test.js b/std/testing/testdata/bar_test.js deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/std/testing/testdata/bar_test.js +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/std/testing/testdata/foo.ts b/std/testing/testdata/foo.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/std/testing/testdata/foo.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/std/testing/testdata/foo_test.ts b/std/testing/testdata/foo_test.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/std/testing/testdata/foo_test.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/std/testing/testdata/subdir/bar.js b/std/testing/testdata/subdir/bar.js deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/std/testing/testdata/subdir/bar.js +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/std/testing/testdata/subdir/bar_test.js b/std/testing/testdata/subdir/bar_test.js deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/std/testing/testdata/subdir/bar_test.js +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/std/testing/testdata/subdir/foo.ts b/std/testing/testdata/subdir/foo.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/std/testing/testdata/subdir/foo.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/std/testing/testdata/subdir/foo_test.ts b/std/testing/testdata/subdir/foo_test.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/std/testing/testdata/subdir/foo_test.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/std/testing/testdata/subdir/test.js b/std/testing/testdata/subdir/test.js deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/std/testing/testdata/subdir/test.js +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/std/testing/testdata/subdir/test.ts b/std/testing/testdata/subdir/test.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/std/testing/testdata/subdir/test.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/std/testing/testdata/test.js b/std/testing/testdata/test.js deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/std/testing/testdata/test.js +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/std/testing/testdata/test.ts b/std/testing/testdata/test.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/std/testing/testdata/test.ts +++ /dev/null @@ -1 +0,0 @@ -export {};