forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change encoding MegaPhase name in progress tracking
also add sbt-bridge test for CompileProgress
- Loading branch information
1 parent
ef9fabc
commit c0190c2
Showing
7 changed files
with
129 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package xsbt | ||
|
||
import org.junit.{ Test, Ignore } | ||
import org.junit.Assert._ | ||
|
||
/**Only does some rudimentary checks to assert compat with sbt. | ||
* More thorough tests are found in compiler/test/dotty/tools/dotc/sbt/ProgressCallbackTest.scala | ||
*/ | ||
class CompileProgressSpecification { | ||
|
||
@Test | ||
def multipleFilesVisitSamePhases = { | ||
val srcA = """class A""" | ||
val srcB = """class B""" | ||
val compilerForTesting = new ScalaCompilerForUnitTesting | ||
val Seq(phasesA, phasesB) = compilerForTesting.extractEnteredPhases(srcA, srcB) | ||
assertTrue("expected some phases, was empty", phasesA.nonEmpty) | ||
assertEquals(phasesA, phasesB) | ||
} | ||
|
||
@Test | ||
def multipleFiles = { | ||
val srcA = """class A""" | ||
val srcB = """class B""" | ||
val compilerForTesting = new ScalaCompilerForUnitTesting | ||
val allPhases = compilerForTesting.extractProgressPhases(srcA, srcB) | ||
assertTrue("expected some phases, was empty", allPhases.nonEmpty) | ||
val someExpectedPhases = // just check some "fundamental" phases, don't put all phases to avoid brittleness | ||
Set( | ||
"parser", | ||
"typer (indexing)", "typer (typechecking)", "typer (checking java)", | ||
"sbt-deps", | ||
"extractSemanticDB", | ||
"posttyper", | ||
"sbt-api", | ||
"SetRootTree", | ||
"pickler", | ||
"inlining", | ||
"postInlining", | ||
"staging", | ||
"splicing", | ||
"pickleQuotes", | ||
"MegaPhase{pruneErasedDefs,...,arrayConstructors}", | ||
"erasure", | ||
"constructors", | ||
"genSJSIR", | ||
"genBCode" | ||
) | ||
val missingExpectedPhases = someExpectedPhases -- allPhases.toSet | ||
val msgIfMissing = | ||
s"missing expected phases: $missingExpectedPhases. " + | ||
s"Either the compiler phases changed, or the encoding of Run.SubPhases.subPhase" | ||
assertTrue(msgIfMissing, missingExpectedPhases.isEmpty) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package xsbti | ||
|
||
import xsbti.compile.CompileProgress | ||
|
||
import scala.collection.mutable | ||
|
||
class TestCompileProgress extends CompileProgress: | ||
class Run: | ||
private[TestCompileProgress] val _phases: mutable.Set[String] = mutable.LinkedHashSet.empty | ||
private[TestCompileProgress] val _unitPhases: mutable.Map[String, mutable.Set[String]] = mutable.LinkedHashMap.empty | ||
|
||
def phases: List[String] = _phases.toList | ||
def unitPhases: collection.MapView[String, List[String]] = _unitPhases.view.mapValues(_.toList) | ||
|
||
private val _runs: mutable.ListBuffer[Run] = mutable.ListBuffer.empty | ||
private var _currentRun: Run = new Run | ||
|
||
def runs: List[Run] = _runs.toList | ||
|
||
def completeRun(): Unit = | ||
_runs += _currentRun | ||
_currentRun = new Run | ||
|
||
override def startUnit(phase: String, unitPath: String): Unit = | ||
_currentRun._unitPhases.getOrElseUpdate(unitPath, mutable.LinkedHashSet.empty) += phase | ||
|
||
override def advance(current: Int, total: Int, prevPhase: String, nextPhase: String): Boolean = | ||
_currentRun._phases += prevPhase | ||
_currentRun._phases += nextPhase | ||
true |