Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Use denormalized path in test (fixes Windows build) #1701

Merged
merged 3 commits into from
Nov 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions test/executable/executableTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { createTempFile } from "../utils";
import { createTempFile, denormalizeWinPath } from "../utils";
import * as cp from "child_process";
import * as fs from "fs";
import * as os from "os";
Expand Down Expand Up @@ -123,10 +123,12 @@ describe("Executable", function() {
execCli(["-c", "test/files/multiple-fixes-test/tslint.json", tempFile, "--fix"],
(err, stdout) => {
const content = fs.readFileSync(tempFile, "utf8");
// compare against file name which will be returned by formatter (used in TypeScript)
const denormalizedFileName = denormalizeWinPath(tempFile);
fs.unlinkSync(tempFile);
assert.strictEqual(content, "import * as y from \"a_long_module\";\nimport * as x from \"b\";\n");
assert.isNull(err, "process should exit without an error");
assert.strictEqual(stdout, `Fixed 2 error(s) in ${tempFile}`);
assert.strictEqual(stdout, `Fixed 2 error(s) in ${denormalizedFileName}`);
done();
});
});
Expand Down
5 changes: 5 additions & 0 deletions test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,8 @@ export function createTempFile(extension: string) {
}
return tmpfile;
}

// converts Windows normalized paths (with backwards slash `\`) to paths used by TypeScript (with forward slash `/`)
export function denormalizeWinPath(path: string): string {
return path.replace(/\\/g, "/");
}