Skip to content

Commit 337fd37

Browse files
committed
fix: make tests work
1 parent 0afbd54 commit 337fd37

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
@@ -515,3 +515,20 @@ jobs:
515515
- uses: sbt/setup-sbt@v1
516516
- name: Test `tasty-core-bootstrapped`
517517
run: ./project/scripts/sbt tasty-core-bootstrapped-new/test
518+
519+
test-scala-js:
520+
runs-on: ubuntu-latest
521+
needs: [scala3-compiler-bootstrapped, tasty-core-bootstrapped, scala3-staging, scala3-tasty-inspector, scala-library-sjs]
522+
steps:
523+
- name: Git Checkout
524+
uses: actions/checkout@v5
525+
526+
- name: Set up JDK 17
527+
uses: actions/setup-java@v5
528+
with:
529+
distribution: 'temurin'
530+
java-version: 17
531+
cache: 'sbt'
532+
- uses: sbt/setup-sbt@v1
533+
- name: Test Scala.js
534+
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
@@ -1968,7 +1968,7 @@ object Build {
19681968
// We add a dependency to the JVM library to have the classfile available
19691969
// (as they are not part of this artifact)
19701970
.dependsOn(`scala3-library-bootstrapped-new`)
1971-
.enablePlugins(ScalaLibraryPlugin)
1971+
.enablePlugins(ScalaLibraryPlugin, DottyJSPlugin)
19721972
.settings(publishSettings)
19731973
.settings(
19741974
name := "scala-library-sjs",
@@ -2017,7 +2017,9 @@ object Build {
20172017
))
20182018
.flatMap(_.relativeTo(baseDirectory.value / "src")).toSet
20192019

2020-
files.filterNot(file =>
2020+
files.filterNot(_.getPath().contains("BoxesRunTime.scala"))
2021+
.filterNot(_.getPath().contains("ScalaNumber.scala"))
2022+
.filterNot(file =>
20212023
file.relativeTo((`scala-library-bootstrapped` / baseDirectory).value / "src")
20222024
.exists(overwrittenSources.contains))
20232025

@@ -2611,6 +2613,7 @@ object Build {
26112613
s"-Ddotty.tests.classes.tastyCore=${(`tasty-core-bootstrapped-new` / Compile / packageBin).value}",
26122614
s"-Ddotty.tests.classes.compilerInterface=${findArtifactPath(externalDeps, "compiler-interface")}",
26132615
s"-Ddotty.tests.classes.scalaLibrary=${(`scala-library-bootstrapped` / Compile / packageBin).value}",
2616+
s"-Ddotty.tests.classes.scalaJSScalalib=${(`scala-library-sjs` / Compile / packageBin).value}",
26142617
s"-Ddotty.tests.classes.scalaAsm=${findArtifactPath(externalDeps, "scala-asm")}",
26152618
s"-Ddotty.tests.classes.jlineTerminal=${findArtifactPath(externalDeps, "jline-terminal")}",
26162619
s"-Ddotty.tests.classes.jlineReader=${findArtifactPath(externalDeps, "jline-reader")}",
@@ -3148,10 +3151,15 @@ object Build {
31483151
)
31493152

31503153
lazy val sjsCompilerTests = project.in(file("sjs-compiler-tests")).
3151-
dependsOn(`scala3-compiler` % "test->test").
3154+
dependsOn(`scala3-compiler-bootstrapped-new` % "test->test").
31523155
settings(
3153-
commonNonBootstrappedSettings,
3154-
3156+
(Compile / scalaSource) := baseDirectory.value / "src",
3157+
(Test / scalaSource) := baseDirectory.value / "test",
3158+
(Compile / javaSource) := baseDirectory.value / "src",
3159+
(Test / javaSource) := baseDirectory.value / "test",
3160+
(Compile / resourceDirectory) := baseDirectory.value / "resources",
3161+
(Test / resourceDirectory) := baseDirectory.value / "test-resources",
3162+
scalaVersion := (`scala3-compiler-bootstrapped-new` / scalaVersion).value,
31553163
libraryDependencies ++= Seq(
31563164
"org.scala-js" %% "scalajs-linker" % scalaJSVersion % Test cross CrossVersion.for3Use2_13,
31573165
"org.scala-js" %% "scalajs-env-nodejs" % "1.3.0" % Test cross CrossVersion.for3Use2_13,
@@ -3160,18 +3168,63 @@ object Build {
31603168
// Change the baseDirectory when running the tests
31613169
Test / baseDirectory := baseDirectory.value.getParentFile,
31623170

3163-
javaOptions ++= (`scala3-compiler` / javaOptions).value,
3171+
javaOptions ++= (`scala3-compiler-bootstrapped-new` / javaOptions).value,
31643172
javaOptions ++= {
3165-
val externalJSDeps = (`scala3-library-bootstrappedJS` / Compile / externalDependencyClasspath).value
3166-
val dottyLibraryJSJar = (`scala3-library-bootstrappedJS` / Compile / packageBin).value.getAbsolutePath
3173+
val externalJSDeps = (`scala-library-sjs` / Compile / externalDependencyClasspath).value
3174+
3175+
val managedSrcDir = {
3176+
// Populate the directory
3177+
(`scala3-compiler-bootstrapped-new` / Compile / managedSources).value
3178+
3179+
(`scala3-compiler-bootstrapped-new` / Compile / sourceManaged).value
3180+
}
3181+
3182+
val externalDeps = (`scala3-compiler-bootstrapped-new` / Runtime / externalDependencyClasspath).value
31673183

31683184
Seq(
3169-
"-Ddotty.tests.classes.dottyLibraryJS=" + dottyLibraryJSJar,
3185+
s"-Ddotty.tests.dottyCompilerManagedSources=${managedSrcDir}",
3186+
s"-Ddotty.tests.classes.dottyInterfaces=${(`scala3-interfaces` / Compile / packageBin).value}",
3187+
s"-Ddotty.tests.classes.dottyCompiler=${(ThisProject / Compile / packageBin).value}",
3188+
s"-Ddotty.tests.classes.tastyCore=${(`tasty-core-nonbootstrapped` / Compile / packageBin).value}",
3189+
s"-Ddotty.tests.classes.compilerInterface=${findArtifactPath(externalDeps, "compiler-interface")}",
3190+
s"-Ddotty.tests.classes.scalaLibrary=${(`scala-library-nonbootstrapped` / Compile / packageBin).value}",
3191+
s"-Ddotty.tests.classes.scalaAsm=${findArtifactPath(externalDeps, "scala-asm")}",
3192+
s"-Ddotty.tests.classes.jlineTerminal=${findArtifactPath(externalDeps, "jline-terminal")}",
3193+
s"-Ddotty.tests.classes.jlineReader=${findArtifactPath(externalDeps, "jline-reader")}",
3194+
s"-Ddotty.tools.dotc.semanticdb.test=${(ThisBuild / baseDirectory).value/"tests"/"semanticdb"}",
3195+
"-Ddotty.tests.classes.scalaJSScalalib=" + (`scala-library-sjs` / Compile / packageBin).value,
31703196
"-Ddotty.tests.classes.scalaJSJavalib=" + findArtifactPath(externalJSDeps, "scalajs-javalib"),
3171-
"-Ddotty.tests.classes.scalaJSScalalib=" + findArtifactPath(externalJSDeps, "scalajs-scalalib_2.13"),
31723197
"-Ddotty.tests.classes.scalaJSLibrary=" + findArtifactPath(externalJSDeps, "scalajs-library_2.13"),
31733198
)
31743199
},
3200+
// Configure to use the non-bootstrapped compiler
3201+
managedScalaInstance := false,
3202+
scalaInstance := {
3203+
val externalCompilerDeps = (`scala3-compiler-nonbootstrapped` / Compile / externalDependencyClasspath).value.map(_.data).toSet
3204+
3205+
// IMPORTANT: We need to use actual jars to form the ScalaInstance and not
3206+
// just directories containing classfiles because sbt maintains a cache of
3207+
// compiler instances. This cache is invalidated based on timestamps
3208+
// however this is only implemented on jars, directories are never
3209+
// invalidated.
3210+
val tastyCore = (`tasty-core-nonbootstrapped` / Compile / packageBin).value
3211+
val scalaLibrary = (`scala-library-nonbootstrapped` / Compile / packageBin).value
3212+
val scala3Interfaces = (`scala3-interfaces` / Compile / packageBin).value
3213+
val scala3Compiler = (`scala3-compiler-nonbootstrapped` / Compile / packageBin).value
3214+
3215+
Defaults.makeScalaInstance(
3216+
dottyNonBootstrappedVersion,
3217+
libraryJars = Array(scalaLibrary),
3218+
allCompilerJars = Seq(tastyCore, scala3Interfaces, scala3Compiler) ++ externalCompilerDeps,
3219+
allDocJars = Seq.empty,
3220+
state.value,
3221+
scalaInstanceTopLoader.value
3222+
)
3223+
},
3224+
scalaCompilerBridgeBinaryJar := {
3225+
Some((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
3226+
},
3227+
Test / forkOptions := (Test / forkOptions).value.withWorkingDirectory((ThisBuild / baseDirectory).value),
31753228
)
31763229

31773230
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)