Skip to content

Commit

Permalink
Make baseline platform agnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
joshafeinberg committed Feb 28, 2020
1 parent 75deea3 commit c48f9c7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BaselineReporter(val out: PrintStream) : Reporter {
out.println("""<baseline version="1.0">""")
for ((file, errList) in acc.entries.sortedBy { it.key }) {
val fileName = try {
Paths.get("").toAbsolutePath().relativize(File(file).toPath()).toString()
Paths.get("").toAbsolutePath().relativize(File(file).toPath()).toString().replace('\\', '/')
} catch (e: IllegalArgumentException) {
file
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ internal fun List<LintError>.containsLintError(error: LintError): Boolean {

/**
* Gets the relative route of the file for baselines
* Also adjusts the slashes for uniformity between file systems
*/
internal val File.relativeRoute: String
get() = Paths.get("").toAbsolutePath().relativize(this.toPath()).toString()
get() = Paths.get("").toAbsolutePath().relativize(this.toPath()).toString().replace('\\', '/')
4 changes: 2 additions & 2 deletions ktlint/src/test/resources/test-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<baseline version="1.0">
<file name="src\test\resources\TestBaselineFile.kt">
<file name="src/test/resources/TestBaselineFile.kt">
<error line="1" column="24" source="no-empty-class-body" />
<error line="2" column="1" source="no-blank-line-before-rbrace" />
</file>
<file name="src\test\resources\TestBaselineExtraErrorFile.kt">
<file name="src/test/resources/TestBaselineExtraErrorFile.kt">
<error line="1" column="24" source="no-empty-class-body" />
</file>
</baseline>

0 comments on commit c48f9c7

Please sign in to comment.