Skip to content

Commit

Permalink
test: normalize expected paths for Windows
Browse files Browse the repository at this point in the history
When testing on Windows, the tool currently prints paths with a `/` path
separator rather than the canonical `\` separator for the platform.  The
resulting path is valid and usable.  However, this causes match failures
due to the difference in the path separator.  The `slash` module permits
us to normalize the path for the tests.  This should have no impact when
running on Unix platforms, but allows greater portability to Windows.
  • Loading branch information
compnerd committed May 9, 2021
1 parent 7012278 commit be5c451
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/linters/params/swift-format-official.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { join } = require("path");
const { slash } = require("slash");

const SwiftFormatOfficial = require("../../../src/linters/swift-format-official");

Expand All @@ -8,10 +9,10 @@ const commandPrefix = "";
const extensions = ["swift"];

function getLintParams(dir) {
const warning1 = `${join(dir, "file2.swift")}:2:22: warning: [DoNotUseSemicolons]: remove ';'`;
const warning2 = `${join(dir, "file1.swift")}:3:35: warning: [RemoveLine]: remove line break`;
const warning3 = `${join(dir, "file1.swift")}:7:1: warning: [Indentation] replace leading whitespace with 2 spaces`;
const warning4 = `${join(dir, "file1.swift")}:7:23: warning: [Spacing]: add 1 space`;
const warning1 = `${slash(join(dir, "file2.swift"))}:2:22: warning: [DoNotUseSemicolons]: remove ';'`;
const warning2 = `${slash(join(dir, "file1.swift"))}:3:35: warning: [RemoveLine]: remove line break`;
const warning3 = `${slash(join(dir, "file1.swift"))}:7:1: warning: [Indentation] replace leading whitespace with 2 spaces`;
const warning4 = `${slash(join(dir, "file1.swift"))}:7:23: warning: [Spacing]: add 1 space`;
// Files on macOS are not sorted.
const stderr =
process.platform === "darwin"
Expand Down

0 comments on commit be5c451

Please sign in to comment.