Skip to content
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
1 change: 1 addition & 0 deletions markdown/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dependencies {
testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0")
testImplementation("com.flextrade.jfixture:jfixture:2.7.2")
testImplementation("io.github.classgraph:classgraph:4.8.95")
testImplementation("com.google.jimfs:jimfs:1.1")

testImplementation("org.spekframework.spek2:spek-dsl-jvm:2.0.15")
testRuntimeOnly("org.spekframework.spek2:spek-runner-junit5:2.0.15")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SinglePathFilter(
}

override fun matches(path: Path): Boolean {
val relativePath = Paths.get(".").resolve(root.relativize(path).normalize())
val relativePath = path.fileSystem.getPath(".").resolve(root.relativize(path).normalize())
return matcher.matches(relativePath)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ class RuleProcessor(private val rootDir: Path, private val reportsDir: Path) {

Files.walkFileTree(this, object : SimpleFileVisitor<Path>() {
override fun preVisitDirectory(dir: Path, attrs: BasicFileAttributes): FileVisitResult {
return if (dir.fileName.toString() == "build" || dir.fileName.toString().startsWith(".")) {
/* The fileName component is null if the dir is the root of the filesystem. */
return if (dir.fileName != null &&
(dir.fileName.toString() == "build" || dir.fileName.toString().startsWith("."))) {
FileVisitResult.SKIP_SUBTREE
} else {
FileVisitResult.CONTINUE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,13 @@ private fun InputStream.toFile(file: File) {
}

private fun GradleRunner.withJaCoCo(): GradleRunner {
javaClass.classLoader.getResourceAsStream("testkit-gradle.properties").toFile(File(projectDir, "gradle.properties"))
/*
* When running under Windows, the forked Gradle VM will linger briefly and keep
* some files open, which interferes with Gradle snapshotting. As long as some
* OS runs JaCoCo coverage for statistics, it is good enough.
*/
if (!System.getProperty("os.name").toLowerCase().contains("win")) {
javaClass.classLoader.getResourceAsStream("testkit-gradle.properties").toFile(File(projectDir, "gradle.properties"))
}
return this
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.appmattus.markdown.processing

import com.appmattus.markdown.dsl.Config
import com.appmattus.markdown.plugin.MarkdownLint
import com.google.common.jimfs.Jimfs
import org.assertj.core.api.Assertions.assertThat
import org.junit.rules.TemporaryFolder
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.gherkin.Feature
import java.io.ByteArrayOutputStream
Expand All @@ -19,18 +19,20 @@ object RuleProcessorTest : Spek({
}

Feature("RuleProcessor") {
val temporaryFolder by memoized {
TemporaryFolder().apply {
create()
}
val fileSystem by memoized {
Jimfs.newFileSystem()
}

val rootDir by memoized {
temporaryFolder.newFolder("rootDir").toPath()
fileSystem.getPath("rootDir").also {
Files.createDirectories(it)
}
}

val reportsDir by memoized {
temporaryFolder.newFolder("reportsDir").toPath()
fileSystem.getPath("reportsDir").also {
Files.createDirectories(it)
}
}

val slash = Regex.escape(File.separator)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ val allFiles = listOf(
"header_duplicate_content_different_nesting.md",
"header_duplicate_content_no_different_nesting.md",
"header_multiple_toplevel.md",
"header_mutliple_h1_no_toplevel.md",
"header_multiple_h1_no_toplevel.md",
"header_trailing_punctuation.md",
"header_trailing_punctuation_customized.md",
"headers_bad.md",
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
rootProject.name = "markdown-lint"

include(
"markdown"
)