Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use slash to allow testing on Windows #215

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"eslint-plugin-jsdoc": "^33.0.0",
"fs-extra": "^9.1.0",
"jest": "^26.6.3",
"prettier": "^2.2.1"
"prettier": "^2.2.1",
"slash": "^3.0.0"
},
"eslintConfig": {
"root": true,
Expand Down
13 changes: 6 additions & 7 deletions test/linters/params/swift-format-official.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const { join } = require("path");

const slash = require("slash");

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

const testName = "swift-format-official";
Expand All @@ -8,13 +10,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 ';'`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason why we can't use joinDoubleBackslash()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, joinDoubleBackslash will replace \ with \\. This will replace \ and \\ with /. They are preforming different operations. This is needed because the tooling currently prints out the path with / as the path separator on Windows rather than the canonical \.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ocean90 ping?

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