Skip to content

Cursive crash in clojure.test diff can make failing assertions appear to pass #3096

@cmf

Description

@cmf

A user reports that certain failing clojure.test assertions involving Java objects can crash Cursive's diff formatting, after which the test appears to pass. This is especially problematic because a real assertion failure is hidden by the crash.

Reproducer

foo/Foo.java:

package foo;

import java.util.function.Predicate;

public interface Foo {
    Predicate<String> BAR = s -> true;
}

mytest.clj:

(ns mytest
  (:require [clojure.test :as t])
  (:import (foo Foo)))

(t/deftest crash
  (t/is (= {:k Foo/BAR} {:k nil})))

Actual result

Cursive crashes 100% of the time when running the test, and the test then appears to pass even though the assertion should fail.

Reported stack trace excerpt:

Caused by: java.lang.NullPointerException: null cannot be cast to non-null type com.intellij.psi.PsiElement
    at cursive.diff.DiffKt.formatMap(diff.kt:65)
    at cursive.diff.DiffKt.toFormat(diff.kt:94)
    at cursive.diff.DiffKt.toFormat$lambda$0(diff.kt:99)
    ...

Expected result

The assertion failure should be reported as a failed test, and Cursive should not crash while formatting/displaying the diff.

Notes

The user has submitted crash reports and raised this because the apparent passing result is deceptive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugMarks issues describing bugsreleased-eapMarks issues which have had the fixes released in an EAP build

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions