Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference to the Lincheck IDEA plugin added #333

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
11 changes: 11 additions & 0 deletions src/jvm/main/org/jetbrains/kotlinx/lincheck/Reporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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:"
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,18 @@ internal inline fun <reified E: Exception> 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)
Expand Down