diktat icon indicating copy to clipboard operation
diktat copied to clipboard

Add more integration tests to check Diktat compatibility with KtLint

Open 0x6675636b796f75676974687562 opened this issue 3 years ago • 3 comments

Update: we already have Gradle plug-in tests available under diktat-gradle-plugin/src/functionalTest/,

  • broken with #1428,
  • re-enabled with #1579,

so the primary focus of this task is the Spotless plug-in (see below).

Diktat Gradle plug-in

Probably DiktatJavaExecTaskTest, feel free to suggest a different test class name.

  1. Check that the plug-in is indeed executed and reports errors (i. e. ./gradlew diktatCheck) against invalid input should produce errors from diktat-ruleset namespace.
    • plain reporter
    • sarif reporter
  2. Check that KtLint-standard rules are indeed excluded, i. e. none of the errors from the standard or experimental namespaces are triggered by the invalid input (be sure to also disable the corresponding Diktat rules via diktat-analysis.yml). This test should fail if changes from #1568 are temporarily rolled back.

Spotless Gradle plug-in

  1. Check that diffplug/spotless, when run as a Gradle plug-in with the snapshot Diktat version, produces expected errors and has no regressions like #1559.
    • plain reporter
    • sarif reporter

Basically, we need a test which would, one way or another, launch a forked JVM against a test project, something we do in DiktatSmokeTest.

At the same time, I'd vote against using save-cli for this purpose and instead look for smth similar to khmarbaise/maven-it-extension for JUnit 5, for two reasons:

  • save-cli takes a long time to download over a slow network,
  • a forked JVM is much easier to debug in case of test failures.

@petertrr, @nulls, WDYT?

we need also test spotless maven plugin

nulls avatar Nov 16 '22 11:11 nulls

Sounds reasonable; our functionalTest for Gradle plugin can be enhanced to run different scenarios as well as projects with spotless plugin using Gradle testkit.

petertrr avatar Nov 16 '22 11:11 petertrr

Depends on https://github.com/saveourtool/save-cli/issues/521

nulls avatar Apr 07 '23 07:04 nulls