Skip to content

Commit 02e217f

Browse files
committed
fix: make tests work
1 parent ea478cc commit 02e217f

File tree

10 files changed

+120
-53
lines changed

10 files changed

+120
-53
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
104104
- name: Scala.js Test
105105
run: |
106-
./project/scripts/sbt ";sjsSandbox/run ;sjsSandbox/test ;sjsJUnitTests/test ;set sjsJUnitTests/scalaJSLinkerConfig ~= switchToESModules ;sjsJUnitTests/test ;sjsCompilerTests/test"
106+
./project/scripts/sbt ";sjsSandbox/run ;sjsSandbox/test ;sjsJUnitTests/test ;set sjsJUnitTests/scalaJSLinkerConfig ~= switchToESModules ;sjsJUnitTests/test"
107107
108108
test_windows_fast:
109109
runs-on: [self-hosted, Windows]
@@ -149,7 +149,7 @@ jobs:
149149
shell: cmd
150150

151151
- name: Scala.js Test
152-
run: sbt ";sjsJUnitTests/test ;set sjsJUnitTests/scalaJSLinkerConfig ~= switchToESModules ;sjsJUnitTests/test ;sjsCompilerTests/test"
152+
run: sbt ";sjsJUnitTests/test ;set sjsJUnitTests/scalaJSLinkerConfig ~= switchToESModules ;sjsJUnitTests/test"
153153
shell: cmd
154154

155155
test_windows_full:

.github/workflows/stdlib.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,3 +517,20 @@ jobs:
517517
- uses: sbt/setup-sbt@v1
518518
- name: Test `tasty-core-bootstrapped`
519519
run: ./project/scripts/sbt tasty-core-bootstrapped-new/test
520+
521+
test-scala-js:
522+
runs-on: ubuntu-latest
523+
needs: [scala3-compiler-bootstrapped, tasty-core-bootstrapped, scala3-staging, scala3-tasty-inspector, scala-library-sjs]
524+
steps:
525+
- name: Git Checkout
526+
uses: actions/checkout@v5
527+
528+
- name: Set up JDK 17
529+
uses: actions/setup-java@v5
530+
with:
531+
distribution: 'temurin'
532+
java-version: 17
533+
cache: 'sbt'
534+
- uses: sbt/setup-sbt@v1
535+
- name: Test `tasty-core-bootstrapped`
536+
run: ./project/scripts/sbt sjsCompilerTests/test

compiler/test/dotty/Properties.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ object Properties {
5757
/** dotty-interfaces jar */
5858
def dottyInterfaces: String = sys.props("dotty.tests.classes.dottyInterfaces")
5959

60-
/** dotty-library-js jar */
61-
def dottyLibraryJS: String = sys.props("dotty.tests.classes.dottyLibraryJS")
62-
6360
/** dotty-compiler jar */
6461
def dottyCompiler: String = sys.props("dotty.tests.classes.dottyCompiler")
6562

compiler/test/dotty/tools/vulpix/TestConfiguration.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ object TestConfiguration {
4848
Properties.scalaJSJavalib,
4949
Properties.scalaJSScalalib,
5050
Properties.scalaJSLibrary,
51-
Properties.dottyLibraryJS
5251
))
5352

5453
def mkClasspath(classpaths: List[String]): String =

project/Build.scala

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,7 +1821,7 @@ object Build {
18211821
// We add a dependency to the JVM library to have the classfile available
18221822
// (as they are not part of this artifact)
18231823
.dependsOn(`scala3-library-bootstrapped-new`)
1824-
.enablePlugins(ScalaLibraryPlugin)
1824+
.enablePlugins(ScalaLibraryPlugin, DottyJSPlugin)
18251825
.settings(publishSettings)
18261826
.settings(
18271827
name := "scala-library-sjs",
@@ -1870,7 +1870,9 @@ object Build {
18701870
))
18711871
.flatMap(_.relativeTo(baseDirectory.value / "src")).toSet
18721872

1873-
files.filterNot(file =>
1873+
files.filterNot(_.getPath().contains("BoxesRunTime.scala"))
1874+
.filterNot(_.getPath().contains("ScalaNumber.scala"))
1875+
.filterNot(file =>
18741876
file.relativeTo((`scala-library-bootstrapped` / baseDirectory).value / "src")
18751877
.exists(overwrittenSources.contains))
18761878

@@ -2460,6 +2462,7 @@ object Build {
24602462
s"-Ddotty.tests.classes.tastyCore=${(`tasty-core-bootstrapped-new` / Compile / packageBin).value}",
24612463
s"-Ddotty.tests.classes.compilerInterface=${findArtifactPath(externalDeps, "compiler-interface")}",
24622464
s"-Ddotty.tests.classes.scalaLibrary=${(`scala-library-bootstrapped` / Compile / packageBin).value}",
2465+
s"-Ddotty.tests.classes.scalaJSScalalib=${(`scala-library-sjs` / Compile / packageBin).value}",
24632466
s"-Ddotty.tests.classes.scalaAsm=${findArtifactPath(externalDeps, "scala-asm")}",
24642467
s"-Ddotty.tests.classes.jlineTerminal=${findArtifactPath(externalDeps, "jline-terminal")}",
24652468
s"-Ddotty.tests.classes.jlineReader=${findArtifactPath(externalDeps, "jline-reader")}",
@@ -2997,10 +3000,15 @@ object Build {
29973000
)
29983001

29993002
lazy val sjsCompilerTests = project.in(file("sjs-compiler-tests")).
3000-
dependsOn(`scala3-compiler` % "test->test").
3003+
dependsOn(`scala3-compiler-bootstrapped-new` % "test->test").
30013004
settings(
3002-
commonNonBootstrappedSettings,
3003-
3005+
(Compile / scalaSource) := baseDirectory.value / "src",
3006+
(Test / scalaSource) := baseDirectory.value / "test",
3007+
(Compile / javaSource) := baseDirectory.value / "src",
3008+
(Test / javaSource) := baseDirectory.value / "test",
3009+
(Compile / resourceDirectory) := baseDirectory.value / "resources",
3010+
(Test / resourceDirectory) := baseDirectory.value / "test-resources",
3011+
scalaVersion := (`scala3-compiler-bootstrapped-new` / scalaVersion).value,
30043012
libraryDependencies ++= Seq(
30053013
"org.scala-js" %% "scalajs-linker" % scalaJSVersion % Test cross CrossVersion.for3Use2_13,
30063014
"org.scala-js" %% "scalajs-env-nodejs" % "1.3.0" % Test cross CrossVersion.for3Use2_13,
@@ -3009,18 +3017,63 @@ object Build {
30093017
// Change the baseDirectory when running the tests
30103018
Test / baseDirectory := baseDirectory.value.getParentFile,
30113019

3012-
javaOptions ++= (`scala3-compiler` / javaOptions).value,
3020+
javaOptions ++= (`scala3-compiler-bootstrapped-new` / javaOptions).value,
30133021
javaOptions ++= {
3014-
val externalJSDeps = (`scala3-library-bootstrappedJS` / Compile / externalDependencyClasspath).value
3015-
val dottyLibraryJSJar = (`scala3-library-bootstrappedJS` / Compile / packageBin).value.getAbsolutePath
3022+
val externalJSDeps = (`scala-library-sjs` / Compile / externalDependencyClasspath).value
3023+
3024+
val managedSrcDir = {
3025+
// Populate the directory
3026+
(`scala3-compiler-bootstrapped-new` / Compile / managedSources).value
3027+
3028+
(`scala3-compiler-bootstrapped-new` / Compile / sourceManaged).value
3029+
}
3030+
3031+
val externalDeps = (`scala3-compiler-bootstrapped-new` / Runtime / externalDependencyClasspath).value
30163032

30173033
Seq(
3018-
"-Ddotty.tests.classes.dottyLibraryJS=" + dottyLibraryJSJar,
3034+
s"-Ddotty.tests.dottyCompilerManagedSources=${managedSrcDir}",
3035+
s"-Ddotty.tests.classes.dottyInterfaces=${(`scala3-interfaces` / Compile / packageBin).value}",
3036+
s"-Ddotty.tests.classes.dottyCompiler=${(ThisProject / Compile / packageBin).value}",
3037+
s"-Ddotty.tests.classes.tastyCore=${(`tasty-core-nonbootstrapped` / Compile / packageBin).value}",
3038+
s"-Ddotty.tests.classes.compilerInterface=${findArtifactPath(externalDeps, "compiler-interface")}",
3039+
s"-Ddotty.tests.classes.scalaLibrary=${(`scala-library-nonbootstrapped` / Compile / packageBin).value}",
3040+
s"-Ddotty.tests.classes.scalaAsm=${findArtifactPath(externalDeps, "scala-asm")}",
3041+
s"-Ddotty.tests.classes.jlineTerminal=${findArtifactPath(externalDeps, "jline-terminal")}",
3042+
s"-Ddotty.tests.classes.jlineReader=${findArtifactPath(externalDeps, "jline-reader")}",
3043+
s"-Ddotty.tools.dotc.semanticdb.test=${(ThisBuild / baseDirectory).value/"tests"/"semanticdb"}",
3044+
"-Ddotty.tests.classes.scalaJSScalalib=" + (`scala-library-sjs` / Compile / packageBin).value,
30193045
"-Ddotty.tests.classes.scalaJSJavalib=" + findArtifactPath(externalJSDeps, "scalajs-javalib"),
3020-
"-Ddotty.tests.classes.scalaJSScalalib=" + findArtifactPath(externalJSDeps, "scalajs-scalalib_2.13"),
30213046
"-Ddotty.tests.classes.scalaJSLibrary=" + findArtifactPath(externalJSDeps, "scalajs-library_2.13"),
30223047
)
30233048
},
3049+
// Configure to use the non-bootstrapped compiler
3050+
managedScalaInstance := false,
3051+
scalaInstance := {
3052+
val externalCompilerDeps = (`scala3-compiler-nonbootstrapped` / Compile / externalDependencyClasspath).value.map(_.data).toSet
3053+
3054+
// IMPORTANT: We need to use actual jars to form the ScalaInstance and not
3055+
// just directories containing classfiles because sbt maintains a cache of
3056+
// compiler instances. This cache is invalidated based on timestamps
3057+
// however this is only implemented on jars, directories are never
3058+
// invalidated.
3059+
val tastyCore = (`tasty-core-nonbootstrapped` / Compile / packageBin).value
3060+
val scalaLibrary = (`scala-library-nonbootstrapped` / Compile / packageBin).value
3061+
val scala3Interfaces = (`scala3-interfaces` / Compile / packageBin).value
3062+
val scala3Compiler = (`scala3-compiler-nonbootstrapped` / Compile / packageBin).value
3063+
3064+
Defaults.makeScalaInstance(
3065+
dottyNonBootstrappedVersion,
3066+
libraryJars = Array(scalaLibrary),
3067+
allCompilerJars = Seq(tastyCore, scala3Interfaces, scala3Compiler) ++ externalCompilerDeps,
3068+
allDocJars = Seq.empty,
3069+
state.value,
3070+
scalaInstanceTopLoader.value
3071+
)
3072+
},
3073+
scalaCompilerBridgeBinaryJar := {
3074+
Some((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
3075+
},
3076+
Test / forkOptions := (Test / forkOptions).value.withWorkingDirectory((ThisBuild / baseDirectory).value),
30243077
)
30253078

30263079
lazy val `scala3-bench` = project.in(file("bench")).asDottyBench(NonBootstrapped)

project/ScalaLibraryPlugin.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ object ScalaLibraryPlugin extends AutoPlugin {
111111
"scala/collection/immutable/DoubleVectorStepper",
112112
"scala/collection/immutable/IntVectorStepper",
113113
"scala/collection/immutable/LongVectorStepper",
114+
"scala/collection/immutable/Range", "scala/collection/immutable/Range$",
114115
"scala/jdk/DoubleAccumulator",
115116
"scala/jdk/IntAccumulator",
116117
"scala/jdk/LongAccumulator",

sjs-compiler-tests/test/scala/dotty/tools/dotc/ScalaJSCompilationTests.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import reporting.TestReporter
1010
import vulpix._
1111
import org.junit.Ignore
1212

13-
@Ignore
1413
@Category(Array(classOf[ScalaJSCompilationTests]))
1514
class ScalaJSCompilationTests {
1615
import ParallelTesting._

tests/neg-scalajs/js-native-members.check

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
-- Warning: tests/neg-scalajs/js-native-members.scala:24:16 ------------------------------------------------------------
1+
-- Warning: tests/neg-scalajs/js-native-members.scala:24:9 -------------------------------------------------------------
22
24 | private[this] def this(x: Int) = this() // ok
3-
| ^
4-
| Ignoring [this] qualifier.
5-
| This syntax will be deprecated in the future; it should be dropped.
6-
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
7-
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
8-
-- Warning: tests/neg-scalajs/js-native-members.scala:28:16 ------------------------------------------------------------
3+
| ^^^^^^
4+
| Ignoring [this] qualifier.
5+
| The syntax `private[this]` will be deprecated in the future; just write `private` instead.
6+
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
7+
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
8+
-- Warning: tests/neg-scalajs/js-native-members.scala:28:9 -------------------------------------------------------------
99
28 | private[this] val a: Int = js.native // error
10-
| ^
11-
| Ignoring [this] qualifier.
12-
| This syntax will be deprecated in the future; it should be dropped.
13-
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
14-
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
15-
-- Warning: tests/neg-scalajs/js-native-members.scala:32:16 ------------------------------------------------------------
10+
| ^^^^^^
11+
| Ignoring [this] qualifier.
12+
| The syntax `private[this]` will be deprecated in the future; just write `private` instead.
13+
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
14+
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
15+
-- Warning: tests/neg-scalajs/js-native-members.scala:32:9 -------------------------------------------------------------
1616
32 | private[this] var d: Int = js.native // error
17-
| ^
18-
| Ignoring [this] qualifier.
19-
| This syntax will be deprecated in the future; it should be dropped.
20-
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
21-
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
22-
-- Warning: tests/neg-scalajs/js-native-members.scala:36:16 ------------------------------------------------------------
17+
| ^^^^^^
18+
| Ignoring [this] qualifier.
19+
| The syntax `private[this]` will be deprecated in the future; just write `private` instead.
20+
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
21+
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
22+
-- Warning: tests/neg-scalajs/js-native-members.scala:36:9 -------------------------------------------------------------
2323
36 | private[this] def g(): Int = js.native // error
24-
| ^
25-
| Ignoring [this] qualifier.
26-
| This syntax will be deprecated in the future; it should be dropped.
27-
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
28-
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
29-
-- Warning: tests/neg-scalajs/js-native-members.scala:49:25 ------------------------------------------------------------
24+
| ^^^^^^
25+
| Ignoring [this] qualifier.
26+
| The syntax `private[this]` will be deprecated in the future; just write `private` instead.
27+
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
28+
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
29+
-- Warning: tests/neg-scalajs/js-native-members.scala:49:18 ------------------------------------------------------------
3030
49 | class X3 private[this] () extends js.Object { // ok
31-
| ^
32-
| Ignoring [this] qualifier.
33-
| This syntax will be deprecated in the future; it should be dropped.
34-
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
35-
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
31+
| ^^^^^^
32+
| Ignoring [this] qualifier.
33+
| The syntax `private[this]` will be deprecated in the future; just write `private` instead.
34+
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
35+
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
3636
-- [E003] Syntax Warning: tests/neg-scalajs/js-native-members.scala:58:44 ----------------------------------------------
3737
58 | def assign[T, U](target: T, source: U): T with U = js.native // ok
3838
| ^^^^

tests/neg-scalajs/js-non-native-members-qualified-private.check

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
-- Warning: tests/neg-scalajs/js-non-native-members-qualified-private.scala:52:28 --------------------------------------
1+
-- Warning: tests/neg-scalajs/js-non-native-members-qualified-private.scala:52:21 --------------------------------------
22
52 | class B private[this] () extends js.Object // ok
3-
| ^
4-
| Ignoring [this] qualifier.
5-
| This syntax will be deprecated in the future; it should be dropped.
6-
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
7-
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
3+
| ^^^^^^
4+
| Ignoring [this] qualifier.
5+
| The syntax `private[this]` will be deprecated in the future; just write `private` instead.
6+
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
7+
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
88
-- Error: tests/neg-scalajs/js-non-native-members-qualified-private.scala:6:32 -----------------------------------------
99
6 | private[Enclosing1] def foo(i: Int): Int = i // error
1010
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/run/classTags.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// scalajs: --skip --pending
12
object Test {
23
type T = String
34

0 commit comments

Comments
 (0)