8000 Test that we can link twice on the same linker with GCC · gzm0/scala-js@c033aaf · GitHub
[go: up one dir, main page]

Skip to content

Commit c033aaf

Browse files
committed
Test that we can link twice on the same linker with GCC
Ensures that we catch issues like this: scala-js#4917 (comment)
1 parent 8ab1d88 commit c033aaf

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

linker/jvm/src/test/scala/org/scalajs/linker/GCCLinkerTest.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ import org.junit.Test
1616

1717
import org.scalajs.junit.async._
1818

19+
import org.scalajs.logging._
20+
1921
import org.scalajs.linker.interface.StandardConfig
2022

23+
import org.scalajs.linker.testutils.{MemClassDefIRFile, TestIRRepo}
2124
import org.scalajs.linker.testutils.LinkingUtils._
25+
import org.scalajs.linker.testutils.TestIRBuilder._
2226

2327
class GCCLinkerTest {
2428
import scala.concurrent.ExecutionContext.Implicits.global
@@ -30,4 +34,27 @@ class GCCLinkerTest {
3034
*/
3135
testLink(Nil, Nil, config = StandardConfig().withClosureCompiler(true))
3236
}
37+
38+
@Test
39+
def linkIncrementalSmoke(): AsyncResult = await {
40+
/* Check that linking twice works. GCC trees are highly mutable, so if we
41+
* (re-)use them wrongly over multiple runs, things can fail unexpectedly.
42+
*/
43+
val classDefs = MemClassDefIRFile(
44+
mainTestClassDef(consoleLog(str("test")))) :: Nil
45+
46+
val moduleInitializers = MainTestModuleInitializers
47+
48+
val config = StandardConfig().withCheckIR(true).withClosureCompiler(true)
49+
val linker = StandardImpl.linker(config)
50+
51+
val output = MemOutputDirectory()
52+
val logger = new ScalaConsoleLogger(Level.Error)
53+
54+
for {
55+
lib <- TestIRRepo.minilib
56+
_ <- linker.link(lib ++ classDefs, moduleInitializers, output, logger)
57+
_ <- linker.link(lib ++ classDefs, moduleInitializers, output, logger)
58+
} yield ()
59+
}
3360
}

0 commit comments

Comments
 (0)
0