Skip to content

Commit 7fc7925

Browse files
sjrdhamzaremmal
andcommitted
Wire sjsSandbox and sjsJUnitTests for the new stdlib.
Co-authored-by: Hamza Remmal <hamza@remmal.net>
1 parent fe7c711 commit 7fc7925

File tree

3 files changed

+53
-14
lines changed

3 files changed

+53
-14
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ jobs:
101101
./project/scripts/cmdTests
102102
./project/scripts/bootstrappedOnlyCmdTests
103103
104-
- name: Scala.js Test
105-
run: |
106-
./project/scripts/sbt ";sjsSandbox/run ;sjsSandbox/test ;sjsJUnitTests/test ;set sjsJUnitTests/scalaJSLinkerConfig ~= switchToESModules ;sjsJUnitTests/test"
107-
108104
test_windows_fast:
109105
runs-on: [self-hosted, Windows]
110106
if: "(
@@ -148,10 +144,6 @@ jobs:
148144
run: './project/scripts/winCmdTests.bat'
149145
shell: cmd
150146

151-
- name: Scala.js Test
152-
run: sbt ";sjsJUnitTests/test ;set sjsJUnitTests/scalaJSLinkerConfig ~= switchToESModules ;sjsJUnitTests/test"
153-
shell: cmd
154-
155147
test_windows_full:
156148
runs-on: [self-hosted, Windows]
157149
if: "github.event_name == 'schedule' && github.repository == 'scala/scala3'

.github/workflows/stdlib.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,5 +532,10 @@ jobs:
532532
java-version: 17
533533
cache: 'sbt'
534534
- uses: sbt/setup-sbt@v1
535-
- name: Test Scala.js
536-
run: ./project/scripts/sbt sjsCompilerTests/test
535+
- name: Scala.js compiler tests
536+
run: ./project/scripts/sbt "sjsCompilerTests/test"
537+
- name: Scala.js sandbox
538+
run: ./project/scripts/sbt ";sjsSandbox/run ;sjsSandbox/test"
539+
- name: Scala.js JUnit tests
540+
run: ./project/scripts/sbt ";sjsJUnitTests/test ;set sjsJUnitTests/scalaJSLinkerConfig ~= switchToESModules ;sjsJUnitTests/test"
541+
# TODO Scala.js on Windows

project/Build.scala

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,6 +2936,48 @@ object Build {
29362936
BuildInfoPlugin.buildInfoDefaultSettings
29372937
)
29382938

2939+
/** Common settings for sjsSandbox and sjsJUnitTests */
2940+
lazy val regularScalaJSProjectSettings: Seq[Setting[_]] = Def.settings(
2941+
version := dottyVersion,
2942+
scalaVersion := referenceVersion,
2943+
crossPaths := true,
2944+
autoScalaLibrary := false, // do not add a dependency to stdlib, we depend on it with dependsOn
2945+
// Add the source directories
2946+
Compile / unmanagedSourceDirectories := Seq(baseDirectory.value / "src"),
2947+
Test / unmanagedSourceDirectories := Seq(baseDirectory.value / "test"),
2948+
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
2949+
Compile / scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-encoding", "UTF8", "-language:implicitConversions"),
2950+
Compile / scalacOptions += "-scalajs", // we really need this one for Scala.js projects
2951+
// Don't publish
2952+
publish / skip := false,
2953+
// Configure to use the non-bootstrapped compiler
2954+
scalaInstance := {
2955+
val externalCompilerDeps = (`scala3-compiler-nonbootstrapped` / Compile / externalDependencyClasspath).value.map(_.data).toSet
2956+
2957+
// IMPORTANT: We need to use actual jars to form the ScalaInstance and not
2958+
// just directories containing classfiles because sbt maintains a cache of
2959+
// compiler instances. This cache is invalidated based on timestamps
2960+
// however this is only implemented on jars, directories are never
2961+
// invalidated.
2962+
val tastyCore = (`tasty-core-nonbootstrapped` / Compile / packageBin).value
2963+
val scalaLibrary = (`scala-library-nonbootstrapped` / Compile / packageBin).value
2964+
val scala3Interfaces = (`scala3-interfaces` / Compile / packageBin).value
2965+
val scala3Compiler = (`scala3-compiler-nonbootstrapped` / Compile / packageBin).value
2966+
2967+
Defaults.makeScalaInstance(
2968+
dottyNonBootstrappedVersion,
2969+
libraryJars = Array(scalaLibrary),
2970+
allCompilerJars = Seq(tastyCore, scala3Interfaces, scala3Compiler) ++ externalCompilerDeps,
2971+
allDocJars = Seq.empty,
2972+
state.value,
2973+
scalaInstanceTopLoader.value
2974+
)
2975+
},
2976+
scalaCompilerBridgeBinaryJar := {
2977+
Some((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
2978+
},
2979+
)
2980+
29392981
/** A sandbox to play with the Scala.js back-end of dotty.
29402982
*
29412983
* This sandbox is compiled with dotty with support for Scala.js. It can be
@@ -2947,9 +2989,9 @@ object Build {
29472989
*/
29482990
lazy val sjsSandbox = project.in(file("sandbox/scalajs")).
29492991
enablePlugins(DottyJSPlugin).
2950-
dependsOn(`scala3-library-bootstrappedJS`).
2992+
dependsOn(`scala-library-sjs`).
29512993
settings(
2952-
commonBootstrappedSettings,
2994+
regularScalaJSProjectSettings,
29532995
// Required to run Scala.js tests.
29542996
Test / fork := false,
29552997

@@ -2965,9 +3007,9 @@ object Build {
29653007
*/
29663008
lazy val sjsJUnitTests = project.in(file("tests/sjs-junit")).
29673009
enablePlugins(DottyJSPlugin).
2968-
dependsOn(`scala3-library-bootstrappedJS`).
3010+
dependsOn(`scala-library-sjs`).
29693011
settings(
2970-
commonBootstrappedSettings,
3012+
regularScalaJSProjectSettings,
29713013
bspEnabled := false,
29723014
scalacOptions --= Seq("-Werror", "-deprecation"),
29733015

0 commit comments

Comments
 (0)