@@ -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,30 @@ 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
+ * We change something about the code in the second run to force the linker
44
+ * to actually re-run.
45
+ */
46
+ def classDef (text : String ) =
47
+ MemClassDefIRFile (mainTestClassDef(consoleLog(str(text))))
48
+
49
+ val moduleInitializers = MainTestModuleInitializers
50
+
51
+ val config = StandardConfig ().withCheckIR(true ).withClosureCompiler(true )
52
+ val linker = StandardImpl .linker(config)
53
+
54
+ val output = MemOutputDirectory ()
55
+ val logger = new ScalaConsoleLogger (Level .Error )
56
+
57
+ for {
58
+ lib <- TestIRRepo .minilib
59
+ _ <- linker.link(lib :+ classDef(" test 1" ), moduleInitializers, output, logger)
60
+ _ <- linker.link(lib :+ classDef(" test 2" ), moduleInitializers, output, logger)
61
+ } yield ()
62
+ }
33
63
}
0 commit comments