Skip to content

Import the JS Envs projects from the Scala.js core repository. #1

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

Merged
merged 150 commits into from
Jun 16, 2020

Conversation

sjrd
Copy link
Member

@sjrd sjrd commented Jun 15, 2020

This is the initial import of the JS Envs projects (scalajs-js-envs, scalajs-js-envs-test-kit and scalajs-env-nodejs) from the Scala.js core repository. The history of this commit reflects the entire history of relevant files from the core repo, filter-branch'ed to appear as if they had always been in this repo. This commit adds the specific setup of the build and tests.


This has been done similarly to scala-js/scala-js-env-phantomjs#1 and scala-js/scala-js-env-jsdom-nodejs#1.

The history was obtained as follows, starting from commit scala-js/scala-js@c82fa8c of the core repo.

First, we identified all the paths where relevant files have lived in the past, through renamings along their history. A useful command:

$ git log --stat -- js-envs nodejs-env/ js-envs-test-kit/ js-envs-test-suite tools/jvm/src/main/scala/scala/scalajs/tools/env/ tools/shared/src/main/scala/scala/scalajs/tools/env/ tools/src/main/scala/scala/scalajs/tools/env/ sbt-plugin/src/main/scala/scala/scalajs/sbtplugin/env/ sbt-plugin/src/main/scala/scala/scalajs/sbtplugin/JSUtils.scala sbt-plugin/src/test/scala/scala/scalajs/sbtplugin/test/env/ tools/jvm/src/test/scala/scala/scalajs/tools/env/ tools/shared/src/test/scala/scala/scalajs/tools/env/ tools/src/test/scala/scala/scalajs/tools/env/

This is the list:

js-envs/
nodejs-env/
js-envs-test-kit/
js-envs-test-suite/
tools/shared/src/main/scala/scala/scalajs/tools/env/
tools/shared/src/test/scala/scala/scalajs/tools/env/
tools/jvm/src/main/scala/scala/scalajs/tools/env/
tools/jvm/src/test/scala/scala/scalajs/tools/env/
tools/src/main/scala/scala/scalajs/tools/env/
tools/src/test/scala/scala/scalajs/tools/env/
sbt-plugin/src/main/scala/scala/scalajs/sbtplugin/JSUtils.scala
sbt-plugin/src/main/scala/scala/scalajs/sbtplugin/env/
sbt-plugin/src/test/scala/scala/scalajs/sbtplugin/test/env/

Based on that, we filter-branch'ed to keep only those files, using the following incantation, inspired by http://stackoverflow.com/a/6006679/1829647:

git filter-branch \
    --prune-empty \
    --index-filter '
  git ls-tree -z -r --name-only --full-tree $GIT_COMMIT \
    | grep -z -v "^js-envs/" \
    | grep -z -v "^nodejs-env/" \
    | grep -z -v "^js-envs-test-kit/" \
    | grep -z -v "^js-envs-test-suite/" \
    | grep -z -v "^tools/shared/src/main/scala/scala/scalajs/tools/env/" \
    | grep -z -v "^tools/shared/src/test/scala/scala/scalajs/tools/env/" \
    | grep -z -v "^tools/jvm/src/main/scala/scala/scalajs/tools/env/" \
    | grep -z -v "^tools/jvm/src/test/scala/scala/scalajs/tools/env/" \
    | grep -z -v "^tools/src/main/scala/scala/scalajs/tools/env/" \
    | grep -z -v "^tools/src/test/scala/scala/scalajs/tools/env/" \
    | grep -z -v "^sbt-plugin/src/main/scala/scala/scalajs/sbtplugin/JSUtils.scala$" \
    | grep -z -v "^sbt-plugin/src/main/scala/scala/scalajs/sbtplugin/env/" \
    | grep -z -v "^sbt-plugin/src/test/scala/scala/scalajs/sbtplugin/test/env/" \
    | xargs -0 -r git rm -r --cached
  ' HEAD

That gave the result visible in https://github.com/sjrd/scala-js-js-envs/commits/import-from-core-step-1. However that includes the files specific to Rhino, PhantomJS and JSDOMNodeJSEnv, which we want to get rid off. We do this with:

git filter-branch \
    --prune-empty \
    --index-filter '
  git rm -r --cached --ignore-unmatch \
    js-envs/src/main/scala/org/scalajs/jsenv/jsdomnodejs/ \
    js-envs/src/main/scala/org/scalajs/jsenv/nodejs/JSDOMNodeJSEnv.scala \
    js-envs/src/main/scala/org/scalajs/jsenv/phantomjs/ \
    js-envs/src/main/scala/org/scalajs/jsenv/RetryingComJSEnv.scala \
    js-envs/src/main/scala/org/scalajs/jsenv/rhino/ \
    js-envs/src/test/scala/org/scalajs/jsenv/test/JSDOMNodeJSEnvTest.scala \
    js-envs/src/test/scala/org/scalajs/jsenv/test/PhantomJSTest.scala \
    js-envs/src/test/scala/org/scalajs/jsenv/test/RetryingComJSEnvTest.scala \
    js-envs/src/test/scala/org/scalajs/jsenv/test/RhinoJSEnvTest.scala \
    js-envs-test-suite/src/test/scala/org/scalajs/jsenv/test/JSDOMNodeJSEnvTest.scala \
    js-envs-test-suite/src/test/scala/org/scalajs/jsenv/test/PhantomJSTest.scala \
    js-envs-test-suite/src/test/scala/org/scalajs/jsenv/test/PhantomJSWithCustomInitFilesTest.scala \
    js-envs-test-suite/src/test/scala/org/scalajs/jsenv/test/RetryingComJSEnvTest.scala \
    js-envs-test-suite/src/test/scala/org/scalajs/jsenv/test/RhinoJSEnvTest.scala \
    sbt-plugin/src/main/scala/scala/scalajs/sbtplugin/env/phantomjs/ \
    sbt-plugin/src/main/scala/scala/scalajs/sbtplugin/env/rhino/ \
    sbt-plugin/src/main/scala/scala/scalajs/sbtplugin/env/nodejs/JSDOMNodeJSEnv.scala \
    sbt-plugin/src/test/scala/scala/scalajs/sbtplugin/test/env/JSDOMNodeJSEnvTest.scala \
    sbt-plugin/src/test/scala/scala/scalajs/sbtplugin/test/env/PhantomJSTest.scala \
    sbt-plugin/src/test/scala/scala/scalajs/sbtplugin/test/env/RhinoJSEnvTest.scala
  ' HEAD

giving https://github.com/sjrd/scala-js-js-envs/commits/import-from-core-step-2

Unfortunately, --prune-empty does not prune empty merge commits. We fixed that using the solution found in http://stackoverflow.com/a/38420284/1829647:

git filter-branch --prune-empty --parent-filter 'sed "s/-p //g" | xargs -r git show-branch --independent | sed "s/\</-p /g"'

giving https://github.com/sjrd/scala-js-js-envs/commits/import-from-core-step-3

Now, we had a clean history, except that it was orphaned wrt. the Initial commit of this repository, which is e9d986c. To have a nice PR with a history that appears to have come from the Initial commit, we reattached the first commit to the Initial commit using:

git filter-branch --parent-filter 'sed "s/^\$/-p e9d986c60d0e44853f4c0faa9d901995a3f239f9/"' HEAD

which yielded https://github.com/sjrd/scala-js-js-envs/commits/import-from-core-step-4.

Almost there, except that now the files from the Initial commit have been removed in the first meaningful commit of the filter-branch. We restored them using:

git filter-branch --index-filter 'git reset e9d986c60d0e44853f4c0faa9d901995a3f239f9 -- .gitignore LICENSE README.md'

giving the history in https://github.com/sjrd/scala-js-js-envs/commits/import-from-core-step-5.

As a final polish, we rewrite, in commit messages, references to tickets of the form #123 to scala-js/scala-js#123, so that they point to issues in the scala-js/scala-js repository. This is done using the following incantation:

git filter-branch --msg-filter 'sed -r -e "s/(#[0-9]+)/scala-js\/scala-js\1/g"'

and gives the result in https://github.com/sjrd/scala-js-js-envs/commits/import-from-core-step-6.

This PR is one commit on top of that final step.

gzm0 and others added 30 commits April 8, 2014 13:25
A JS_DEPENDENCIES manifest file is added to each configuration
classpath and exported in JARs. This way, libraries may declare what
exact JS files should be included from a WebJar they depend on. (Or
what JS files they provide themselves should be included).

Example usages can be found in the build definitions for the
jasmine-test-framework and the testing example.

- This completely removes `importScripts` and fixes scala-js/scala-js#457
- The project's classpath is fully available even in the post package
  stages. This is necessary to allow for discovery of dependency
  manifests and JS libraries the project depends on.
- Fix scala-js/scala-js#442: Add Phantom.js environment
- Add a setting whether a project requires the DOM
…tput

Send printlns to the console, not the logger.
The new API allows for classpaths to be partially linked
(n.b. packageExternalDeps, this commit fixes scala-js/scala-js#609).
JSEnv#runJS used to return Some(<string>) if it failed due to
historical reasons. This is no longer necessary and introduces useless
clutter and confusion (e.g. runners failing without the outer code
failing). runJS now throws an exception if it fails.
…s#958)

This commit removes support for `__ScalaJSExportsNamespace`. Use
`__ScalaJSEnv.exportsNamespace` instead.
In order to be able to use normal Node.js modules, the NodeJSEnv must
respect NODE_PATH from the environment and properly merge it with its
own provided library path (for CommonJS-style includes).
sjrd and others added 19 commits December 9, 2018 13:01
Back when that hack was introduced in
1fc8d0526ba9b46049c0deefc3fe3fa93d3271b0, Node.js' `console.log`
deduplicated consecutive `%` signs in its argument, even if it was
a single argument. At the time we thought that was intentional, and
we added our hack to have it behave in a more standard way for
Scala.js.

The deduplication with only 1 argument turned out to be a bug,
recognized as such in nodejs/node#3396,
when it was accidentally fixed in Node.js 4. It is now the
documented behavior, see
https://nodejs.org/api/util.html#util_util_format_format_args
which is referenced from
https://nodejs.org/api/console.html#console_console_log_data_args.
This has been added way back in the days (scala-js/scala-js#958) as a poor man's way to
support asynchronous testing.

Since then, testing has substantially matured. Notably a JSEnv is not
required anymore to be able to terminate automatically.

Therefore, there is no need anymore to support exiting in a platform
agnostic manner. Or if there is a need or such a thing, it should be
put in an external library with JS-style dynamic platform detection.

Unfortunately this makes the JSEnv test suite slightly more
complicated again (and basically reverts
6746cf3a20d2497bbc6c520666a47f7ec1cd28dd).
…ort ES module errors.

Backported from master.
Class#newInstance is deprecated.
And specialize them to the particular needs of each subproject:

* `java.lang.StringBuilder` versus `java.io.Writer` instead of the
  generic `java.lang.Appendable`.
* With or without tracking of how many characters are written out.

Also review and specialize the one in `ir`.
It is not possible to cross-compile `@deprecatedName`s without
warnings between Scala 2.12- and 2.13+, because:

* In 2.12, they require symbol literals as arguments
* In 2.13, symbol literals are deprecated

Since they were deprecated more than two years ago, and are part of
an API that is not used much anyway (JS envs), I believe it is fair
to drop the source compatibility in this case.
…cts.

Partest is not yet enabled in this commit, because a dependency of
`partest` 2.13.0, namely `testkit`, was not published. See
scala/bug#11529 upstream.
Partest is not yet enabled in this commit, because a dependency of
`partest` 2.13.0, namely `testkit`, was not published. See
scala/bugscala-js/scala-js#11529 upstream.
This includes d5021d2d0, 45cf1cff7, c4d50703b and fd2343eb9.
This removes the last references to `JavaConverters` in our
codebase, excluding scalalib overrides and comments.
@sjrd sjrd requested a review from gzm0 June 15, 2020 15:57
@sjrd sjrd force-pushed the import-from-core branch from 4af55ef to a8f4d16 Compare June 15, 2020 15:59
require(msgs.isEmpty)
callOnOutputStream(config)
new TestRun
}

def startWithCom(input: Input, config: RunConfig, onMessage: String => Unit): JSComRun = {
def startWithCom(input: Seq[Input], config: RunConfig, onMessage: String => Unit): JSComRun = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two changes here are necessary because the file was not compiling as is. It turns out we were not running jsEnvsTestKit/test in the core repo!

@sjrd sjrd force-pushed the import-from-core branch from a8f4d16 to 8c5c2ff Compare June 15, 2020 16:17
Comment on lines +57 to +58
// Links to the JavaDoc do not work
Compile / doc / scalacOptions -= "-Xfatal-warnings",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I deactivate fatal warnings in Scaladoc, because links to the JavaDoc, including in @throws sections, do not work and report errors. We could fix this by doing all the heavy machinery that we do in scala-js/scala-js to patch up the JavaDoc links, but I found that overkill right now.

@sjrd sjrd force-pushed the import-from-core branch from 8c5c2ff to 97d12af Compare June 15, 2020 16:24
This is the initial import of the JS Envs projects
(scalajs-js-envs, scalajs-js-envs-test-kit and scalajs-env-nodejs)
from the Scala.js core repository. The history of this commit
reflects the entire history of relevant files from the core repo,
filter-branch'ed to appear as if they had always been in this repo.
This commit adds the specific setup of the build and tests.
@sjrd sjrd force-pushed the import-from-core branch from 97d12af to f3a156c Compare June 15, 2020 20:54
@gzm0 gzm0 merged commit 7463ce6 into scala-js:master Jun 16, 2020
@sjrd sjrd deleted the import-from-core branch June 16, 2020 09:05
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.

6 participants