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

Add support for running Scala.js tests #706

Merged
merged 15 commits into from
Nov 11, 2018
Merged

Add support for running Scala.js tests #706

merged 15 commits into from
Nov 11, 2018

Conversation

jvican
Copy link
Contributor

@jvican jvican commented Nov 8, 2018

There's a new big commit stabilizing the test infrastructure and
modifying key things in Bloop to get test support for Scala.js working
reliably.

Follow-up of #572

tindzk and others added 13 commits October 30, 2018 17:01
- TestSuiteEvent: Remove `logger.trace()` as exceptions and their
  traces are already printed by the test runner
- Tasks: Only link projects and look up tests if test frameworks are
  defined
- ScalaJsToolchain: Make main class optional since test projects do
  not necessarily have a main class
- ScalaJsToolchain: Add function to retrieve test frameworks
- DiscoveredTests: Rename to `DiscoveredTestFrameworks` and make it
  platform-agnostic
- Add missing module initialiser `org.scalajs.testinterface.Bridge.start()`
- Port `JSDOMNodeJSEnv` from upstream Scala.js
1. Fixes the test infrastructure to avoid the previous messy API that
   required to both match on the platform and then the toolchain.
2. Modularize `Tasks` into independent classes that are only meant to be
   used for testing/linking. Also modularize more the code.
3. Make the change in the bloop configuration not breaking, so that we
   can release this change in a minor version of Bloop.
@jvican
Copy link
Contributor Author

jvican commented Nov 8, 2018

Things that need to be done in the test infrastructure before a stable release (non-blocking, for now):

  • Print good test exceptions for testing/running anything.
  • Populate the jsenv option from the sbt build and error if the jsenv is not supported
  • Wire this infrastructure up with BSP to support the test classes endpoint
  • Persist Scala.js's linker state to get incremental linker
  • Test JSDom environment extensively

@jvican jvican force-pushed the topic/scalajs-testing branch 8 times, most recently from f5da9cb to ddf0c73 Compare November 9, 2018 13:44
1. Adds tests for the whole Scala.js test infrastructure.
2. Implements test cancellation reliably for both Scala.js 0.6.x and 1.x.
3. Refines the Scala.js infrastructure and reorganizes the structure of
   the code to keep the test infrastructure readable. It also renames
   some of the test suites to be consistent with the logic in
   `frontend`.
4. Sets the right module initializers and skips settings the main
   initializer if the project is going to be tested. A module
   initializer is always run.
5. Introduces unit test projects in test resources. The unit test
   projects exist so that in the future we can run tests without
   requiring `integrationSetUpBloop` to set up the whole community
   build. It's left for future work adapting the test suite to do this.

   * The configuration files of the projects are generated per machine.
     If the files are up-to-date, the generation is skipped.
   * The generation occurs the first time the user starts the build, to
     ensure that whenever we do `bloopInstall` the whole project can be
     tested via bloop too.

Other nice improvements:

1. Remove `SourceMap` and reuse the one from Scala.js in the bridge 1.0.
2. Pretty prints exceptions coming from failed tests (and hidden behind
   Scala.JS specific or invocation target exceptions).
@jvican jvican force-pushed the topic/scalajs-testing branch 2 times, most recently from 85f75ca to 94a4334 Compare November 11, 2018 20:11
Scala.js 1.x's `ComRun` doesn't invoke `close` on the underlying run
when its `close()` method is called. This means that the process is
effectively not killed and a resource leak happens. This leak can happen
fatal consequences in Windows because an open reference to the JS output
file is open and, therefore, other processes cannot write to it and
fail.

To fix this issue, we've had to copy the contents of `BloopComRun`,
`JsDomNodeJsEnv` and `NodeJsEnv`. These environments use nuprocess to
spawn the JS test servers.

When Scala.js fixes the aforementioned issue upstream, we can remove all
of this logic and keep the js bridge 1.x logic as simple as that of
0.6.x. The use of Scala sys.process doesn't bother us because
cancellation still works successfully.
@jvican jvican force-pushed the topic/scalajs-testing branch from 94a4334 to fc07e87 Compare November 11, 2018 20:53
@jvican jvican merged commit acdc3f8 into master Nov 11, 2018
@tgodzik tgodzik deleted the topic/scalajs-testing branch September 7, 2021 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants