Skip to content

Commit

Permalink
Fix file path to URL conversion for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nayeemrmn committed Sep 26, 2019
1 parent b7ba067 commit ffc2a39
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions testing/runner.ts
Expand Up @@ -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;
Expand Down Expand Up @@ -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 })
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ffc2a39

Please sign in to comment.