diff --git a/markdown/build.gradle.kts b/markdown/build.gradle.kts index 9b00118..b5e7527 100644 --- a/markdown/build.gradle.kts +++ b/markdown/build.gradle.kts @@ -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") diff --git a/markdown/src/main/kotlin/com/appmattus/markdown/filter/SinglePathFilter.kt b/markdown/src/main/kotlin/com/appmattus/markdown/filter/SinglePathFilter.kt index 1577035..1028ed4 100644 --- a/markdown/src/main/kotlin/com/appmattus/markdown/filter/SinglePathFilter.kt +++ b/markdown/src/main/kotlin/com/appmattus/markdown/filter/SinglePathFilter.kt @@ -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) } } diff --git a/markdown/src/main/kotlin/com/appmattus/markdown/processing/RuleProcessor.kt b/markdown/src/main/kotlin/com/appmattus/markdown/processing/RuleProcessor.kt index 612c76b..a7c11c6 100644 --- a/markdown/src/main/kotlin/com/appmattus/markdown/processing/RuleProcessor.kt +++ b/markdown/src/main/kotlin/com/appmattus/markdown/processing/RuleProcessor.kt @@ -121,7 +121,9 @@ class RuleProcessor(private val rootDir: Path, private val reportsDir: Path) { Files.walkFileTree(this, object : SimpleFileVisitor() { 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 diff --git a/markdown/src/test/kotlin/com/appmattus/markdown/plugin/MarkdownLintPluginTest.kt b/markdown/src/test/kotlin/com/appmattus/markdown/plugin/MarkdownLintPluginTest.kt index 31fbea3..e5eb47e 100644 --- a/markdown/src/test/kotlin/com/appmattus/markdown/plugin/MarkdownLintPluginTest.kt +++ b/markdown/src/test/kotlin/com/appmattus/markdown/plugin/MarkdownLintPluginTest.kt @@ -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 } diff --git a/markdown/src/test/kotlin/com/appmattus/markdown/processing/RuleProcessorTest.kt b/markdown/src/test/kotlin/com/appmattus/markdown/processing/RuleProcessorTest.kt index 2bf5b1d..2a6883b 100644 --- a/markdown/src/test/kotlin/com/appmattus/markdown/processing/RuleProcessorTest.kt +++ b/markdown/src/test/kotlin/com/appmattus/markdown/processing/RuleProcessorTest.kt @@ -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 @@ -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) diff --git a/markdown/src/test/kotlin/com/appmattus/markdown/rules/Files.kt b/markdown/src/test/kotlin/com/appmattus/markdown/rules/Files.kt index a429fad..9a746e6 100644 --- a/markdown/src/test/kotlin/com/appmattus/markdown/rules/Files.kt +++ b/markdown/src/test/kotlin/com/appmattus/markdown/rules/Files.kt @@ -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", diff --git a/markdown/src/test/resources/header_mutliple_h1_no_toplevel.md b/markdown/src/test/resources/header_multiple_h1_no_toplevel.md similarity index 100% rename from markdown/src/test/resources/header_mutliple_h1_no_toplevel.md rename to markdown/src/test/resources/header_multiple_h1_no_toplevel.md diff --git a/settings.gradle.kts b/settings.gradle.kts index c7dd1af..17d84f9 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,3 +1,5 @@ +rootProject.name = "markdown-lint" + include( "markdown" )