Skip to content

[test-sbt] More uniformity. #10120

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

Open
wants to merge 1 commit into
base: series/2.x
Choose a base branch
from

Conversation

dubinsky
Copy link
Contributor

@dubinsky dubinsky commented Aug 19, 2025

Currently, code implementing sbt.testing.Framework for JVM, Scala.js and Scala Native suffers from severe code triplication: code doing the same thing is present in three places. This pull request removes this gratuitous redundancy.

An unfortunate - and inevitable - consequence of code duplication is code drift: different copies of the code do things differently for no good reason.

Backends sbt.testing.Framework runs on do have inherent differences: tests running on Scala.js and Scala Native are running outside of the JVM, and thus their outcomes need to be communicated to the process managing the test run; Scala.js is single-threaded by nature, which affects the way tests have to be run. Code differences not warranted by the inherent differences between the backends seem gratuitous, and this pull request removes some of them.

One area where implementations of the sbt.testing.Framework diverged from one another is the machinery to test them: only JVM implementation is currently testable. With this pull request, sbt.testing.Framework tests run on all the backends.

Another divergence is in the storage of test summaries: JVM uses AtomicReference[Vector], Scala.js uses Buffer, Scala Native uses ConcurrentLinkedQueue; this pull request unifies summary storage for all backends: AtomicReference[Vector] works for all of them.

Another divergence is the way test summary is rendered: counts of tests executed, ignored, or failed are included in the summary on JVM but not on Scala.js or Scala Native; setting test renderer to IntelliJ in the test arguments is honored only on JVM. This pull request makes test summary uniform across the backends.

Another divergence is: currently, signal handlers are installed only on JVM. This pull request installs them on all backends.

Another divergence affects a recent enhancement, which turned out to be effective only on JVM; this pull request applies it to all backends (and tests that it works ;)).

@kyri-petrou, your remark

I gave it a go at this (basically trying to unify the JVM / JS / Native implementations so that we can reuse the existing event test suites that exist for the JVM, but it doesn't seem possible.
... writing a full test suite from scratch (which frankly it's going to be extremely time consuming)

is on target: this was not trivial ;)

@dubinsky dubinsky force-pushed the zio-test-more-uniform-reporting branch 6 times, most recently from 61d736b to 246ce39 Compare August 20, 2025 04:52
@dubinsky dubinsky marked this pull request as draft August 20, 2025 05:29
@dubinsky dubinsky force-pushed the zio-test-more-uniform-reporting branch 6 times, most recently from e0332e7 to a908303 Compare August 20, 2025 23:32
@dubinsky dubinsky marked this pull request as ready for review August 20, 2025 23:46
@dubinsky dubinsky force-pushed the zio-test-more-uniform-reporting branch 2 times, most recently from b96fecc to d4b4e6e Compare August 21, 2025 18:32
Currently, code implementing `sbt.testing.Framework` for JVM, Scala.js and Scala Native suffers from severe code triplication: code doing the same thing is present in three places. This pull request removes this gratuitous redundancy.

An unfortunate - and inevitable - consequence of code duplication is code drift: different copies of the code do things differently for no good reason.

Backends `sbt.testing.Framework` runs on _do_ have inherent differences: tests running on Scala.js and Scala Native are not running on JVM, and thus their outcomes need to be communicated to the process managing the test run; Scala.js is single-threaded by nature, which affects the way tests have to be run.
Code differences not warranted by the inherent differences between the backends seem gratuitous, and this pull request removes some of them.

One area where implementations of the `sbt.testing.Framework` diverged from one another is the machinery to test them: only JVM implementation is currently testable. With this pull request, `sbt.testing.Framework` tests run on all the backends.

Another divergence is in the storage of test summaries: JVM uses `AtomicReference[Vector]`, Scala.js uses `Buffer`, Scala Native uses `ConcurrentLinkedQueue`; this pull request unifies summary storage for all backends: `AtomicReference[Vector]` works for all of them.

Another divergence is the way test summary is rendered: counts of tests executed, ignored, or failed are included in the summary on JVM but not on Scala.js or Scala Native; setting test renderer to IntelliJ in the test arguments is honored only on JVM. This pull request makes test summary uniform across the backends.

Another divergence is: currently, signal handlers are installed only on JVM. This pull request installs them on all backends.

Another divergence affects a recent [enhancement](zio#9756), which turned out to be effective only on JVM; this pull request applies it to all backends (and tests that it works ;)).

@kyri-petrou, your [remark](zio#9629 (comment))

> I gave it a go at this (basically trying to unify the JVM / JS / Native implementations so that we can reuse the existing event test suites that exist for the JVM, but it doesn't seem possible.
> ... writing a full test suite from scratch (which frankly it's going to be extremely time consuming)

is on target: this was not trivial ;)
@dubinsky dubinsky force-pushed the zio-test-more-uniform-reporting branch from d4b4e6e to 3df9da4 Compare August 21, 2025 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant