diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5c1e00c5..5a207a50 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,9 +21,11 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-latest, macos-latest ] + os: [ ubuntu-latest, macos-latest, windows-latest ] steps: + - name: Disable Git's autocrlf + run: git config --global core.autocrlf false - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 with: fetch-depth: 2 diff --git a/src/main/java/se/kth/spork/spoon/printer/SporkPrettyPrinter.java b/src/main/java/se/kth/spork/spoon/printer/SporkPrettyPrinter.java index 7d3d33c2..559f383b 100644 --- a/src/main/java/se/kth/spork/spoon/printer/SporkPrettyPrinter.java +++ b/src/main/java/se/kth/spork/spoon/printer/SporkPrettyPrinter.java @@ -47,6 +47,9 @@ public SporkPrettyPrinter(Environment env) { // instead of just String, it will print java.lang.String. Which isn't great. setIgnoreImplicit(false); + // TODO detect these values instead of setting unconditionally + printerHelper.setLineSeparator("\n"); + globalContentConflicts = DEFAULT_CONFLICT_MAP; } diff --git a/src/main/kotlin/se/kth/spork/spoon/Parser.kt b/src/main/kotlin/se/kth/spork/spoon/Parser.kt index 45379ff1..75c0cd1c 100644 --- a/src/main/kotlin/se/kth/spork/spoon/Parser.kt +++ b/src/main/kotlin/se/kth/spork/spoon/Parser.kt @@ -13,6 +13,7 @@ import spoon.reflect.declaration.CtType import spoon.support.compiler.FileSystemFile import spoon.support.compiler.VirtualFile import java.io.IOException +import java.nio.charset.StandardCharsets import java.nio.file.Files import java.nio.file.Path @@ -60,6 +61,7 @@ object Parser { env.useTabulations(useTabs) env.setPrettyPrinterCreator { SporkPrettyPrinter(env) } env.noClasspath = true + env.encoding = StandardCharsets.UTF_8 // TODO detect instead of setting unconditionally } private fun parse(configureLauncher: (Launcher) -> Unit): CtModule { @@ -115,7 +117,7 @@ object Parser { */ fun read(path: Path): String { return try { - java.lang.String.join("\n", Files.readAllLines(path)) + java.lang.String.join("\n", Files.readAllLines(path, StandardCharsets.UTF_8)) } catch (e: IOException) { e.printStackTrace() throw RuntimeException("Error reading from $path") diff --git a/src/test/java/se/kth/spork/Util.java b/src/test/java/se/kth/spork/Util.java index 8a3cd818..889ff181 100644 --- a/src/test/java/se/kth/spork/Util.java +++ b/src/test/java/se/kth/spork/Util.java @@ -4,6 +4,7 @@ import gumtree.spoon.builder.SpoonGumTreeBuilder; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -50,7 +51,7 @@ private static Stream getArgumentSourcesStream( } public static String read(Path path) throws IOException { - return String.join("\n", Files.readAllLines(path)); + return String.join("\n", Files.readAllLines(path, StandardCharsets.UTF_8)); } public static ITree toGumTree(String clazz) {