lambdaisland / kaocha

Full featured next gen Clojure test runner
https://cljdoc.org/d/lambdaisland/kaocha/1.0.861/doc/1-introduction
Eclipse Public License 1.0
792 stars 81 forks source link

fix the issue from kaocha #416: casting *out* to System/out #417

Closed humorless closed 1 year ago

humorless commented 1 year ago

Problem

From #416, there is a bug raised. The bug is because that Clojure's *out* is not totally equivalent to java's System/out. Clojure's *out* is equivalent to System/out, wrapped in an OutputStreamWriter. Therefore, it caused a Casting error.

Solution

After referencing how output capture is implemented in src/kaocha/plugin/capture_output.cljc, although I think there is already a finally section, which should restore the java's System/out and System/err, I tend to believe that Arne's comment is based on his real world experiments.

;; Force reset printing to stdout, since we
;; don't know where in the process we've
;; been interrupted, output capturing may
;; still be in effect.
codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 60.00% and project coverage change: -0.05 :warning:

Comparison is base (f8775f2) 75.13% compared to head (b85883d) 75.08%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #417 +/- ## ========================================== - Coverage 75.13% 75.08% -0.05% ========================================== Files 52 52 Lines 2799 2802 +3 Branches 289 289 ========================================== + Hits 2103 2104 +1 - Misses 509 511 +2 Partials 187 187 ``` | Flag | Coverage Δ | | |---|---|---| | integration | `56.31% <40.00%> (-0.03%)` | :arrow_down: | | unit | `69.41% <60.00%> (-0.04%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#carryforward-flags-in-the-pull-request-comment) to find out more. | [Impacted Files](https://app.codecov.io/gh/lambdaisland/kaocha/pull/417?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [src/kaocha/api.clj](https://app.codecov.io/gh/lambdaisland/kaocha/pull/417?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2thb2NoYS9hcGkuY2xq) | `73.52% <60.00%> (-1.22%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

alysbrooks commented 1 year ago

Thanks, @humorless! Looks good.

I think adding your PR message (or a shorter version) to a comment would be good. If I remember correctly when I made the change, I looked around for comments and past commit messages but didn't find anything explaining why it was the way it was.

humorless commented 1 year ago

Thanks, @humorless! Looks good.

I think adding your PR message (or a shorter version) to a comment would be good. If I remember correctly when I made the change, I looked around for comments and past commit messages but didn't find anything explaining why it was the way it was.

Thanks for you suggestion. I have added the necessary comments to explain the bug.

alysbrooks commented 1 year ago

Released in v1.84.1335

[lambdaisland/kaocha "1.84.1335"]                 ;; deps.edn
{lambdaisland/kaocha {:mvn/version "1.84.1335"}}  ;; project.clj