diff --git a/testing/runner.ts b/testing/runner.ts index 85d0c70ab94c..0839f7bd6414 100755 --- a/testing/runner.ts +++ b/testing/runner.ts @@ -7,6 +7,7 @@ import { glob, ExpandGlobOptions } from "../fs/mod.ts"; +import { isWindows } from "../fs/path/constants.ts"; import { isAbsolute, join } from "../fs/path/mod.ts"; import { RunTestsOptions, runTests } from "./mod.ts"; const { DenoError, ErrorKind, args, cwd, exit } = Deno; @@ -55,6 +56,10 @@ function partition( ); } +function filePathToUrl(path: string): string { + return `file://${isWindows ? "/" : ""}${path.replace(/\\/g, "/")}`; +} + function expandDirectory(dir: string, options: ExpandGlobOptions): WalkInfo[] { return DIR_GLOBS.flatMap((s: string): WalkInfo[] => [ ...expandGlobSync(s, { ...options, root: dir }) @@ -108,10 +113,7 @@ export async function findTestModules( const matchedUrls = includeUrls.filter(notExcludedUrl); - return [ - ...matchedPaths.map((path: string): string => `file://${path}`), - ...matchedUrls - ]; + return [...matchedPaths.map(filePathToUrl), ...matchedUrls]; } export interface RunTestModulesOptions extends RunTestsOptions {