From e8caeb65e2373217b440702766d546b988b10702 Mon Sep 17 00:00:00 2001 From: sanyavertolet Date: Fri, 22 Oct 2021 17:25:31 +0300 Subject: [PATCH 01/14] feature/ignoreLines ###What's done: * Added ignoreLines option for Fix plugin. * Added tests for ignoreLines and Fix plugin. * Added ignoreLines option for Warn plugin. * Added tests for ignoreLines and Warn plugin. * Implemented copying a file in Warn plugin in order to filter out lines that match any regex from ignoreLines. (#303) --- .../IgnoreLines/Bug1Expected.kt | 21 ++++++++++ .../IgnoreLinesTest/IgnoreLines/Bug1Test.kt | 11 +++++ .../IgnoreLinesTest/IgnoreLines/save.toml | 7 ++++ .../IgnoreLinesIsEmpty/Bug1Expected.kt | 22 ++++++++++ .../IgnoreLinesIsEmpty/Bug1Test.kt | 11 +++++ .../IgnoreLinesIsEmpty/save.toml | 7 ++++ .../NoIgnoreLines/Bug1Expected.kt | 21 ++++++++++ .../IgnoreLinesTest/NoIgnoreLines/Bug1Test.kt | 11 +++++ .../IgnoreLinesTest/NoIgnoreLines/save.toml | 6 +++ .../kotlin/org/cqfn/save/chapter1/save.toml | 6 +++ examples/kotlin-diktat/save.toml | 4 +- .../IgnoreLinesTest/EnumTestDetection.kt | 16 +++++++ .../warn/chapter1/IgnoreLinesTest/save.toml | 7 ++++ examples/kotlin-diktat/warn/save.toml | 2 +- .../org/cqfn/save/core/plugin/Plugin.kt | 9 ++++ .../org/cqfn/save/core/plugin/PluginConfig.kt | 17 ++++++-- .../save/core/integration/ClassicFixTest.kt | 37 +++++++++++++++- .../save/core/integration/ClassicWarnTest.kt | 14 +++++-- .../plugins/fixandwarn/FixAndWarnPlugin.kt | 1 - .../fixandwarn/FixAndWarnPluginConfig.kt | 14 ++++++- .../org/cqfn/save/plugins/fix/FixPlugin.kt | 28 ++++++++++--- .../cqfn/save/plugins/fix/FixPluginConfig.kt | 24 +++++++++-- .../org/cqfn/save/plugin/warn/WarnPlugin.kt | 42 +++++++++++++------ .../cqfn/save/plugin/warn/WarnPluginConfig.kt | 17 +++++++- 24 files changed, 316 insertions(+), 39 deletions(-) create mode 100644 examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/Bug1Expected.kt create mode 100644 examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/Bug1Test.kt create mode 100644 examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/save.toml create mode 100644 examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty/Bug1Expected.kt create mode 100644 examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty/Bug1Test.kt create mode 100644 examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty/save.toml create mode 100644 examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines/Bug1Expected.kt create mode 100644 examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines/Bug1Test.kt create mode 100644 examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines/save.toml create mode 100644 examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/chapter1/save.toml create mode 100644 examples/kotlin-diktat/warn/chapter1/IgnoreLinesTest/EnumTestDetection.kt create mode 100644 examples/kotlin-diktat/warn/chapter1/IgnoreLinesTest/save.toml diff --git a/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/Bug1Expected.kt b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/Bug1Expected.kt new file mode 100644 index 000000000..f485b861a --- /dev/null +++ b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/Bug1Expected.kt @@ -0,0 +1,21 @@ +package org.cqfn.save.IgnoreLinesTest.IgnoreLines + +class D { + val x = 0 + + /** + * @return + */ + fun bar(): Bar { + val qux = 42 + return Bar(qux) + } +} + +/** + * @param foo + */ +fun readFile(foo: Foo) { + var bar: Bar +} +// ;warn:0: [TEST] JUST_A_TEST diff --git a/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/Bug1Test.kt b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/Bug1Test.kt new file mode 100644 index 000000000..7a21be2ad --- /dev/null +++ b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/Bug1Test.kt @@ -0,0 +1,11 @@ +package test.smoke.src.main.kotlin + +fun readFile(foo: Foo) { + var bar: Bar +} + +class D {val x = 0 +fun bar(): Bar {val qux = 42; return Bar(qux)} +} +// ;warn:0: [TEST] JUST_A_TEST +// IGNORE_ME diff --git a/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/save.toml b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/save.toml new file mode 100644 index 000000000..883e10015 --- /dev/null +++ b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/save.toml @@ -0,0 +1,7 @@ +[general] + tags = ["FixIgnoreLines"] + description = "Test for ignoreLines option in Fix" + suiteName = "Autofix: Smoke Tests" + +[fix] + ignoreLines = ["// IGNORE_ME"] \ No newline at end of file diff --git a/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty/Bug1Expected.kt b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty/Bug1Expected.kt new file mode 100644 index 000000000..43a982386 --- /dev/null +++ b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty/Bug1Expected.kt @@ -0,0 +1,22 @@ +package org.cqfn.save.IgnoreLinesTest.IgnoreLinesIsEmpty + +class D { + val x = 0 + + /** + * @return + */ + fun bar(): Bar { + val qux = 42 + return Bar(qux) + } +} + +/** + * @param foo + */ +fun readFile(foo: Foo) { + var bar: Bar +} +// ;warn:0: [TEST] JUST_A_TEST +// IGNORE_ME diff --git a/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty/Bug1Test.kt b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty/Bug1Test.kt new file mode 100644 index 000000000..7a21be2ad --- /dev/null +++ b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty/Bug1Test.kt @@ -0,0 +1,11 @@ +package test.smoke.src.main.kotlin + +fun readFile(foo: Foo) { + var bar: Bar +} + +class D {val x = 0 +fun bar(): Bar {val qux = 42; return Bar(qux)} +} +// ;warn:0: [TEST] JUST_A_TEST +// IGNORE_ME diff --git a/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty/save.toml b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty/save.toml new file mode 100644 index 000000000..12f77b199 --- /dev/null +++ b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty/save.toml @@ -0,0 +1,7 @@ +[general] + tags = ["smoke"] + description = "Smoke tests for diktat" + suiteName = "Autofix: Smoke Tests" + +[fix] + ignoreLines = [] \ No newline at end of file diff --git a/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines/Bug1Expected.kt b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines/Bug1Expected.kt new file mode 100644 index 000000000..50c4220cf --- /dev/null +++ b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines/Bug1Expected.kt @@ -0,0 +1,21 @@ +package org.cqfn.save.IgnoreLinesTest.NoIgnoreLines + +class D { + val x = 0 + + /** + * @return + */ + fun bar(): Bar { + val qux = 42 + return Bar(qux) + } +} + +/** + * @param foo + */ +fun readFile(foo: Foo) { + var bar: Bar +} +// IGNORE_ME diff --git a/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines/Bug1Test.kt b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines/Bug1Test.kt new file mode 100644 index 000000000..7a21be2ad --- /dev/null +++ b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines/Bug1Test.kt @@ -0,0 +1,11 @@ +package test.smoke.src.main.kotlin + +fun readFile(foo: Foo) { + var bar: Bar +} + +class D {val x = 0 +fun bar(): Bar {val qux = 42; return Bar(qux)} +} +// ;warn:0: [TEST] JUST_A_TEST +// IGNORE_ME diff --git a/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines/save.toml b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines/save.toml new file mode 100644 index 000000000..f4d6312e1 --- /dev/null +++ b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines/save.toml @@ -0,0 +1,6 @@ +[general] + tags = ["smoke"] + description = "Smoke tests for diktat" + suiteName = "Autofix: Smoke Tests" + +[fix] \ No newline at end of file diff --git a/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/chapter1/save.toml b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/chapter1/save.toml new file mode 100644 index 000000000..f4d6312e1 --- /dev/null +++ b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/chapter1/save.toml @@ -0,0 +1,6 @@ +[general] + tags = ["smoke"] + description = "Smoke tests for diktat" + suiteName = "Autofix: Smoke Tests" + +[fix] \ No newline at end of file diff --git a/examples/kotlin-diktat/save.toml b/examples/kotlin-diktat/save.toml index bba0d5572..a1911acad 100644 --- a/examples/kotlin-diktat/save.toml +++ b/examples/kotlin-diktat/save.toml @@ -2,6 +2,4 @@ execCmd = "java -jar ktlint -R diktat.jar" description = "Test for diktat - linter and formatter for Kotlin" # this is the default value, you don't need to add it explicitly, but can be useful, if you have different pattern: - expectedWarningsPattern = "// ;warn:?(.*):(\\d*): (.+)" - - + expectedWarningsPattern = "// ;warn:?(.*):(\\d*): (.+)" \ No newline at end of file diff --git a/examples/kotlin-diktat/warn/chapter1/IgnoreLinesTest/EnumTestDetection.kt b/examples/kotlin-diktat/warn/chapter1/IgnoreLinesTest/EnumTestDetection.kt new file mode 100644 index 000000000..1ef8decb8 --- /dev/null +++ b/examples/kotlin-diktat/warn/chapter1/IgnoreLinesTest/EnumTestDetection.kt @@ -0,0 +1,16 @@ +package org.cqfn.diktat.test.resources.test.paragraph1.naming.enum_ + +// ;warn:3:1: [MISSING_KDOC_TOP_LEVEL] all public and internal top-level classes and functions should have Kdoc: EnumTestDetection (cannot be auto-corrected) +// ;warn:30: [WRONG_DECLARATIONS_ORDER] declarations of constants and enum members should be sorted alphabetically: enum entries order is incorrect +// ;warn:10:5: [ENUMS_SEPARATED] enum is incorrectly formatted: enums must end with semicolon +enum class EnumTestDetection { + // ;warn:$line+1:5: [ENUM_VALUE] enum values should be{{ in }}selected UPPER_CASE snake/PascalCase format: paSC_SAl_l + paSC_SAl_l, + + // ;warn:5: [ENUM_VALUE] enum values{{ should }}be in selected{{ UPPER_CASE }}snake/PascalCase format: PascAsl_f + PascAsl_f + // ;warn:$line-2:5: [ENUMS_SEPARATED] enum is incorrectly formatted: last enum entry must end with a comma + + // ;warn:1:9: {{.*}}[PACKAGE_NAME_INCORRECT_PREFIX] package name should start from company's domain: org.cqfn.save{{.*}} +} +// ;warn:0:0: [YOU SHOULD NOT SEE THIS] this warning should not be shown diff --git a/examples/kotlin-diktat/warn/chapter1/IgnoreLinesTest/save.toml b/examples/kotlin-diktat/warn/chapter1/IgnoreLinesTest/save.toml new file mode 100644 index 000000000..bc6f5d8a8 --- /dev/null +++ b/examples/kotlin-diktat/warn/chapter1/IgnoreLinesTest/save.toml @@ -0,0 +1,7 @@ +[general] + tags = ["WarnIgnoreLines"] + description = "Test suite that checks if filtering by regex work." + +[warn] + testNameRegex = "^E.*T.*D.*" + ignoreLines = [".*// ;warn:0:0: \\[YOU SHOULD NOT SEE THIS\\] this warning should not be shown.*"] \ No newline at end of file diff --git a/examples/kotlin-diktat/warn/save.toml b/examples/kotlin-diktat/warn/save.toml index 71959f39a..5089cbc9e 100644 --- a/examples/kotlin-diktat/warn/save.toml +++ b/examples/kotlin-diktat/warn/save.toml @@ -17,4 +17,4 @@ messageCaptureGroupOut = 4 exactWarningsMatch = false warningTextHasColumn = true - warningTextHasLine = true + warningTextHasLine = true \ No newline at end of file diff --git a/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/Plugin.kt b/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/Plugin.kt index 4508796bf..33b003c87 100644 --- a/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/Plugin.kt +++ b/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/Plugin.kt @@ -80,6 +80,15 @@ abstract class Plugin( */ abstract fun handleFiles(files: Sequence): Sequence + /** + * Method, which filters out all the strings that match any pattern from ignoreLinesPatterns, creating a new file + * + * @param path to source file + * @param pluginConfig - setting of a plugin + * @return list of [String]s, each of which doesn't match any pattern + */ + //abstract fun createTestFile(path: Path, pluginConfig: PluginConfig): Path + /** * Discover groups of resource files which will be used to run tests, applying additional filtering * for execution of individual tests. diff --git a/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/PluginConfig.kt b/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/PluginConfig.kt index 5f36b46d8..7a35504f2 100644 --- a/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/PluginConfig.kt +++ b/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/PluginConfig.kt @@ -25,6 +25,11 @@ interface PluginConfig { */ val type: TestConfigSections + /** + * list of regexes to be ignored + */ + var ignoreLinesPatterns: MutableList + /** * Location of the toml config */ @@ -70,6 +75,8 @@ data class GeneralConfig( ) : PluginConfig { override val type = TestConfigSections.GENERAL + override var ignoreLinesPatterns: MutableList = mutableListOf() + @Transient override var configLocation: Path = "undefined_toml_location".toPath() @@ -88,8 +95,10 @@ data class GeneralConfig( this.suiteName ?: other.suiteName, this.excludedTests ?: other.excludedTests, this.expectedWarningsPattern ?: other.expectedWarningsPattern, - this.runConfigPattern ?: other.runConfigPattern, - ).also { it.configLocation = this.configLocation } + this.runConfigPattern ?: other.runConfigPattern + ).also { + it.configLocation = this.configLocation + } } override fun validateAndSetDefaults(): GeneralConfig { @@ -113,7 +122,9 @@ data class GeneralConfig( excludedTests ?: emptyList(), expectedWarningsPattern ?: defaultExpectedWarningPattern, runConfigPattern ?: defaultRunConfigPattern, - ).also { it.configLocation = this.configLocation } + ).also { + it.configLocation = this.configLocation + } } private fun errorMsgForRequireCheck(field: String) = diff --git a/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicFixTest.kt b/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicFixTest.kt index e6067fbf1..a1f4f986d 100644 --- a/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicFixTest.kt +++ b/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicFixTest.kt @@ -1,6 +1,7 @@ package org.cqfn.save.core.integration import org.cqfn.save.core.test.utils.runTestsWithDiktat +import kotlin.test.Ignore import kotlin.test.Test class ClassicFixTest { @@ -18,7 +19,7 @@ class ClassicFixTest { runTestsWithDiktat( listOf( "fix/save.toml" - ), 2 + ), 5 ) @Test @@ -26,6 +27,38 @@ class ClassicFixTest { runTestsWithDiktat( listOf( "fix/smoke/save.toml" - ), 2 + ), 5 ) + + @Test + fun `execute fix plugin on folder`() = + runTestsWithDiktat( + listOf( + "fix/smoke/src/main/kotlin/org/cqfn/save/" + ), 5 + ) + + @Test + fun `check NoIgnoreLines`() = + runTestsWithDiktat( + listOf( + "fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines" + ), 1 + ) + + @Test + fun `check IgnoreLinesIsEmpty`() = + runTestsWithDiktat( + listOf( + "fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty" + ), 1 + ) + + @Test + fun `check IgnoreLines`() = + runTestsWithDiktat( + listOf( + "fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines" + ), 1 + ) } diff --git a/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt b/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt index 9d3923a04..a36444f9e 100644 --- a/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt +++ b/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt @@ -38,7 +38,7 @@ class ClassicWarnTest { runTestsWithDiktat( listOf( "warn/chapter1" - ), 6 + ), 7 ) @Test @@ -49,6 +49,14 @@ class ClassicWarnTest { ), 1 ) + @Test + fun `lines that match ignoreLines should be ignored`() = + runTestsWithDiktat( + listOf( + "warn/chapter1/IgnoreLinesTest" + ), 1 + ) + @Test fun `test output file set`() = runTestsWithDiktat( @@ -73,7 +81,7 @@ class ClassicWarnTest { runTestsWithDiktat( listOf( "warn/save.toml" - ), 6 + ), 7 ) @Test @@ -81,7 +89,7 @@ class ClassicWarnTest { runTestsWithDiktat( listOf( "warn/chapter1/save.toml" - ), 6 + ), 7 ) @Test diff --git a/save-plugins/fix-and-warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fixandwarn/FixAndWarnPlugin.kt b/save-plugins/fix-and-warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fixandwarn/FixAndWarnPlugin.kt index f0293d547..65058a0fc 100644 --- a/save-plugins/fix-and-warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fixandwarn/FixAndWarnPlugin.kt +++ b/save-plugins/fix-and-warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fixandwarn/FixAndWarnPlugin.kt @@ -121,7 +121,6 @@ class FixAndWarnPlugin( files.forEach { file -> val fileData = fs.readLines(file) filesAndTheirWarningsMap[file] = mutableListOf() - val fileDataWithoutWarnings = fileData.filterIndexed { index, line -> val isLineWithWarning = (generalConfig.expectedWarningsPattern!!.find(line)?.groups != null) if (isLineWithWarning) { diff --git a/save-plugins/fix-and-warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fixandwarn/FixAndWarnPluginConfig.kt b/save-plugins/fix-and-warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fixandwarn/FixAndWarnPluginConfig.kt index 12fc24540..e8a1417c9 100644 --- a/save-plugins/fix-and-warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fixandwarn/FixAndWarnPluginConfig.kt +++ b/save-plugins/fix-and-warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fixandwarn/FixAndWarnPluginConfig.kt @@ -25,6 +25,9 @@ data class FixAndWarnPluginConfig( @Transient override var configLocation: Path = "undefined_toml_location".toPath() + @Transient + override var ignoreLinesPatterns: MutableList = defaultIgnoreLines + override fun mergeWith(otherConfig: PluginConfig): PluginConfig { val other = otherConfig as FixAndWarnPluginConfig val mergedFixPluginConfig = fix.mergeWith(other.fix) @@ -32,7 +35,9 @@ data class FixAndWarnPluginConfig( return FixAndWarnPluginConfig( mergedFixPluginConfig as FixPluginConfig, mergedWarnPluginConfig as WarnPluginConfig - ).also { it.configLocation = this.configLocation } + ).also { + it.configLocation = this.configLocation + } } override fun validateAndSetDefaults(): PluginConfig { @@ -48,6 +53,11 @@ data class FixAndWarnPluginConfig( return FixAndWarnPluginConfig( fix.validateAndSetDefaults(), warn.validateAndSetDefaults() - ).also { it.configLocation = this.configLocation } + ).also { + it.configLocation = this.configLocation + } + } + companion object { + internal val defaultIgnoreLines = mutableListOf() } } diff --git a/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt b/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt index eff15e35e..751f2a4e9 100644 --- a/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt +++ b/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt @@ -76,7 +76,9 @@ class FixPlugin( val extraFlags = extraFlagsList.singleOrNull() ?: ExtraFlags("", "") val pathMap = chunk.map { it.test to it.expected } - val pathCopyMap = pathMap.map { (test, expected) -> createTestFile(test, generalConfig) to expected } + val pathCopyMap = pathMap.map { + (test, expected) -> createTestFile(test, generalConfig, fixPluginConfig) to expected + } val testCopyNames = pathCopyMap.joinToString(separator = fixPluginConfig.batchSeparator!!) { (testCopy, _) -> testCopy.toString() } @@ -127,20 +129,34 @@ class FixPlugin( } } - private fun createTestFile(path: Path, generalConfig: GeneralConfig): Path { + private fun createTestFile(path: Path, generalConfig: GeneralConfig, fixPluginConfig: FixPluginConfig): Path { val pathCopy: Path = constructPathForCopyOfTestFile(FixPlugin::class.simpleName!!, path) createTempDir(pathCopy.parent!!) - val expectedWarningPattern = generalConfig.expectedWarningsPattern + val defaultIgnoreLinesPatterns = mutableListOf() + // fixme: make it more kotlin + if (generalConfig.expectedWarningsPattern != null) { + defaultIgnoreLinesPatterns.add(generalConfig.expectedWarningsPattern!!) + } + // fixme: and this if as well + if (generalConfig.runConfigPattern != null) { + defaultIgnoreLinesPatterns.add(generalConfig.runConfigPattern!!) + } fs.write(fs.createFile(pathCopy)) { - fs.readLines(path).forEach { - if (expectedWarningPattern == null || !generalConfig.expectedWarningsPattern!!.matches(it)) { + fs.readLines(path) + .filter { line -> + if (fixPluginConfig.ignoreLines == null) { + defaultIgnoreLinesPatterns.none {regex -> regex.matches(line)} + } else { + fixPluginConfig.ignoreLinesPatterns.none { pattern -> pattern.matches(line) } + } + } + .forEach { write( (it + "\n").encodeToByteArray() ) } - } } return pathCopy } diff --git a/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPluginConfig.kt b/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPluginConfig.kt index fd9ddd1c1..8ca987e30 100644 --- a/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPluginConfig.kt +++ b/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPluginConfig.kt @@ -12,6 +12,8 @@ import okio.Path.Companion.toPath import kotlinx.serialization.Serializable import kotlinx.serialization.Transient import kotlinx.serialization.UseSerializers +import org.cqfn.save.core.logging.logDebug +import org.cqfn.save.core.logging.logError /** * Some fields by default are null, instead of some natural value, because of the fact, that in stage of merging @@ -31,12 +33,16 @@ data class FixPluginConfig( val batchSeparator: String? = null, val resourceNameTestSuffix: String? = null, val resourceNameExpectedSuffix: String? = null, + val ignoreLines: MutableList? = null ) : PluginConfig { override val type = TestConfigSections.FIX @Transient override var configLocation: Path = "undefined_toml_location".toPath() + @Transient + override var ignoreLinesPatterns: MutableList = ignoreLines?.map{ it.toRegex() }?.toMutableList() ?: defaultIgnoreLines + /** * @property resourceNameTest */ @@ -60,14 +66,26 @@ data class FixPluginConfig( this.batchSeparator ?: other.batchSeparator, this.resourceNameTestSuffix ?: other.resourceNameTestSuffix, this.resourceNameExpectedSuffix ?: other.resourceNameExpectedSuffix, - ).also { it.configLocation = this.configLocation } + other.ignoreLines?.let { + this.ignoreLines?.let { other.ignoreLines.union(this.ignoreLines) } ?: other.ignoreLines + } ?.toMutableList() ?: this.ignoreLines + ).also { + it.configLocation = this.configLocation + } } + // due to probable bug in ktoml, ignoreLines = [] and no ignoreLines is ktoml are parsed to be mutableListOf("null") override fun validateAndSetDefaults() = FixPluginConfig( execFlags ?: "", batchSize ?: 1, batchSeparator ?: ", ", resourceNameTest, - resourceNameExpected - ).also { it.configLocation = this.configLocation } + resourceNameExpected, + ignoreLines?.filter { it != "null" }?.toMutableList() ?: ignoreLines + ).also { + it.configLocation = this.configLocation + } + companion object { + internal val defaultIgnoreLines = mutableListOf() + } } diff --git a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt index cd5c779f3..0616c5d68 100644 --- a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt +++ b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt @@ -22,6 +22,8 @@ import org.cqfn.save.plugin.warn.utils.getLineNumber import okio.FileNotFoundException import okio.FileSystem import okio.Path +import org.cqfn.save.core.files.createFile +import org.cqfn.save.core.logging.logError private typealias WarningMap = Map> @@ -81,6 +83,22 @@ class WarnPlugin( } } + private fun createTestFile(path: Path, warnPluginConfig: WarnPluginConfig): Path { + val pathCopy: Path = constructPathForCopyOfTestFile(WarnPlugin::class.simpleName!!, path) + createTempDir(pathCopy.parent!!) + + val ignorePatterns = warnPluginConfig.ignoreLinesPatterns + + fs.write(fs.createFile(pathCopy)) { + fs.readLines(path) + .filter { line -> + ignorePatterns.none { pattern -> pattern.matches(line) } + } + .map { write((it + "\n").encodeToByteArray()) } + } + return pathCopy + } + @Suppress( "TOO_LONG_FUNCTION", "SAY_NO_TO_VAR", @@ -93,12 +111,13 @@ class WarnPlugin( generalConfig: GeneralConfig ): Sequence { // extracting all warnings from test resource files - val expectedWarningsMap: WarningMap = paths.associate { + val copyPaths: List = paths.map { path -> createTestFile(path, warnPluginConfig) } + val expectedWarningsMap: WarningMap = copyPaths.associate { val warningsForCurrentPath = it.collectWarningsWithLineNumbers(warnPluginConfig, generalConfig) it.name to warningsForCurrentPath } - val extraFlagsList = paths.mapNotNull { path -> + val extraFlagsList = copyPaths.mapNotNull { path -> extraFlagsExtractor.extractExtraFlagsFrom(path) } .distinct() @@ -121,23 +140,17 @@ class WarnPlugin( // NOTE: SAVE will pass relative paths of Tests (calculated from testRootConfig dir) into the executed tool val fileNamesForExecCmd = warnPluginConfig.wildCardInDirectoryMode?.let { - val directoryPrefix = testConfig - .directory - .createRelativePathToTheRoot(testConfig.getRootConfig().location) // a hack to put only the directory path to the execution command // only in case a directory mode is enabled - "$directoryPrefix$it" - } ?: paths.joinToString(separator = warnPluginConfig.batchSeparator!!) { - it.createRelativePathToTheRoot(testConfig.getRootConfig().location) - } - + "${copyPaths[0].parent!!}$it" + } ?: copyPaths.joinToString(separator = warnPluginConfig.batchSeparator!!) val execFlagsAdjusted = resolvePlaceholdersFrom(warnPluginConfig.execFlags, extraFlags, fileNamesForExecCmd) val execCmd = "${generalConfig.execCmd} $execFlagsAdjusted" val executionResult = try { pb.exec(execCmd, testConfig.getRootConfig().directory.toString(), redirectTo) } catch (ex: ProcessExecutionException) { - return paths.map { + return copyPaths.map { TestResult( Test(it), Fail(ex.describe(), ex.describe()), @@ -145,6 +158,7 @@ class WarnPlugin( ) }.asSequence() } + val stdout = warnPluginConfig.testToolResFileOutput?.let { val testToolResFilePath = testConfig.directory / warnPluginConfig.testToolResFileOutput @@ -161,7 +175,8 @@ class WarnPlugin( } val stderr = executionResult.stderr - val actualWarningsMap = stdout.mapNotNull { + val actualWarningsMap = stdout + .mapNotNull { with(warnPluginConfig) { val line = it.getLineNumber(actualWarningsPattern!!, lineCaptureGroupOut) it.extractWarning( @@ -208,7 +223,8 @@ class WarnPlugin( generalConfig: GeneralConfig ): List { val linesFile = fs.readLines(this) - return linesFile.mapIndexed { index, line -> + return linesFile + .mapIndexed { index, line -> val newLine = line.getLineNumber( generalConfig.expectedWarningsPattern!!, warnPluginConfig.lineCaptureGroup, diff --git a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt index c5d6977f4..edf76f1f7 100644 --- a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt +++ b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt @@ -72,6 +72,7 @@ data class WarnPluginConfig( val patternForRegexInWarning: List? = null, val partialWarnTextMatch: Boolean? = null, val testToolResFileOutput: String? = null, + val ignoreLines: MutableList? = null ) : PluginConfig { @Transient override val type = TestConfigSections.WARN @@ -79,6 +80,9 @@ data class WarnPluginConfig( @Transient override var configLocation: Path = "undefined_toml_location".toPath() + @Transient + override var ignoreLinesPatterns: MutableList = ignoreLines?.map{ it.toRegex() }?.toMutableList() ?: defaultIgnoreLines + /** * regex for name of the test file. */ @@ -113,7 +117,12 @@ data class WarnPluginConfig( this.patternForRegexInWarning ?: other.patternForRegexInWarning, this.partialWarnTextMatch ?: other.partialWarnTextMatch, this.testToolResFileOutput ?: other.testToolResFileOutput, - ).also { it.configLocation = this.configLocation } + other.ignoreLines?.let { + this.ignoreLines?.let { other.ignoreLines.union(this.ignoreLines) } ?: other.ignoreLines + } ?.toMutableList() ?: this.ignoreLines + ).also { + it.configLocation = this.configLocation + } } @Suppress( @@ -169,7 +178,10 @@ data class WarnPluginConfig( patternForRegexInWarning ?: defaultPatternForRegexInWarning, partialWarnTextMatch ?: false, testToolResFileOutput, - ).also { it.configLocation = this.configLocation } + ignoreLines?.filter { it != "null" }?.toMutableList() ?: ignoreLines + ).also { + it.configLocation = this.configLocation + } } private fun requirePositiveIfNotNull(value: Long?) { @@ -202,5 +214,6 @@ data class WarnPluginConfig( */ internal val defaultOutputPattern = Regex("(.+):(\\d*):(\\d*): (.+)") internal val defaultPatternForRegexInWarning = listOf("{{", "}}") + internal val defaultIgnoreLines = mutableListOf() } } From f73884ea90598d4a7b283f110c599133b381fa39 Mon Sep 17 00:00:00 2001 From: sanyavertolet Date: Fri, 5 Nov 2021 11:58:42 +0300 Subject: [PATCH 02/14] feature/ignoreLines ###What's done: * Added ignoreLines option for Warn plugin. * Added tests for ignoreLines and Warn plugin. * Added ignoreLines option for Fix plugin. * Added tests for ignoreLines and Fix plugin. (#303) --- .../org/cqfn/save/core/plugin/Plugin.kt | 9 ---- .../org/cqfn/save/core/plugin/PluginConfig.kt | 1 - .../save/core/integration/ClassicFixTest.kt | 41 +++++++------- .../save/core/integration/ClassicWarnTest.kt | 10 ++-- .../fixandwarn/FixAndWarnPluginConfig.kt | 2 +- .../org/cqfn/save/plugins/fix/FixPlugin.kt | 28 +++++----- .../cqfn/save/plugins/fix/FixPluginConfig.kt | 9 ++-- .../org/cqfn/save/plugin/warn/WarnPlugin.kt | 54 +++++++++---------- .../cqfn/save/plugin/warn/WarnPluginConfig.kt | 7 +-- 9 files changed, 73 insertions(+), 88 deletions(-) diff --git a/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/Plugin.kt b/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/Plugin.kt index 33b003c87..4508796bf 100644 --- a/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/Plugin.kt +++ b/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/Plugin.kt @@ -80,15 +80,6 @@ abstract class Plugin( */ abstract fun handleFiles(files: Sequence): Sequence - /** - * Method, which filters out all the strings that match any pattern from ignoreLinesPatterns, creating a new file - * - * @param path to source file - * @param pluginConfig - setting of a plugin - * @return list of [String]s, each of which doesn't match any pattern - */ - //abstract fun createTestFile(path: Path, pluginConfig: PluginConfig): Path - /** * Discover groups of resource files which will be used to run tests, applying additional filtering * for execution of individual tests. diff --git a/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/PluginConfig.kt b/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/PluginConfig.kt index 7a35504f2..52a2e760d 100644 --- a/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/PluginConfig.kt +++ b/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/PluginConfig.kt @@ -74,7 +74,6 @@ data class GeneralConfig( val runConfigPattern: Regex? = null, ) : PluginConfig { override val type = TestConfigSections.GENERAL - override var ignoreLinesPatterns: MutableList = mutableListOf() @Transient diff --git a/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicFixTest.kt b/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicFixTest.kt index a1f4f986d..8386d8e0b 100644 --- a/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicFixTest.kt +++ b/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicFixTest.kt @@ -1,7 +1,6 @@ package org.cqfn.save.core.integration import org.cqfn.save.core.test.utils.runTestsWithDiktat -import kotlin.test.Ignore import kotlin.test.Test class ClassicFixTest { @@ -32,33 +31,33 @@ class ClassicFixTest { @Test fun `execute fix plugin on folder`() = - runTestsWithDiktat( - listOf( - "fix/smoke/src/main/kotlin/org/cqfn/save/" - ), 5 - ) + runTestsWithDiktat( + listOf( + "fix/smoke/src/main/kotlin/org/cqfn/save/" + ), 5 + ) @Test fun `check NoIgnoreLines`() = - runTestsWithDiktat( - listOf( - "fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines" - ), 1 - ) + runTestsWithDiktat( + listOf( + "fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines" + ), 1 + ) @Test fun `check IgnoreLinesIsEmpty`() = - runTestsWithDiktat( - listOf( - "fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty" - ), 1 - ) + runTestsWithDiktat( + listOf( + "fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty" + ), 1 + ) @Test fun `check IgnoreLines`() = - runTestsWithDiktat( - listOf( - "fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines" - ), 1 - ) + runTestsWithDiktat( + listOf( + "fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines" + ), 1 + ) } diff --git a/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt b/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt index a36444f9e..4ef2f8e36 100644 --- a/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt +++ b/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt @@ -51,11 +51,11 @@ class ClassicWarnTest { @Test fun `lines that match ignoreLines should be ignored`() = - runTestsWithDiktat( - listOf( - "warn/chapter1/IgnoreLinesTest" - ), 1 - ) + runTestsWithDiktat( + listOf( + "warn/chapter1/IgnoreLinesTest" + ), 1 + ) @Test fun `test output file set`() = diff --git a/save-plugins/fix-and-warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fixandwarn/FixAndWarnPluginConfig.kt b/save-plugins/fix-and-warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fixandwarn/FixAndWarnPluginConfig.kt index e8a1417c9..d60678129 100644 --- a/save-plugins/fix-and-warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fixandwarn/FixAndWarnPluginConfig.kt +++ b/save-plugins/fix-and-warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fixandwarn/FixAndWarnPluginConfig.kt @@ -58,6 +58,6 @@ data class FixAndWarnPluginConfig( } } companion object { - internal val defaultIgnoreLines = mutableListOf() + internal val defaultIgnoreLines: MutableList = mutableListOf() } } diff --git a/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt b/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt index 751f2a4e9..eee8a3aa9 100644 --- a/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt +++ b/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt @@ -76,8 +76,8 @@ class FixPlugin( val extraFlags = extraFlagsList.singleOrNull() ?: ExtraFlags("", "") val pathMap = chunk.map { it.test to it.expected } - val pathCopyMap = pathMap.map { - (test, expected) -> createTestFile(test, generalConfig, fixPluginConfig) to expected + val pathCopyMap = pathMap.map { (test, expected) -> + createTestFile(test, generalConfig, fixPluginConfig) to expected } val testCopyNames = pathCopyMap.joinToString(separator = fixPluginConfig.batchSeparator!!) { (testCopy, _) -> testCopy.toString() } @@ -129,28 +129,26 @@ class FixPlugin( } } - private fun createTestFile(path: Path, generalConfig: GeneralConfig, fixPluginConfig: FixPluginConfig): Path { + private fun createTestFile( + path: Path, + generalConfig: GeneralConfig, + fixPluginConfig: FixPluginConfig): Path { val pathCopy: Path = constructPathForCopyOfTestFile(FixPlugin::class.simpleName!!, path) createTempDir(pathCopy.parent!!) - val defaultIgnoreLinesPatterns = mutableListOf() - // fixme: make it more kotlin - if (generalConfig.expectedWarningsPattern != null) { - defaultIgnoreLinesPatterns.add(generalConfig.expectedWarningsPattern!!) - } - // fixme: and this if as well - if (generalConfig.runConfigPattern != null) { - defaultIgnoreLinesPatterns.add(generalConfig.runConfigPattern!!) - } + val defaultIgnoreLinesPatterns: MutableList = mutableListOf() + generalConfig.expectedWarningsPattern?.let { defaultIgnoreLinesPatterns.add(it) } + generalConfig.runConfigPattern?.let { defaultIgnoreLinesPatterns.add(it) } fs.write(fs.createFile(pathCopy)) { fs.readLines(path) .filter { line -> - if (fixPluginConfig.ignoreLines == null) { - defaultIgnoreLinesPatterns.none {regex -> regex.matches(line)} - } else { + fixPluginConfig.ignoreLines?.let { fixPluginConfig.ignoreLinesPatterns.none { pattern -> pattern.matches(line) } } + ?: run { + defaultIgnoreLinesPatterns.none {regex -> regex.matches(line) } + } } .forEach { write( diff --git a/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPluginConfig.kt b/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPluginConfig.kt index 8ca987e30..c1affe5f0 100644 --- a/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPluginConfig.kt +++ b/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPluginConfig.kt @@ -12,8 +12,6 @@ import okio.Path.Companion.toPath import kotlinx.serialization.Serializable import kotlinx.serialization.Transient import kotlinx.serialization.UseSerializers -import org.cqfn.save.core.logging.logDebug -import org.cqfn.save.core.logging.logError /** * Some fields by default are null, instead of some natural value, because of the fact, that in stage of merging @@ -25,6 +23,7 @@ import org.cqfn.save.core.logging.logError * @property resourceNameTestSuffix suffix name of the test file. * @property resourceNameExpectedSuffix suffix name of the expected file. * @property batchSeparator + * @property ignoreLines mutable list of patterns that later will be used to filter lines in test file */ @Serializable data class FixPluginConfig( @@ -41,7 +40,7 @@ data class FixPluginConfig( override var configLocation: Path = "undefined_toml_location".toPath() @Transient - override var ignoreLinesPatterns: MutableList = ignoreLines?.map{ it.toRegex() }?.toMutableList() ?: defaultIgnoreLines + override var ignoreLinesPatterns: MutableList = ignoreLines?.map { it.toRegex() }?.toMutableList() ?: defaultIgnoreLines /** * @property resourceNameTest @@ -68,7 +67,7 @@ data class FixPluginConfig( this.resourceNameExpectedSuffix ?: other.resourceNameExpectedSuffix, other.ignoreLines?.let { this.ignoreLines?.let { other.ignoreLines.union(this.ignoreLines) } ?: other.ignoreLines - } ?.toMutableList() ?: this.ignoreLines + }?.toMutableList() ?: this.ignoreLines ).also { it.configLocation = this.configLocation } @@ -86,6 +85,6 @@ data class FixPluginConfig( it.configLocation = this.configLocation } companion object { - internal val defaultIgnoreLines = mutableListOf() + internal val defaultIgnoreLines: MutableList = mutableListOf() } } diff --git a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt index 0616c5d68..ff36a7e6c 100644 --- a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt +++ b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt @@ -1,7 +1,7 @@ package org.cqfn.save.plugin.warn import org.cqfn.save.core.config.TestConfig -import org.cqfn.save.core.files.createRelativePathToTheRoot +import org.cqfn.save.core.files.createFile import org.cqfn.save.core.files.readLines import org.cqfn.save.core.logging.describe import org.cqfn.save.core.logging.logWarn @@ -22,8 +22,6 @@ import org.cqfn.save.plugin.warn.utils.getLineNumber import okio.FileNotFoundException import okio.FileSystem import okio.Path -import org.cqfn.save.core.files.createFile -import org.cqfn.save.core.logging.logError private typealias WarningMap = Map> @@ -177,17 +175,17 @@ class WarnPlugin( val actualWarningsMap = stdout .mapNotNull { - with(warnPluginConfig) { - val line = it.getLineNumber(actualWarningsPattern!!, lineCaptureGroupOut) - it.extractWarning( - actualWarningsPattern, - fileNameCaptureGroupOut!!, - line, - columnCaptureGroupOut, - messageCaptureGroupOut!! - ) + with(warnPluginConfig) { + val line = it.getLineNumber(actualWarningsPattern!!, lineCaptureGroupOut) + it.extractWarning( + actualWarningsPattern, + fileNameCaptureGroupOut!!, + line, + columnCaptureGroupOut, + messageCaptureGroupOut!! + ) + } } - } .groupBy { it.fileName } .mapValues { (_, warning) -> warning.sortedBy { it.message } } @@ -225,24 +223,24 @@ class WarnPlugin( val linesFile = fs.readLines(this) return linesFile .mapIndexed { index, line -> - val newLine = line.getLineNumber( - generalConfig.expectedWarningsPattern!!, - warnPluginConfig.lineCaptureGroup, - warnPluginConfig.linePlaceholder!!, - index + 1, - this, - linesFile, - ) - with(warnPluginConfig) { - line.extractWarning( + val newLine = line.getLineNumber( generalConfig.expectedWarningsPattern!!, - this@collectWarningsWithLineNumbers.name, - newLine, - columnCaptureGroup, - messageCaptureGroup!!, + warnPluginConfig.lineCaptureGroup, + warnPluginConfig.linePlaceholder!!, + index + 1, + this, + linesFile, ) + with(warnPluginConfig) { + line.extractWarning( + generalConfig.expectedWarningsPattern!!, + this@collectWarningsWithLineNumbers.name, + newLine, + columnCaptureGroup, + messageCaptureGroup!!, + ) + } } - } .filterNotNull() .sortedBy { warn -> warn.message } } diff --git a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt index edf76f1f7..6d5a414d3 100644 --- a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt +++ b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt @@ -49,6 +49,7 @@ import kotlinx.serialization.UseSerializers * @property partialWarnTextMatch if true - the regex created from expected warning will be wrapped with '.*': .*warn.*. * That can help a user to write only main information in the warning without any need to add/copy-paste technical info * @property testToolResFileOutput file with actual warnings + * @property ignoreLines mutable list of patterns that later will be ignored in test files */ @Serializable data class WarnPluginConfig( @@ -81,7 +82,7 @@ data class WarnPluginConfig( override var configLocation: Path = "undefined_toml_location".toPath() @Transient - override var ignoreLinesPatterns: MutableList = ignoreLines?.map{ it.toRegex() }?.toMutableList() ?: defaultIgnoreLines + override var ignoreLinesPatterns: MutableList = ignoreLines?.map { it.toRegex() }?.toMutableList() ?: defaultIgnoreLines /** * regex for name of the test file. @@ -119,7 +120,7 @@ data class WarnPluginConfig( this.testToolResFileOutput ?: other.testToolResFileOutput, other.ignoreLines?.let { this.ignoreLines?.let { other.ignoreLines.union(this.ignoreLines) } ?: other.ignoreLines - } ?.toMutableList() ?: this.ignoreLines + }?.toMutableList() ?: this.ignoreLines ).also { it.configLocation = this.configLocation } @@ -214,6 +215,6 @@ data class WarnPluginConfig( */ internal val defaultOutputPattern = Regex("(.+):(\\d*):(\\d*): (.+)") internal val defaultPatternForRegexInWarning = listOf("{{", "}}") - internal val defaultIgnoreLines = mutableListOf() + internal val defaultIgnoreLines: MutableList = mutableListOf() } } From 6166aafacea7cae5dbddf7d2d404c0de9c817921 Mon Sep 17 00:00:00 2001 From: sanyavertolet Date: Fri, 5 Nov 2021 12:47:28 +0300 Subject: [PATCH 03/14] feature/ignoreLines ###What's done: * Added ignoreLines option for Warn plugin. * Added tests for ignoreLines and Warn plugin. * Added ignoreLines option for Fix plugin. * Added tests for ignoreLines and Fix plugin. (#303) --- .../IgnoreLinesTest/IgnoreLines/Bug1Test.kt | 1 + .../IgnoreLinesTest/IgnoreLines/save.toml | 2 +- .../save/core/integration/ClassicFixTest.kt | 78 ++++++++++--------- .../save/core/integration/ClassicWarnTest.kt | 67 ++++++++-------- 4 files changed, 79 insertions(+), 69 deletions(-) diff --git a/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/Bug1Test.kt b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/Bug1Test.kt index 7a21be2ad..43886418b 100644 --- a/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/Bug1Test.kt +++ b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/Bug1Test.kt @@ -9,3 +9,4 @@ fun bar(): Bar {val qux = 42; return Bar(qux)} } // ;warn:0: [TEST] JUST_A_TEST // IGNORE_ME +# I WILL DISSAPEAR AS WELL diff --git a/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/save.toml b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/save.toml index 883e10015..67047f4e8 100644 --- a/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/save.toml +++ b/examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/save.toml @@ -4,4 +4,4 @@ suiteName = "Autofix: Smoke Tests" [fix] - ignoreLines = ["// IGNORE_ME"] \ No newline at end of file + ignoreLines = ["^// IGNORE.*", "^#.*"] \ No newline at end of file diff --git a/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicFixTest.kt b/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicFixTest.kt index c768f0ebe..8b198a071 100644 --- a/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicFixTest.kt +++ b/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicFixTest.kt @@ -15,50 +15,56 @@ class ClassicFixTest { } @Test - fun `executing fix plugin on save-toml file in directory`() = - runTestsWithDiktat( - listOf( - "fix/save.toml" - ), 5 - ) + fun `executing fix plugin on save-toml file in directory`() { + runTestsWithDiktat( + listOf( + "fix/save.toml" + ), 5 + ) + } @Test - fun `executing fix plugin on parental save-toml file`() = - runTestsWithDiktat( - listOf( - "fix/smoke/save.toml" - ), 5 - ) + fun `executing fix plugin on parental save-toml file`() { + runTestsWithDiktat( + listOf( + "fix/smoke/save.toml" + ), 5 + ) + } @Test - fun `execute fix plugin on folder`() = - runTestsWithDiktat( - listOf( - "fix/smoke/src/main/kotlin/org/cqfn/save/" - ), 5 - ) + fun `execute fix plugin on folder`() { + runTestsWithDiktat( + listOf( + "fix/smoke/src/main/kotlin/org/cqfn/save/" + ), 5 + ) + } @Test - fun `check NoIgnoreLines`() = - runTestsWithDiktat( - listOf( - "fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines" - ), 1 - ) + fun `check NoIgnoreLines`() { + runTestsWithDiktat( + listOf( + "fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines" + ), 1 + ) + } @Test - fun `check IgnoreLinesIsEmpty`() = - runTestsWithDiktat( - listOf( - "fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty" - ), 1 - ) + fun `check IgnoreLinesIsEmpty`() { + runTestsWithDiktat( + listOf( + "fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty" + ), 1 + ) + } @Test - fun `check IgnoreLines`() = - runTestsWithDiktat( - listOf( - "fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines" - ), 1 - ) + fun `check IgnoreLines`() { + runTestsWithDiktat( + listOf( + "fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines" + ), 1 + ) + } } diff --git a/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt b/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt index 348bbe7e6..7a99d5847 100644 --- a/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt +++ b/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt @@ -36,13 +36,13 @@ class ClassicWarnTest { } @Test - fun `executing warn plugin on directory`() = - runTestsWithDiktat( - listOf( - "warn/chapter1" - ), 7 - ) - + fun `executing warn plugin on directory`() { + runTestsWithDiktat( + listOf( + "warn/chapter1" + ), 7 + ) + } @Test fun `executing warn plugin on directory, files are set with regex`() { @@ -54,21 +54,22 @@ class ClassicWarnTest { } @Test - - fun `lines that match ignoreLines should be ignored`() = - runTestsWithDiktat( - listOf( - "warn/chapter1/IgnoreLinesTest" - ), 1 - ) + fun `lines that match ignoreLines should be ignored`() { + runTestsWithDiktat( + listOf( + "warn/chapter1/IgnoreLinesTest" + ), 1 + ) + } @Test - fun `test output file set`() = - runTestsWithDiktat( - listOf( - "warn/chapter1/TestResultsFileTest" - ), 1 - ) + fun `test output file set`() { + runTestsWithDiktat( + listOf( + "warn/chapter1/TestResultsFileTest" + ), 1 + ) + } @Test @Ignore @@ -83,20 +84,22 @@ class ClassicWarnTest { } @Test - fun `executing warn plugin on save-toml file in directory`() = - runTestsWithDiktat( - listOf( - "warn/save.toml" - ), 7 - ) + fun `executing warn plugin on save-toml file in directory`() { + runTestsWithDiktat( + listOf( + "warn/save.toml" + ), 7 + ) + } @Test - fun `executing warn plugin on parental save-toml file`() = - runTestsWithDiktat( - listOf( - "warn/chapter1/save.toml" - ), 7 - ) + fun `executing warn plugin on parental save-toml file`() { + runTestsWithDiktat( + listOf( + "warn/chapter1/save.toml" + ), 7 + ) + } @Test @Ignore From 8d5ee0c8fad39e72d4b711d36238014b184dfc1a Mon Sep 17 00:00:00 2001 From: sanyavertolet Date: Fri, 5 Nov 2021 14:14:29 +0300 Subject: [PATCH 04/14] feature/ignoreLines ###What's done: * Added ignoreLines option for Warn plugin. * Added tests for ignoreLines and Warn plugin. * Added ignoreLines option for Fix plugin. * Added tests for ignoreLines and Fix plugin. * Implemented copying a file in Warn plugin in order to filter out lines that match any regex from ignoreLines. (#133) --- .../kotlin/org/cqfn/save/core/integration/FixDirTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/FixDirTest.kt b/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/FixDirTest.kt index 54bd9db18..dc5b9b2b8 100644 --- a/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/FixDirTest.kt +++ b/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/FixDirTest.kt @@ -6,7 +6,7 @@ import kotlin.test.Test class FixDirTest { @Test fun `execute fix plugin`() { - runTestsWithDiktat(listOf("fix/smoke/src/main/kotlin/org/cqfn/save"), 2) + runTestsWithDiktat(listOf("fix/smoke/src/main/kotlin/org/cqfn/save"), 5) } @Test From ca67047b863747052288a7cd455faed16808897f Mon Sep 17 00:00:00 2001 From: sanyavertolet Date: Mon, 22 Nov 2021 15:51:28 +0300 Subject: [PATCH 05/14] feature/ignoreLines ###What's done: * Added ignoreLines option for Warn plugin. * Added tests for ignoreLines and Warn plugin. * Added ignoreLines option for Fix plugin. * Added tests for ignoreLines and Fix plugin. * Implemented copying a file in Warn plugin in order to filter out lines that match any regex from ignoreLines. (#133) --- .../kotlin/org/cqfn/save/core/plugin/PluginConfig.kt | 4 ++-- .../save/plugins/fixandwarn/FixAndWarnPluginConfig.kt | 5 +---- .../kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt | 4 ++-- .../kotlin/org/cqfn/save/plugins/fix/FixPluginConfig.kt | 7 ++----- .../kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt | 9 +++------ .../kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt | 5 ++--- 6 files changed, 12 insertions(+), 22 deletions(-) diff --git a/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/PluginConfig.kt b/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/PluginConfig.kt index e427cf0b6..7aa4ef1a5 100644 --- a/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/PluginConfig.kt +++ b/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/PluginConfig.kt @@ -28,7 +28,7 @@ interface PluginConfig { /** * list of regexes to be ignored */ - var ignoreLinesPatterns: MutableList + val ignoreLinesPatterns: MutableList /** * Location of the toml config @@ -79,7 +79,7 @@ data class GeneralConfig( val runConfigPattern: Regex? = null, ) : PluginConfig { override val type = TestConfigSections.GENERAL - override var ignoreLinesPatterns: MutableList = mutableListOf() + override val ignoreLinesPatterns: MutableList = mutableListOf() @Transient override var configLocation: Path = "undefined_toml_location".toPath() diff --git a/save-plugins/fix-and-warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fixandwarn/FixAndWarnPluginConfig.kt b/save-plugins/fix-and-warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fixandwarn/FixAndWarnPluginConfig.kt index 1802d9b35..aab8fed37 100644 --- a/save-plugins/fix-and-warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fixandwarn/FixAndWarnPluginConfig.kt +++ b/save-plugins/fix-and-warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fixandwarn/FixAndWarnPluginConfig.kt @@ -27,7 +27,7 @@ data class FixAndWarnPluginConfig( override val resourceNamePatternStr: String = "(${fix.resourceNamePatternStr})|(${warn.resourceNamePatternStr})" @Transient - override var ignoreLinesPatterns: MutableList = defaultIgnoreLines + override val ignoreLinesPatterns: MutableList = mutableListOf() override fun mergeWith(otherConfig: PluginConfig): PluginConfig { val other = otherConfig as FixAndWarnPluginConfig @@ -58,7 +58,4 @@ data class FixAndWarnPluginConfig( it.configLocation = this.configLocation } } - companion object { - internal val defaultIgnoreLines: MutableList = mutableListOf() - } } diff --git a/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt b/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt index 89d1ffff9..bcacda249 100644 --- a/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt +++ b/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt @@ -145,10 +145,10 @@ class FixPlugin( fs.readLines(path) .filter { line -> fixPluginConfig.ignoreLines?.let { - fixPluginConfig.ignoreLinesPatterns.none { pattern -> pattern.matches(line) } + fixPluginConfig.ignoreLinesPatterns.none { it.matches(line) } } ?: run { - defaultIgnoreLinesPatterns.none {regex -> regex.matches(line) } + defaultIgnoreLinesPatterns.none { it.matches(line) } } } .forEach { diff --git a/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPluginConfig.kt b/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPluginConfig.kt index fdd54c9cd..bf42494d0 100644 --- a/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPluginConfig.kt +++ b/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPluginConfig.kt @@ -40,7 +40,7 @@ data class FixPluginConfig( override var configLocation: Path = "undefined_toml_location".toPath() @Transient - override var ignoreLinesPatterns: MutableList = ignoreLines?.map { it.toRegex() }?.toMutableList() ?: defaultIgnoreLines + override val ignoreLinesPatterns: MutableList = ignoreLines?.map { it.toRegex() }?.toMutableList() ?: mutableListOf() /** * @property resourceNameTest @@ -81,11 +81,8 @@ data class FixPluginConfig( batchSeparator ?: ", ", resourceNameTest, resourceNameExpected, - ignoreLines?.filter { it != "null" }?.toMutableList() ?: ignoreLines + ignoreLines ).also { it.configLocation = this.configLocation } - companion object { - internal val defaultIgnoreLines: MutableList = mutableListOf() - } } diff --git a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt index ca298fe79..3eb2328bc 100644 --- a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt +++ b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt @@ -90,7 +90,7 @@ class WarnPlugin( fs.write(fs.createFile(pathCopy)) { fs.readLines(path) .filter { line -> - ignorePatterns.none { pattern -> pattern.matches(line) } + ignorePatterns.none { it.matches(line) } } .map { write((it + "\n").encodeToByteArray()) } } @@ -109,16 +109,13 @@ class WarnPlugin( generalConfig: GeneralConfig ): Sequence { // extracting all warnings from test resource files - val copyPaths: List = paths.map { path -> createTestFile(path, warnPluginConfig) } + val copyPaths: List = paths.map { createTestFile(it, warnPluginConfig) } val expectedWarningsMap: WarningMap = copyPaths.associate { val warningsForCurrentPath = it.collectWarningsWithLineNumbers(warnPluginConfig, generalConfig) it.name to warningsForCurrentPath } - val extraFlagsList = copyPaths.mapNotNull { path -> - extraFlagsExtractor.extractExtraFlagsFrom(path) - } - .distinct() + val extraFlagsList = copyPaths.mapNotNull { extraFlagsExtractor.extractExtraFlagsFrom(it) }.distinct() require(extraFlagsList.size <= 1) { "Extra flags for all files in a batch should be same, but you have batchSize=${warnPluginConfig.batchSize}" + " and there are ${extraFlagsList.size} different sets of flags inside it, namely $extraFlagsList" diff --git a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt index 07b2731df..6be324ac2 100644 --- a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt +++ b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt @@ -82,7 +82,7 @@ data class WarnPluginConfig( override var configLocation: Path = "undefined_toml_location".toPath() @Transient - override var ignoreLinesPatterns: MutableList = ignoreLines?.map { it.toRegex() }?.toMutableList() ?: defaultIgnoreLines + override val ignoreLinesPatterns: MutableList = ignoreLines?.map { it.toRegex() }?.toMutableList() ?: mutableListOf() /** * regex for name of the test file. @@ -179,7 +179,7 @@ data class WarnPluginConfig( patternForRegexInWarning ?: defaultPatternForRegexInWarning, partialWarnTextMatch ?: false, testToolResFileOutput, - ignoreLines?.filter { it != "null" }?.toMutableList() ?: ignoreLines + ignoreLines ).also { it.configLocation = this.configLocation } @@ -215,6 +215,5 @@ data class WarnPluginConfig( */ internal val defaultOutputPattern = Regex("(.+):(\\d*):(\\d*): (.+)") internal val defaultPatternForRegexInWarning = listOf("{{", "}}") - internal val defaultIgnoreLines: MutableList = mutableListOf() } } From b52e00fb1ce260704117c42ad063de7c071b4d67 Mon Sep 17 00:00:00 2001 From: sanyavertolet Date: Mon, 22 Nov 2021 16:06:55 +0300 Subject: [PATCH 06/14] feature/ignoreLines ###What's done: * Added ignoreLines option for Warn plugin. * Added tests for ignoreLines and Warn plugin. * Added ignoreLines option for Fix plugin. * Added tests for ignoreLines and Fix plugin. * Implemented copying a file in Warn plugin in order to filter out lines that match any regex from ignoreLines. (#133) --- .../org/cqfn/save/core/integration/ClassicWarnTest.kt | 2 +- .../kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt b/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt index 8d7b12424..ee7d72fe9 100644 --- a/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt +++ b/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt @@ -94,7 +94,7 @@ class ClassicWarnTest { runTestsWithDiktat( listOf( "warn/save.toml" - ), 8 + ), 9 ) } diff --git a/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt b/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt index 513cbb66a..1983fd8ff 100644 --- a/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt +++ b/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt @@ -148,12 +148,8 @@ class FixPlugin( } } - private fun createTestFile(path: Path, generalConfig: GeneralConfig, fixPluginConfig: FixPluginConfig): Path { - val pathCopy: Path = constructPathForCopyOfTestFile( - "${FixPlugin::class.simpleName!!}-${Random.nextInt()}", - path - ) + val pathCopy: Path = constructPathForCopyOfTestFile("${FixPlugin::class.simpleName!!}-${Random.nextInt()}", path) tmpDirectory = pathCopy.parent!! createTempDir(tmpDirectory!!) From 751220815285f22d0b4c61ad1c3ebeae7311196f Mon Sep 17 00:00:00 2001 From: sanyavertolet Date: Mon, 22 Nov 2021 16:32:09 +0300 Subject: [PATCH 07/14] feature/ignoreLines ###What's done: * Added ignoreLines option for Warn plugin. * Added tests for ignoreLines and Warn plugin. * Added ignoreLines option for Fix plugin. * Added tests for ignoreLines and Fix plugin. * Implemented copying a file in Warn plugin in order to filter out lines that match any regex from ignoreLines. (#133) --- .../commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt b/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt index 1983fd8ff..015860503 100644 --- a/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt +++ b/save-plugins/fix-plugin/src/commonMain/kotlin/org/cqfn/save/plugins/fix/FixPlugin.kt @@ -148,7 +148,10 @@ class FixPlugin( } } - private fun createTestFile(path: Path, generalConfig: GeneralConfig, fixPluginConfig: FixPluginConfig): Path { + private fun createTestFile( + path: Path, + generalConfig: GeneralConfig, + fixPluginConfig: FixPluginConfig): Path { val pathCopy: Path = constructPathForCopyOfTestFile("${FixPlugin::class.simpleName!!}-${Random.nextInt()}", path) tmpDirectory = pathCopy.parent!! createTempDir(tmpDirectory!!) From 1316dc0b90b8e11abd6c97fe949ae1235dafbb8d Mon Sep 17 00:00:00 2001 From: sanyavertolet Date: Tue, 23 Nov 2021 11:49:34 +0300 Subject: [PATCH 08/14] feature/ignoreLines ###What's done: * Added ignoreLines option for Warn plugin. * Added tests for ignoreLines and Warn plugin. * Added ignoreLines option for Fix plugin. * Added tests for ignoreLines and Fix plugin. * Implemented copying a file in Warn plugin in order to filter out lines that match any regex from ignoreLines. (#133) --- .../kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt | 14 ++++++++------ .../org/cqfn/save/plugin/warn/WarnPluginConfig.kt | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt index d63625546..d4236ad42 100644 --- a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt +++ b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt @@ -104,7 +104,7 @@ class WarnPlugin( "LongMethod", "ReturnCount", "SwallowedException", - "TOO_MANY_LINES_IN_LAMBDA", + "TOO_MANY_LINES_IN_LAMBDA" ) private fun handleTestFile( paths: List, @@ -183,6 +183,7 @@ class WarnPlugin( benchmarkMode!!, ) } + } .groupBy { it.fileName } .mapValues { (_, warning) -> warning.sortedBy { it.message } } @@ -232,11 +233,11 @@ class WarnPlugin( .mapIndexed { index, line -> val newLine = line.getLineNumber( generalConfig.expectedWarningsPattern!!, - this@collectWarningsWithLineNumbers.name, - newLine, - columnCaptureGroup, - messageCaptureGroup!!, - benchmarkMode!!, + warnPluginConfig.lineCaptureGroup, + warnPluginConfig.linePlaceholder!!, + index + 1, + this, + linesFile ) with(warnPluginConfig) { line.extractWarning( @@ -245,6 +246,7 @@ class WarnPlugin( newLine, columnCaptureGroup, messageCaptureGroup!!, + benchmarkMode!! ) } } diff --git a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt index 528338e1e..e7a8065a8 100644 --- a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt +++ b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt @@ -74,8 +74,8 @@ data class WarnPluginConfig( val patternForRegexInWarning: List? = null, val partialWarnTextMatch: Boolean? = null, val testToolResFileOutput: String? = null, - val ignoreLines: MutableList? = null - val benchmarkMode: Boolean? = null, + val ignoreLines: MutableList? = null, + val benchmarkMode: Boolean? = null ) : PluginConfig { @Transient override val type = TestConfigSections.WARN From e6f16adceb082c2196e6001352cdcec17b3489ab Mon Sep 17 00:00:00 2001 From: sanyavertolet Date: Tue, 23 Nov 2021 12:07:24 +0300 Subject: [PATCH 09/14] feature/ignoreLines ###What's done: * Added ignoreLines option for Warn plugin. * Added tests for ignoreLines and Warn plugin. * Added ignoreLines option for Fix plugin. * Added tests for ignoreLines and Fix plugin. * Implemented copying a file in Warn plugin in order to filter out lines that match any regex from ignoreLines. (#133) --- .../org/cqfn/save/core/integration/ClassicWarnTest.kt | 6 +++--- .../kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt b/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt index bfc9519f5..b71132d83 100644 --- a/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt +++ b/save-core/src/commonNonJsTest/kotlin/org/cqfn/save/core/integration/ClassicWarnTest.kt @@ -47,7 +47,7 @@ class ClassicWarnTest { runTestsWithDiktat( listOf( "warn/chapter1" - ), 7 + ), 8 ) } @@ -95,7 +95,7 @@ class ClassicWarnTest { runTestsWithDiktat( listOf( "warn/save.toml" - ), 9 + ), 10 ) } @@ -104,7 +104,7 @@ class ClassicWarnTest { runTestsWithDiktat( listOf( "warn/chapter1/save.toml" - ), 7 + ), 8 ) } diff --git a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt index e7a8065a8..74f18b5a5 100644 --- a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt +++ b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPluginConfig.kt @@ -187,7 +187,6 @@ data class WarnPluginConfig( ).also { it.configLocation = this.configLocation } - } private fun requirePositiveIfNotNull(value: Long?) { From dca01fbf6db198fc639296ba58eee087d72b0bd0 Mon Sep 17 00:00:00 2001 From: sanyavertolet Date: Tue, 23 Nov 2021 12:31:27 +0300 Subject: [PATCH 10/14] feature/ignoreLines ###What's done: * Added ignoreLines option for Warn plugin. * Added tests for ignoreLines and Warn plugin. * Added ignoreLines option for Fix plugin. * Added tests for ignoreLines and Fix plugin. * Implemented copying a file in Warn plugin in order to filter out lines that match any regex from ignoreLines. (#133) --- save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt b/save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt index aca7bd591..fddbe94fa 100644 --- a/save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt +++ b/save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt @@ -75,7 +75,7 @@ class GeneralTest { val saveFlags = " . --result-output FILE --report-type JSON" // Execute the script from examples val execCmd = "$runCmd$saveBinName $saveFlags" - val pb = ProcessBuilder(true, fs).exec(execCmd, examplesDir, null, 100_000L) + val pb = ProcessBuilder(true, fs).exec(execCmd, examplesDir, null, 200_000L) println("SAVE execution output:\n${pb.stdout.joinToString("\n")}") if (pb.stderr.isNotEmpty()) { println("Warning and errors during SAVE execution:\n${pb.stderr.joinToString("\n")}") From f3c84a538cf74fdb12f2885043e7113d02d33371 Mon Sep 17 00:00:00 2001 From: sanyavertolet Date: Tue, 23 Nov 2021 13:09:46 +0300 Subject: [PATCH 11/14] feature/ignoreLines ###What's done: * TESTING (#133) --- save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt b/save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt index fddbe94fa..3ae7c6e90 100644 --- a/save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt +++ b/save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt @@ -72,10 +72,10 @@ class GeneralTest { } val runCmd = if (isCurrentOsWindows()) "" else "sudo chmod +x $saveBinName && ./" - val saveFlags = " . --result-output FILE --report-type JSON" + val saveFlags = " . --result-output FILE --report-type JSON --log trace" // Execute the script from examples val execCmd = "$runCmd$saveBinName $saveFlags" - val pb = ProcessBuilder(true, fs).exec(execCmd, examplesDir, null, 200_000L) + val pb = ProcessBuilder(true, fs).exec(execCmd, examplesDir, null, 300_000L) println("SAVE execution output:\n${pb.stdout.joinToString("\n")}") if (pb.stderr.isNotEmpty()) { println("Warning and errors during SAVE execution:\n${pb.stderr.joinToString("\n")}") From cc3e3faae6f1b49c0a971128fb52cc858c65a6dd Mon Sep 17 00:00:00 2001 From: sanyavertolet Date: Tue, 23 Nov 2021 13:55:18 +0300 Subject: [PATCH 12/14] feature/ignoreLines ###What's done: * TESTING (#133) --- save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt | 2 +- save-core/src/commonNonJsMain/kotlin/org/cqfn/save/core/Save.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt b/save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt index 3ae7c6e90..59087d363 100644 --- a/save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt +++ b/save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt @@ -72,7 +72,7 @@ class GeneralTest { } val runCmd = if (isCurrentOsWindows()) "" else "sudo chmod +x $saveBinName && ./" - val saveFlags = " . --result-output FILE --report-type JSON --log trace" + val saveFlags = " . --result-output FILE --report-type JSON --log all" // Execute the script from examples val execCmd = "$runCmd$saveBinName $saveFlags" val pb = ProcessBuilder(true, fs).exec(execCmd, examplesDir, null, 300_000L) diff --git a/save-core/src/commonNonJsMain/kotlin/org/cqfn/save/core/Save.kt b/save-core/src/commonNonJsMain/kotlin/org/cqfn/save/core/Save.kt index 26bb462d3..3f6977a90 100644 --- a/save-core/src/commonNonJsMain/kotlin/org/cqfn/save/core/Save.kt +++ b/save-core/src/commonNonJsMain/kotlin/org/cqfn/save/core/Save.kt @@ -118,7 +118,7 @@ class Save( } reporter.afterAll() reporter.out.close() - logInfo("SAVE has finished execution. You can rerun with --log debug or --log trace for additional information.") + logInfo("SAVE has finished execution. You can rerun with --log debug or --log all for additional information.") return reporter } From 81aa3cf6851c1aa4fa455d262f9055c7bba1c0ce Mon Sep 17 00:00:00 2001 From: sanyavertolet Date: Tue, 23 Nov 2021 15:34:45 +0300 Subject: [PATCH 13/14] feature/ignoreLines ###What's done: * Added ignoreLines option for Warn plugin. * Added tests for ignoreLines and Warn plugin. * Added ignoreLines option for Fix plugin. * Added tests for ignoreLines and Fix plugin. * Implemented copying a file in Warn plugin in order to filter out lines that match any regex from ignoreLines. --- .../src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt | 4 ++-- .../kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt b/save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt index 59087d363..fddbe94fa 100644 --- a/save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt +++ b/save-cli/src/jvmTest/kotlin/org/cqfn/save/cli/GeneralTest.kt @@ -72,10 +72,10 @@ class GeneralTest { } val runCmd = if (isCurrentOsWindows()) "" else "sudo chmod +x $saveBinName && ./" - val saveFlags = " . --result-output FILE --report-type JSON --log all" + val saveFlags = " . --result-output FILE --report-type JSON" // Execute the script from examples val execCmd = "$runCmd$saveBinName $saveFlags" - val pb = ProcessBuilder(true, fs).exec(execCmd, examplesDir, null, 300_000L) + val pb = ProcessBuilder(true, fs).exec(execCmd, examplesDir, null, 200_000L) println("SAVE execution output:\n${pb.stdout.joinToString("\n")}") if (pb.stderr.isNotEmpty()) { println("Warning and errors during SAVE execution:\n${pb.stderr.joinToString("\n")}") diff --git a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt index d4236ad42..43eab9c46 100644 --- a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt +++ b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt @@ -23,6 +23,7 @@ import org.cqfn.save.plugin.warn.utils.getLineNumber import okio.FileNotFoundException import okio.FileSystem import okio.Path +import kotlin.random.Random private typealias WarningMap = Map> @@ -83,7 +84,7 @@ class WarnPlugin( } private fun createTestFile(path: Path, warnPluginConfig: WarnPluginConfig): Path { - val pathCopy: Path = constructPathForCopyOfTestFile(WarnPlugin::class.simpleName!!, path) + val pathCopy: Path = constructPathForCopyOfTestFile("${WarnPlugin::class.simpleName!!}-${ Random.nextInt()}", path) createTempDir(pathCopy.parent!!) val ignorePatterns = warnPluginConfig.ignoreLinesPatterns @@ -144,7 +145,7 @@ class WarnPlugin( } ?: copyPaths.joinToString(separator = warnPluginConfig.batchSeparator!!) val execFlagsAdjusted = resolvePlaceholdersFrom(warnPluginConfig.execFlags, extraFlags, fileNamesForExecCmd) val execCmd = "${generalConfig.execCmd} $execFlagsAdjusted" - val time = generalConfig.timeOutMillis!!.times(paths.size) + val time = generalConfig.timeOutMillis!!.times(copyPaths.size) val executionResult = try { pb.exec(execCmd, testConfig.getRootConfig().directory.toString(), redirectTo, time) @@ -152,7 +153,7 @@ class WarnPlugin( logWarn("The following tests took too long to run and were stopped: $paths, timeout for single test: ${ex.timeoutMillis}") return failTestResult(paths, ex, execCmd) } catch (ex: ProcessExecutionException) { - return failTestResult(copyPaths, ex, execCmd) + return failTestResult(paths, ex, execCmd) } val stdout = From 1c70ad95a133a11703de4d4f068740a95ca96f54 Mon Sep 17 00:00:00 2001 From: sanyavertolet Date: Tue, 23 Nov 2021 18:29:17 +0300 Subject: [PATCH 14/14] feature/ignoreLines ###What's done: * Added ignoreLines option for Warn plugin. * Added tests for ignoreLines and Warn plugin. * Added ignoreLines option for Fix plugin. * Added tests for ignoreLines and Fix plugin. * Implemented copying a file in Warn plugin in order to filter out lines that match any regex from ignoreLines. --- .../org/cqfn/save/core/plugin/Plugin.kt | 2 +- .../org/cqfn/save/plugin/warn/WarnPlugin.kt | 24 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/Plugin.kt b/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/Plugin.kt index a818a1335..d8eb5a397 100644 --- a/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/Plugin.kt +++ b/save-common/src/commonMain/kotlin/org/cqfn/save/core/plugin/Plugin.kt @@ -56,7 +56,7 @@ abstract class Plugin( if (!excludedTests.isNullOrEmpty()) { logDebug("Excluded tests for [${testConfig.location}] : $excludedTests") } - + clean() return if (testFilesList.isNotEmpty()) { // fixme: remove this logging and convert `testFilesList` back to Sequence // or at least make `logDebug` accept lazy messages diff --git a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt index 43eab9c46..8d4ec6dbb 100644 --- a/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt +++ b/save-plugins/warn-plugin/src/commonMain/kotlin/org/cqfn/save/plugin/warn/WarnPlugin.kt @@ -83,20 +83,22 @@ class WarnPlugin( } } - private fun createTestFile(path: Path, warnPluginConfig: WarnPluginConfig): Path { - val pathCopy: Path = constructPathForCopyOfTestFile("${WarnPlugin::class.simpleName!!}-${ Random.nextInt()}", path) - createTempDir(pathCopy.parent!!) + private fun createTestFiles(paths: List, warnPluginConfig: WarnPluginConfig): List { + val dirName = "${WarnPlugin::class.simpleName!!}-${Random.nextInt()}" + val dirPath = constructPathForCopyOfTestFile(dirName, paths[0]).parent!! + createTempDir(dirPath) val ignorePatterns = warnPluginConfig.ignoreLinesPatterns - fs.write(fs.createFile(pathCopy)) { - fs.readLines(path) - .filter { line -> - ignorePatterns.none { it.matches(line) } - } - .map { write((it + "\n").encodeToByteArray()) } + return paths.map { path -> + val copyPath = constructPathForCopyOfTestFile(dirName, path) + fs.write(fs.createFile(copyPath)) { + fs.readLines(path) + .filter { line -> ignorePatterns.none { it.matches(line) } } + .map { write((it + "\n").encodeToByteArray()) } + } + copyPath } - return pathCopy } @Suppress( @@ -113,7 +115,7 @@ class WarnPlugin( generalConfig: GeneralConfig ): Sequence { // extracting all warnings from test resource files - val copyPaths: List = paths.map { createTestFile(it, warnPluginConfig) } + val copyPaths: List = createTestFiles(paths, warnPluginConfig) val expectedWarningsMap: WarningMap = copyPaths.associate { val warningsForCurrentPath = it.collectWarningsWithLineNumbers(warnPluginConfig, generalConfig) it.name to warningsForCurrentPath