From 669bfb9f7216fb7efec41748516c49afcbdcbaba Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sun, 9 May 2021 14:43:58 -0700 Subject: [PATCH 1/3] test: stylistic change for recording the warning (NFC) This removes the trailing `,` to allow the warnings to be listed similarly. This is purely a stylistic change intended to help simplify future changes. --- test/linters/params/swift-format-official.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/linters/params/swift-format-official.js b/test/linters/params/swift-format-official.js index f93a21a7..0df36a58 100644 --- a/test/linters/params/swift-format-official.js +++ b/test/linters/params/swift-format-official.js @@ -10,10 +10,7 @@ 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 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`; // Files on macOS are not sorted. const stderr = From f8ace83898822b543bf449edb4ab6091e7846f65 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sun, 9 May 2021 14:46:56 -0700 Subject: [PATCH 2/3] test: normalize expected paths for Windows 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. --- test/linters/params/swift-format-official.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/linters/params/swift-format-official.js b/test/linters/params/swift-format-official.js index 0df36a58..f6f3f84c 100644 --- a/test/linters/params/swift-format-official.js +++ b/test/linters/params/swift-format-official.js @@ -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"; @@ -8,10 +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 ';'`; + 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" From b7460212eb22254e12b8e525a2f4e09914c096c6 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sun, 9 May 2021 15:29:26 -0700 Subject: [PATCH 3/3] package.json: update the dependencies Add a dependency on slash for development purposes. --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 895d0528..a081b22a 100644 --- a/package.json +++ b/package.json @@ -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,