From be5c4516ef648919a59deba8b9d0cc30f2b4bc45 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sun, 9 May 2021 14:46:56 -0700 Subject: [PATCH] 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 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/linters/params/swift-format-official.js b/test/linters/params/swift-format-official.js index 0df36a58..225300ff 100644 --- a/test/linters/params/swift-format-official.js +++ b/test/linters/params/swift-format-official.js @@ -1,4 +1,5 @@ const { join } = require("path"); +const { slash } = require("slash"); const SwiftFormatOfficial = require("../../../src/linters/swift-format-official"); @@ -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"