Skip to content

Commit

Permalink
Remove reflect from scripts and fix incorrect bin-test
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmulder committed May 9, 2017
1 parent 693351f commit cbc1546
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
9 changes: 5 additions & 4 deletions bin/common
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ else
echo "Failed to parse .packages file"
build_all
fi

if [ ! -f "$INTERFACES_JAR" -o ! -f "$MAIN_JAR" -o ! -f "$DOTTY_LIB_JAR" -o ! -f "$TEST_JAR" ]; then
echo ".packages file corrupted, rebuilding"
build_all
fi
fi

################# After this point, jar variables will be set #################
Expand Down Expand Up @@ -142,10 +147,6 @@ if [ "$SCALA_LIBRARY_JAR" == "" ]; then
SCALA_LIBRARY_JAR=$(find_jar "$HOME/.ivy2/cache/org.scala-lang/scala-library/jars" "scala-library-$SCALA_VERSION.jar")
fi

if [ "$SCALA_REFLECT_JAR" == "" ]; then
SCALA_REFLECT_JAR=$(find_jar "$HOME/.ivy2/cache/org.scala-lang/scala-reflect/jars" "scala-reflect-$SCALA_VERSION.jar")
fi

if [ "$SCALA_ASM_JAR" == "" ]; then
SCALA_ASM_JAR=$(find_jar "$HOME/.ivy2/cache/org.scala-lang.modules/scala-asm/bundles" "scala-asm-$SCALA_ASM_VERSION.jar")
fi
Expand Down
7 changes: 3 additions & 4 deletions bin/dotc
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ CompilerMain=dotty.tools.dotc.Main
FromTasty=dotty.tools.dotc.FromTasty
ReplMain=dotty.tools.dotc.repl.Main

if [ ! -f "$SCALA_LIBRARY_JAR" -o ! -f "$SCALA_REFLECT_JAR" -o ! -f "$SCALA_ASM_JAR" -o ! -f "$SBT_INTERFACE_JAR" ]
if [ ! -f "$SCALA_LIBRARY_JAR" -o ! -f "$SCALA_ASM_JAR" -o ! -f "$SBT_INTERFACE_JAR" ]
then
echo To use this script please set
echo SCALA_LIBRARY_JAR to point to scala-library-$SCALA_VERSION.jar "(currently $SCALA_LIBRARY_JAR)"
echo SCALA_REFLECT_JAR to point to scala-reflect-$SCALA_VERSION.jar "(currently $SCALA_REFLECT_JAR)"
echo SCALA_ASM_JAR to point to scala-asm-$SCALA_ASM_VERSION.jar "(currently $SCALA_ASM_JAR)"
echo SBT_INTERFACE_JAR to point to interface-$SBT_VERSION.jar "(currently $SBT_INTERFACE_JAR)"
fi
Expand Down Expand Up @@ -116,9 +115,9 @@ trap onExit INT
classpathArgs () {
if [[ "true" == "$bootstrapped" ]]; then
check_jar "dotty-bootstrapped" "$DOTTY_JAR" "target" 'build_jar "test:runMain dotc.build" target' &> /dev/null
toolchain="$DOTTY_JAR:$DOTTY_LIB_JAR:$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_ASM_JAR:$SBT_INTERFACE_JAR"
toolchain="$DOTTY_JAR:$DOTTY_LIB_JAR:$SCALA_LIBRARY_JAR:$SCALA_ASM_JAR:$SBT_INTERFACE_JAR"
else
toolchain="$SCALA_LIBRARY_JAR:$DOTTY_LIB_JAR:$SCALA_REFLECT_JAR:$SCALA_ASM_JAR:$SBT_INTERFACE_JAR"
toolchain="$SCALA_LIBRARY_JAR:$DOTTY_LIB_JAR:$SCALA_ASM_JAR:$SBT_INTERFACE_JAR"
fi
bcpJars="$INTERFACES_JAR:$MAIN_JAR:$DOTTY_LIB_JAR"
cpJars="$INTERFACES_JAR:$MAIN_JAR:$DOTTY_LIB_JAR:$TEST_JAR"
Expand Down
20 changes: 15 additions & 5 deletions bin/test/TestScripts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ class TestScripts {

private def executeScript(script: String): (Int, String) = {
val sb = new StringBuilder
val ret = Process(script) ! ProcessLogger { line => println(line); sb.append(line) }
val ret = Process(script) ! ProcessLogger { line => println(line); sb.append(line + "\n") }
val output = sb.toString
println(output) // For CI, otherwise "terminal inactive for 5m0s, build cancelled"
(ret, output)
}

Expand Down Expand Up @@ -59,7 +58,7 @@ class TestScripts {

val (retDotr, dotrOutput) = executeScript("./bin/dotr HelloWorld")
assert(
retDotr == 0 && dotrOutput == "hello world",
retDotr == 0 && dotrOutput == "hello world\n",
s"Running hello world exited with status: $retDotr and output: $dotrOutput"
)
}
Expand Down Expand Up @@ -93,8 +92,19 @@ class TestScripts {

/** dotc script should work after corrupting .packages */
@Test def reCreatesPackagesIfNecessary = doUnlessWindows {
executeScript("sed -i.old 's/2.1/2.X/' ./.packages") // That's going to replace 2.11 with 2.X1
val (retFirstBuild, _) = executeScript("./bin/dotc ./tests/pos/HelloWorld.scala")
import java.nio.file.{Paths, Files}
import java.nio.charset.StandardCharsets
val contents =
"""|/Users/fixel/Projects/dotty/interfaces/target/dotty-interfaces-0.1.1-bin-SNAPSHOT-X.jar
|/Users/fixel/Projects/dotty/compiler/target/scala-2.11/dotty-compiler_2.1X-0.1.1-bin-SNAPSHOT.jar
|/Users/fixel/Projects/dotty/library/target/scala-2.11/dotty-library_2.1X-0.1.1-bin-SNAPSHOT.jar
|/Users/fixel/Projects/dotty/doc-tool/target/scala-2.11/dotty-doc_2.1X-0.1.1-bin-SNAPSHOT-tests.jar"""
.stripMargin

Files.write(Paths.get("./.packages"), contents.getBytes(StandardCharsets.UTF_8))

val (retFirstBuild, output) = executeScript("./bin/dotc ./tests/pos/HelloWorld.scala")
assert(output.contains(".packages file corrupted"))
assert(retFirstBuild == 0, "building dotc failed")
}
}
1 change: 1 addition & 0 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ object Build {
settings(
publishArtifact := false,
parallelExecution in Test := false,
testOptions in Test += Tests.Argument(TestFrameworks.JUnit, "-a", "-v"),
libraryDependencies +=
"com.novocode" % "junit-interface" % "0.11" % "test"
)
Expand Down

0 comments on commit cbc1546

Please sign in to comment.