From 802e629d10e1ceac8746f101570c92a6018d392a Mon Sep 17 00:00:00 2001 From: "Aleksandr.Potapov" Date: Tue, 11 Jun 2024 20:35:53 +0200 Subject: [PATCH] The reference to the Lincheck IDEA plugin added --- README.md | 6 ++++++ .../main/org/jetbrains/kotlinx/lincheck/Reporter.kt | 11 +++++++++++ .../representation/InternalLincheckBugTest.kt | 2 +- .../jetbrains/kotlinx/lincheck_test/util/TestUtils.kt | 11 +++++++++-- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fd379423b..c13a4298d 100755 --- a/README.md +++ b/README.md @@ -117,6 +117,12 @@ The following interleaving leads to the error: | result: 4 | | ``` +## Lincheck IDEA Plugin + +Try [Lincheck IDEA Plugin](https://plugins.jetbrains.com/plugin/24171-lincheck) to investigate +bugs easily, navigate trace points, and quickly identify bugs with fully-fledged debugger integration. +Walk through the failure trace to any direction you want (even in the past!) and examine your data structure in live mode via the debugger, without sophisticated conditional breakpoints creation. Download in from the JetBrains Plugin marketplace or right from the IntelliJ IDEA Ultimate. + ## Contributing See [Contributing Guidelines](CONTRIBUTING.md). diff --git a/src/jvm/main/org/jetbrains/kotlinx/lincheck/Reporter.kt b/src/jvm/main/org/jetbrains/kotlinx/lincheck/Reporter.kt index 8fac850d4..a268f23b2 100644 --- a/src/jvm/main/org/jetbrains/kotlinx/lincheck/Reporter.kt +++ b/src/jvm/main/org/jetbrains/kotlinx/lincheck/Reporter.kt @@ -390,6 +390,10 @@ internal fun StringBuilder.appendFailure(failure: LincheckFailure): StringBuilde if (failure.trace != null) { appendLine() appendTrace(failure, results, failure.trace, exceptionStackTraces) + if (!ideaPluginEnabled()) { + appendLine() + appendPluginReference() + } } else { appendExceptionsStackTracesBlock(exceptionStackTraces) } @@ -713,4 +717,11 @@ private fun StringBuilder.appendException(t: Throwable) { appendLine(sw.toString()) } +private fun StringBuilder.appendPluginReference() = append(pluginReferenceInTrace) + +internal val pluginReferenceInTrace = """ + Enhance your debugging experience with the Lincheck IDEA Plugin https://plugins.jetbrains.com/plugin/24171-lincheck. + Easily navigate trace points and quickly identify bugs with fully-fledged debugger integration. + """.trimIndent() + private const val EXCEPTIONS_TRACES_TITLE = "Exception stack traces:" diff --git a/src/jvm/test/org/jetbrains/kotlinx/lincheck_test/representation/InternalLincheckBugTest.kt b/src/jvm/test/org/jetbrains/kotlinx/lincheck_test/representation/InternalLincheckBugTest.kt index d297dedb7..4cf9ff1e7 100644 --- a/src/jvm/test/org/jetbrains/kotlinx/lincheck_test/representation/InternalLincheckBugTest.kt +++ b/src/jvm/test/org/jetbrains/kotlinx/lincheck_test/representation/InternalLincheckBugTest.kt @@ -42,6 +42,6 @@ class InternalLincheckBugTest { fun test() = ModelCheckingOptions() .actorsPerThread(2) .checkImpl(this::class.java) { failure -> - failure.checkLincheckOutput("internal_bug_report.txt") + failure.checkLincheckOutput("internal_bug_report.txt", expectPluginReferenceIfPluginDisabled = false) } } diff --git a/src/jvm/test/org/jetbrains/kotlinx/lincheck_test/util/TestUtils.kt b/src/jvm/test/org/jetbrains/kotlinx/lincheck_test/util/TestUtils.kt index 5faec5868..366573de6 100644 --- a/src/jvm/test/org/jetbrains/kotlinx/lincheck_test/util/TestUtils.kt +++ b/src/jvm/test/org/jetbrains/kotlinx/lincheck_test/util/TestUtils.kt @@ -43,11 +43,18 @@ internal inline fun Options<*, *>.checkFailsWithException * * @param expectedOutputFile name of file stored in resources/expected_logs, storing the expected lincheck output. */ -internal fun LincheckFailure?.checkLincheckOutput(expectedOutputFile: String) { +internal fun LincheckFailure?.checkLincheckOutput(expectedOutputFile: String, expectPluginReferenceIfPluginDisabled: Boolean = true) { check(this != null) { "The test should fail" } val actualOutput = StringBuilder().appendFailure(this).toString() - val expectedOutput = getExpectedLogFromResources(expectedOutputFile) + var expectedOutput = getExpectedLogFromResources(expectedOutputFile) + + if (expectPluginReferenceIfPluginDisabled && !ideaPluginEnabled()) { + expectedOutput = StringBuilder(expectedOutput) + .appendLine() + .append(pluginReferenceInTrace) + .toString() + } if (actualOutput.filtered != expectedOutput.filtered) { assertEquals(expectedOutput, actualOutput)