@@ -16,9 +16,13 @@ import org.junit.Test
16
16
17
17
import org .scalajs .junit .async ._
18
18
19
+ import org .scalajs .logging ._
20
+
19
21
import org .scalajs .linker .interface .StandardConfig
20
22
23
+ import org .scalajs .linker .testutils .{MemClassDefIRFile , TestIRRepo }
21
24
import org .scalajs .linker .testutils .LinkingUtils ._
25
+ import org .scalajs .linker .testutils .TestIRBuilder ._
22
26
23
27
class GCCLinkerTest {
24
28
import scala .concurrent .ExecutionContext .Implicits .global
@@ -30,4 +34,27 @@ class GCCLinkerTest {
30
34
*/
31
35
testLink(Nil , Nil , config = StandardConfig ().withClosureCompiler(true ))
32
36
}
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
+ }
33
60
}
0 commit comments