Permalink
Browse files

Test case code for testing compilation cancellation bug.

It's implemented in a very hacky way because sbt doesn't really
have functionality for cancelling compilation.

It was enough to reproduce reliably the bug reported by the Eclipse
IDE team.
  • Loading branch information...
1 parent d779303 commit ece9b71988cf55bc881cd2f505767d1b01a484c5 @gkossakowski committed Jul 19, 2013
@@ -127,7 +127,7 @@ object AnalyzingCompiler
{
import sbt.IO.{copy, createDirectory, zip, jars, unzip, withTemporaryDirectory}
- // Note: The Scala build now depends on some details of this method:
+ // Note: The Scala build now depends on some details of this method:
// https://github.com/jsuereth/scala/commit/3431860048df8d2a381fb85a526097e00154eae0
/** Extract sources from source jars, compile them with the xsbti interfaces on the classpath, and package the compiled classes and
* any resources from the source jars into a final jar.*/
@@ -159,5 +159,10 @@ object AnalyzingCompiler
private[this] object IgnoreProgress extends CompileProgress {
def startUnit(phase: String, unitPath: String) {}
- def advance(current: Int, total: Int) = true
+ def advance(current: Int, total: Int): Boolean = {
+ val shouldCancel = java.lang.Boolean.valueOf(System.getProperty("xsbt.inc.cancel"))
+ val moreThanHalfProcessed = current > total/2
+ val willCancel = (shouldCancel && moreThanHalfProcessed)
+ !willCancel
+ }
}
@@ -0,0 +1 @@
+//logLevel in compile := Level.Debug
@@ -0,0 +1,5 @@
+package test
+
+trait A
+
+// some comment
@@ -0,0 +1,5 @@
+package test
+
+trait A
+
+// some comment 2
@@ -0,0 +1,3 @@
+package test
+
+trait A
@@ -0,0 +1,3 @@
+package test
+
+class B
@@ -0,0 +1,16 @@
+# Tests for bug when sbt would introduce dependency on non-existing
+# class files corresponding to packages
+
+$ exec echo "First compile"
+> compile
+$ copy-file changes/A1.scala src/main/scala/test/A.scala
+$ exec echo "Set cancel to true"
+> eval System.setProperty("xsbt.inc.cancel", true.toString)
+$ exec echo "Second compile (should be cancelled)"
+> compile
+$ exec echo "Set cancel to false"
+> eval System.setProperty("xsbt.inc.cancel", false.toString)
+$ exec echo "This compile (should recompile A.scala)"
+> compile
+> last compile
+$ fail

0 comments on commit ece9b71

Please sign in to comment.