From e7c912927074d72c30c211aea85e3724b151e29f Mon Sep 17 00:00:00 2001 From: Matej Trakal Date: Sun, 28 Jul 2024 21:56:02 +0200 Subject: [PATCH] Fix imports in tests, fix line separator --- plugin/config/ktlint/baseline.xml | 8 ++------ plugin/detekt-baseline.xml | 2 ++ .../graph/assertion/FullProjectGradleTest.kt | 12 ++++-------- .../FullProjectMultipleAppliedGradleTest.kt | 15 ++++++--------- .../graph/assertion/FullProjectRootGradleTest.kt | 8 ++++---- 5 files changed, 18 insertions(+), 27 deletions(-) diff --git a/plugin/config/ktlint/baseline.xml b/plugin/config/ktlint/baseline.xml index 70acc0f..c157974 100644 --- a/plugin/config/ktlint/baseline.xml +++ b/plugin/config/ktlint/baseline.xml @@ -1,10 +1,6 @@ - - - - - - + + diff --git a/plugin/detekt-baseline.xml b/plugin/detekt-baseline.xml index 41da1be..5390e9c 100644 --- a/plugin/detekt-baseline.xml +++ b/plugin/detekt-baseline.xml @@ -3,6 +3,8 @@ LongMethod:DependencyGraphTest.kt$DependencyGraphTest$@Test fun countsStatisticsWell() + MaxLineLength:FullProjectMultipleAppliedGradleTest.kt$FullProjectMultipleAppliedGradleTest$"GraphStatistics(modulesCount=3, edgesCount=3, height=2, longestPath=':app -> :core -> :core-api')${System.lineSeparator()}" + MaxLineLength:FullProjectRootGradleTest.kt$FullProjectRootGradleTest$"GraphStatistics\\(modulesCount=1, edgesCount=0, height=0, longestPath=\'root.*\'\\)${System.lineSeparator()}${System.lineSeparator()}" MaxLineLength:ModuleTreeHeightAssert.kt$ModuleTreeHeightAssert$"Module $moduleName is allowed to have maximum height of $maxHeight, but has $height, problematic dependencies: ${longestPath.pathString()}" MaxLineLength:ModuleTreeHeightAssert.kt$ModuleTreeHeightAssert$"Module Graph is allowed to have maximum height of $maxHeight, but has $height, problematic dependencies: ${longestPath.pathString()}" MaxLineLength:OnAnyBuildAssertTest.kt$OnAnyBuildAssertTest$"""["App"(':app') -> "Implementation"(':core'), "App"(':app') -> "Implementation"(':feature')] not allowed by any of ['Implementation -> Api', 'App -> Api']""" diff --git a/plugin/src/test/kotlin/com/jraska/module/graph/assertion/FullProjectGradleTest.kt b/plugin/src/test/kotlin/com/jraska/module/graph/assertion/FullProjectGradleTest.kt index 3854797..068c8de 100644 --- a/plugin/src/test/kotlin/com/jraska/module/graph/assertion/FullProjectGradleTest.kt +++ b/plugin/src/test/kotlin/com/jraska/module/graph/assertion/FullProjectGradleTest.kt @@ -1,7 +1,5 @@ package com.jraska.module.graph.assertion -import org.hamcrest.CoreMatchers -import org.hamcrest.MatcherAssert import org.junit.Before import org.junit.Rule import org.junit.Test @@ -129,9 +127,8 @@ class FullProjectGradleTest { "-Pmodules.graph.of.module=:feature", ).output - MatcherAssert.assertThat( - output, - CoreMatchers.containsString( + assert( + output.contains( "digraph G {\n" + "\":feature('Implementation')\" -> \":core-api('Api')\" [color=red style=bold]\n" + "}", @@ -148,9 +145,8 @@ class FullProjectGradleTest { "-Pmodules.graph.of.module=:feature", ).output - MatcherAssert.assertThat( - output, - CoreMatchers.containsString( + assert( + output.contains( "GraphStatistics(modulesCount=2, edgesCount=1, height=1, longestPath=':feature -> :core-api')", ), ) diff --git a/plugin/src/test/kotlin/com/jraska/module/graph/assertion/FullProjectMultipleAppliedGradleTest.kt b/plugin/src/test/kotlin/com/jraska/module/graph/assertion/FullProjectMultipleAppliedGradleTest.kt index 101e132..c2e45c8 100644 --- a/plugin/src/test/kotlin/com/jraska/module/graph/assertion/FullProjectMultipleAppliedGradleTest.kt +++ b/plugin/src/test/kotlin/com/jraska/module/graph/assertion/FullProjectMultipleAppliedGradleTest.kt @@ -1,7 +1,5 @@ package com.jraska.module.graph.assertion -import org.hamcrest.CoreMatchers -import org.hamcrest.MatcherAssert import org.junit.Before import org.junit.Rule import org.junit.Test @@ -76,13 +74,12 @@ class FullProjectMultipleAppliedGradleTest { runGradleAssertModuleGraph(testProjectDir.root, "generateModulesGraphStatistics").output println(output) - MatcherAssert.assertThat( - output, - CoreMatchers.containsString( - "> Task :app:generateModulesGraphStatistics\n" + - "GraphStatistics(modulesCount=3, edgesCount=3, height=2, longestPath=':app -> :core -> :core-api')\n" + - "\n" + - "> Task :no-dependencies:generateModulesGraphStatistics\n" + + assert( + output.contains( + "> Task :app:generateModulesGraphStatistics${System.lineSeparator()}" + + "GraphStatistics(modulesCount=3, edgesCount=3, height=2, longestPath=':app -> :core -> :core-api')${System.lineSeparator()}" + + "${System.lineSeparator()}" + + "> Task :no-dependencies:generateModulesGraphStatistics${System.lineSeparator()}" + "GraphStatistics(modulesCount=1, edgesCount=0, height=0, longestPath=':no-dependencies')", ), ) diff --git a/plugin/src/test/kotlin/com/jraska/module/graph/assertion/FullProjectRootGradleTest.kt b/plugin/src/test/kotlin/com/jraska/module/graph/assertion/FullProjectRootGradleTest.kt index 821026f..6990957 100644 --- a/plugin/src/test/kotlin/com/jraska/module/graph/assertion/FullProjectRootGradleTest.kt +++ b/plugin/src/test/kotlin/com/jraska/module/graph/assertion/FullProjectRootGradleTest.kt @@ -45,7 +45,7 @@ class FullProjectRootGradleTest { assert( output.contains( ( - "> Task :generateModulesGraphStatistics\n.*" + + "> Task :generateModulesGraphStatistics${System.lineSeparator()}.*" + "GraphStatistics\\(modulesCount=2, edgesCount=1, height=1, longestPath=\'root.* -> :core\'\\)" ).toRegex(), ), @@ -91,9 +91,9 @@ class FullProjectRootGradleTest { assert( output.contains( ( - "> Task :generateModulesGraphStatistics\n.*" + - "GraphStatistics\\(modulesCount=1, edgesCount=0, height=0, longestPath=\'root.*\'\\)\n\n" + - "> Task :app:generateModulesGraphStatistics\n+" + + "> Task :generateModulesGraphStatistics${System.lineSeparator()}.*" + + "GraphStatistics\\(modulesCount=1, edgesCount=0, height=0, longestPath=\'root.*\'\\)${System.lineSeparator()}${System.lineSeparator()}" + + "> Task :app:generateModulesGraphStatistics${System.lineSeparator()}+" + "GraphStatistics\\(modulesCount=1, edgesCount=0, height=0, longestPath=\':app\'\\)" ).toRegex(), ),