Skip to content

Allow for dottyCompileBisect to take multiple files #15804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions project/scripts/dottyCompileBisect.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Usage
// > scala-cli project/scripts/dottyCompileBisect.scala -- File.scala
// > scala-cli project/scripts/dottyCompileBisect.scala -- File1.scala File2.scala
//
// This script will bisect the compilation failure starting with a fast bisection on released nightly builds.
// Then it will bisect the commits between the last nightly that worked and the first nightly that failed.
Expand All @@ -9,19 +9,19 @@ import sys.process._
import scala.io.Source
import Releases.Release

@main def dottyCompileBisect(file: String): Unit =
val releaseBisect = ReleaseBisect(file)
@main def dottyCompileBisect(files: String*): Unit =
val releaseBisect = ReleaseBisect(files.toList)
val fistBadRelease = releaseBisect.bisect(Releases.allReleases)
println("\nFinished bisecting releases\n")
fistBadRelease.previous match
case Some(lastGoodRelease) =>
println(s"Last good release: $lastGoodRelease\nFirst bad release: $fistBadRelease\n")
val commitBisect = CommitBisect(file)
val commitBisect = CommitBisect(files.toList)
commitBisect.bisect(lastGoodRelease.hash, fistBadRelease.hash)
case None =>
println(s"No good release found")

class ReleaseBisect(file: String):
class ReleaseBisect(files: List[String]):

def bisect(releases: Vector[Release]): Release =
assert(releases.length > 1, "Need at least 2 releases to bisect")
Expand All @@ -35,7 +35,7 @@ class ReleaseBisect(file: String):

private def isGoodRelease(release: Release): Boolean =
println(s"Testing ${release.version}")
val res = s"""scala-cli compile $file -S "${release.version}"""".!
val res = s"""scala-cli compile ${files.mkString(" ")} -S "${release.version}"""".!
val isGood = res == 0
println(s"Test result: ${release.version} is a ${if isGood then "good" else "bad"} release\n")
isGood
Expand Down Expand Up @@ -64,10 +64,10 @@ object Releases:

override def toString: String = version

class CommitBisect(file: String):
class CommitBisect(files: List[String]):
def bisect(lastGoodHash: String, fistBadHash: String): Unit =
println(s"Starting bisecting commits $lastGoodHash..$fistBadHash\n")
"git bisect start".!
s"git bisect bad $fistBadHash".!
s"git bisect good $lastGoodHash".!
s"git bisect run sh project/scripts/dottyCompileBisect.sh $file".!
s"git bisect run sh project/scripts/dottyCompileBisect.sh ${files.mkString(" ")}".!
4 changes: 2 additions & 2 deletions project/scripts/dottyCompileBisect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#
# Note: Use dottyCompileBisect.scala for faster bisection over commits that spans several days

file="$1"
files=$@
shift

rm -r out
mkdir out
mkdir out/bisect

sbt "clean; scalac -d out/bisect $file"
sbt "clean; scalac -d out/bisect $files"