diff options
-rw-r--r-- | .drone.yml | 5 | ||||
-rw-r--r-- | .drone.yml.sig | 2 | ||||
-rwxr-xr-x | bin/common | 33 | ||||
-rwxr-xr-x | bin/dotc | 37 | ||||
-rwxr-xr-x | bin/dotr | 6 | ||||
-rw-r--r-- | bin/test/TestScripts.scala | 23 | ||||
-rw-r--r-- | project/Build.scala | 2 |
7 files changed, 60 insertions, 48 deletions
diff --git a/.drone.yml b/.drone.yml index 544eae07b..83309ef4e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -4,8 +4,9 @@ pipeline: pull: true commands: - ln -s /var/cache/drone/scala-scala scala-scala + - ln -s /var/cache/drone/ivy2 "$HOME/.ivy2" - ./scripts/update-scala-library - - sbt -J-Xmx4096m -J-XX:ReservedCodeCacheSize=512m -J-XX:MaxMetaspaceSize=1024m -Ddotty.drone.mem=4096m -ivy /var/cache/drone/ivy2 "${TEST}" + - sbt -J-Xmx4096m -J-XX:ReservedCodeCacheSize=512m -J-XX:MaxMetaspaceSize=1024m -Ddotty.drone.mem=4096m "${TEST}" when: branch: exclude: gh-pages @@ -33,7 +34,7 @@ pipeline: matrix: TEST: - - test + - ;test;dotty-bin-tests/test - ;publishLocal;dotty-bootstrapped/test - partest-only-no-bootstrap --show-diff --verbose - partest-only --show-diff --verbose diff --git a/.drone.yml.sig b/.drone.yml.sig index 033741bd7..1093928f0 100644 --- a/.drone.yml.sig +++ b/.drone.yml.sig @@ -1 +1 @@ -eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgdGVzdDoKICAgIGltYWdlOiBsYW1wZXBmbC9kb3R0eTpsYXRlc3QKICAgIHB1bGw6IHRydWUKICAgIGNvbW1hbmRzOgogICAgICAtIGxuIC1zIC92YXIvY2FjaGUvZHJvbmUvc2NhbGEtc2NhbGEgc2NhbGEtc2NhbGEKICAgICAgLSAuL3NjcmlwdHMvdXBkYXRlLXNjYWxhLWxpYnJhcnkKICAgICAgLSBzYnQgLUotWG14NDA5Nm0gLUotWFg6U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YgLS12ZXJib3NlCiAgICAtIHBhcnRlc3Qtb25seSAtLXNob3ctZGlmZiAtLXZlcmJvc2UK.VRqZiSgeE6OumPlEvs4TWfxIHNOEVjR_ZmyBmapxZ-U
\ No newline at end of file diff --git a/bin/common b/bin/common index 1cb79fc14..0a084c8a6 100755 --- a/bin/common +++ b/bin/common @@ -8,7 +8,7 @@ function getLastStringOnLineWith { } # Configuration -SCALA_VERSION=$(getLastStringOnLineWith "scalaVersion in") +SCALA_VERSION=$(getLastStringOnLineWith "val scalacVersion") SCALA_BINARY_VERSION=2.11 SCALA_COMPILER_VERSION=$(getLastStringOnLineWith "scala-compiler") SBT_VERSION=$(grep "sbt.version=" "$DOTTY_ROOT/project/build.properties" | sed 's/sbt.version=//') @@ -40,9 +40,9 @@ ERROR_LOG=error.log trap onTerminate SIGTERM onTerminate() { - if [ -f $ERROR_LOG ]; then - cat $ERROR_LOG - rm -f $ERROR_LOG + if [ -f "$ERROR_LOG" ]; then + cat "$ERROR_LOG" + rm -f "$ERROR_LOG" fi exit 1 # $? is lost from subprocess in command substitution. } @@ -52,7 +52,7 @@ function build_jar { # build_jar package path/to/jar/dir ['/some/sed/command'] # # Last arg is optional - cd $DOTTY_ROOT >& /dev/null + cd "$DOTTY_ROOT" >& /dev/null local build_output=$(sbt "$1" || (echo "failed to run: sbt $1" >> $ERROR_LOG; kill -SIGTERM $$)) local jar=$(echo $build_output | sed -n 's/.*Packaging //g; s/ \.\.\..*//g; /^\/.*/p') @@ -68,14 +68,14 @@ function build_jar { cd - >& /dev/null - echo $jar + echo "$jar" } function update_packages { - echo "$INTERFACES_JAR" > $DOTTY_ROOT/.packages - echo "$MAIN_JAR" >> $DOTTY_ROOT/.packages - echo "$DOTTY_LIB_JAR" >> $DOTTY_ROOT/.packages - echo "$TEST_JAR" >> $DOTTY_ROOT/.packages + echo "$INTERFACES_JAR" > "$DOTTY_ROOT/.packages" + echo "$MAIN_JAR" >> "$DOTTY_ROOT/.packages" + echo "$DOTTY_LIB_JAR" >> "$DOTTY_ROOT/.packages" + echo "$TEST_JAR" >> "$DOTTY_ROOT/.packages" } function build_all { @@ -122,19 +122,20 @@ function check_jar { # Usage: # check_jar "name" "path/to/package.jar" "sources/dir" 'lambda to exec on failure' local new_files="$(find "$DOTTY_ROOT/$3" \( -iname "*.scala" -o -iname "*.java" \) -newer "$2")" - if [ ! -z "$new_files" ]; then + # If the find failed, or if it found new files... + if [ "$?" -ne 0 ] || [ ! -z "$new_files" ]; then printf "New files detected in $1, rebuilding..." - rm $2 + rm "$2" eval "$4" printf "done\n" update_packages fi } -check_jar "dotty-interfaces" $INTERFACES_JAR "interfaces/src" 'INTERFACES_JAR=$(build_jar dotty-interfaces/package interfaces/target)' -check_jar "dotty-compiler" $MAIN_JAR "compiler/src" 'MAIN_JAR=$(build_jar dotty-compiler/package compiler/target/scala-$SCALA_BINARY_VERSION)' -check_jar "dotty-library" $DOTTY_LIB_JAR "library/src" 'DOTTY_LIB_JAR=$(build_jar dotty-library/package library/target/scala-$SCALA_BINARY_VERSION)' -check_jar "dotty-tests" $TEST_JAR "compiler/test" 'TEST_JAR=$(build_jar dotty-compiler/test:package compiler/target/scala-$SCALA_BINARY_VERSION /dotty.*-tests\.jar/p)' +check_jar "dotty-interfaces" "$INTERFACES_JAR" "interfaces/src" 'INTERFACES_JAR=$(build_jar dotty-interfaces/package interfaces/target)' +check_jar "dotty-compiler" "$MAIN_JAR" "compiler/src" 'MAIN_JAR=$(build_jar dotty-compiler/package compiler/target/scala-$SCALA_BINARY_VERSION)' +check_jar "dotty-library" "$DOTTY_LIB_JAR" "library/src" 'DOTTY_LIB_JAR=$(build_jar dotty-library/package library/target/scala-$SCALA_BINARY_VERSION)' +check_jar "dotty-tests" "$TEST_JAR" "compiler/test" 'TEST_JAR=$(build_jar dotty-compiler/test:package compiler/target/scala-$SCALA_BINARY_VERSION /dotty.*-tests\.jar/p)' # Autodetecting the scala-library location, in case it wasn't provided by an environment variable if [ "$SCALA_LIBRARY_JAR" == "" ]; then @@ -1,4 +1,5 @@ #!/usr/bin/env bash + # This script is used for running compiler standalone(outside of sbt) # it's based on miniboxing script and paulp's launcher script @@ -10,10 +11,10 @@ fi DOTTY_ROOT="$(dirname "$DOTTY_ROOT")" DOTTY_ROOT="$( cd "$DOTTY_ROOT" >& /dev/null && pwd )/.." # absolute -source $DOTTY_ROOT/bin/common +source "$DOTTY_ROOT/bin/common" # dotc.build test places bootstrapped jar here -DOTTY_JAR=$DOTTY_ROOT/dotty.jar +DOTTY_JAR="$DOTTY_ROOT/dotty.jar" CompilerMain=dotty.tools.dotc.Main FromTasty=dotty.tools.dotc.FromTasty @@ -29,13 +30,13 @@ then fi ifdebug () { - [[ -n $debug ]] && eval "$@" + [[ -n "$debug" ]] && eval "$@" } echoErr () { echo >&2 "$@" } dlog () { - [[ -n $debug ]] && echoErr "$@" + [[ -n "$debug" ]] && echoErr "$@" } die() { @@ -52,7 +53,7 @@ echoErr "" execCommand () { ifdebug echoArgs "$@" ignore="$(cat "$HOME/.scala_ignore_crashes" 2>/dev/null)" - if [[ $ignore == "true" ]]; then + if [[ "$ignore" == "true" ]]; then "$@" 2>&1 | scala-crash-filter else $@ @@ -62,11 +63,11 @@ execCommand () { # restore stty settings (echo in particular) restoreSttySettings () { dlog "" && dlog "[restore stty] $saved_stty" - stty $saved_stty && saved_stty="" + stty "$saved_stty" && saved_stty="" } onExit () { - [[ -n $saved_stty ]] && restoreSttySettings + [[ -n "$saved_stty" ]] && restoreSttySettings exit $scala_exit_status } @@ -103,7 +104,7 @@ addResidual () { } onExit() { - [[ -n $saved_stty ]] && restoreSttySettings + [[ -n "$saved_stty" ]] && restoreSttySettings exit $scala_exit_status } @@ -113,8 +114,8 @@ trap onExit INT # If using the boot classpath, also pass an empty classpath # to java to suppress "." from materializing. classpathArgs () { - if [[ "true" == $bootstrapped ]]; then - check_jar "dotty-bootstrapped" $DOTTY_JAR "target" 'build_jar "test:runMain dotc.build" target' &> /dev/null + 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_COMPILER_JAR:$SBT_INTERFACE_JAR" else toolchain="$SCALA_LIBRARY_JAR:$DOTTY_LIB_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$SBT_INTERFACE_JAR" @@ -129,7 +130,7 @@ classpathArgs () { format=windows fi - if [[ -n $bootcp ]]; then + if [[ -n "$bootcp" ]]; then boot_classpath="$(cygpath --path --$format "$toolchain:$bcpJars")" classpath="$(cygpath --path --$format "$cpJars")" cpArgs="-Xbootclasspath/a:$boot_classpath -classpath $classpath" @@ -138,7 +139,7 @@ classpathArgs () { cpArgs="-classpath $classpath" fi else - if [[ -n $bootcp ]]; then + if [[ -n "$bootcp" ]]; then cpArgs="-Xbootclasspath/a:$toolchain:$bcpJars -classpath $cpJars" else cpArgs="-classpath $toolchain:$cpJars" @@ -159,7 +160,7 @@ require_arg () { } -main_class=$CompilerMain +main_class="$CompilerMain" while [[ $# -gt 0 ]]; do case "$1" in @@ -172,11 +173,11 @@ case "$1" in # Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222 -Oshort) addJava "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" && shift ;; - -repl) main_class=$ReplMain && shift ;; - -tasty) main_class=$FromTasty && shift ;; - -compile) main_class=$CompilerMain && shift ;; - -run) main_class=$ReplMain && shift ;; - -fsc) main_class=$FscMain && shift ;; + -repl) main_class="$ReplMain" && shift ;; + -tasty) main_class="$FromTasty" && shift ;; + -compile) main_class="$CompilerMain" && shift ;; + -run) main_class="$ReplMain" && shift ;; + -fsc) main_class="$FscMain" && shift ;; -bootcp) bootcp=true && shift ;; -nobootcp) unset bootcp && shift ;; -colors) colors=true && shift ;; @@ -9,7 +9,7 @@ DOTTY_ROOT="$(dirname "$DOTTY_ROOT")" DOTTY_ROOT="$( cd "$DOTTY_ROOT" >& /dev/null && pwd )/.." # absolute # Load common functions and variables -source $DOTTY_ROOT/bin/common +source "$DOTTY_ROOT"/bin/common CLASS_PATH="-classpath .:$DOTTY_LIB_JAR:.:$SCALA_LIBRARY_JAR" @@ -17,7 +17,7 @@ function runMain { local jbin=$(which "java") if [ ! -z "$JAVA_BIN" ]; then - jbin=$JAVA_BIN + jbin="$JAVA_BIN" fi if [ "$jbin" == "" ]; then @@ -28,7 +28,7 @@ function runMain { fi } -first_arg=$1 +first_arg="$1" if [ -z "$1" ]; then echo "Starting dotty REPL..." diff --git a/bin/test/TestScripts.scala b/bin/test/TestScripts.scala index 0558c0480..6543ac7b7 100644 --- a/bin/test/TestScripts.scala +++ b/bin/test/TestScripts.scala @@ -17,16 +17,18 @@ class TestScripts { private def executeScript(script: String): (Int, String) = { val sb = new StringBuilder - val ret = Process(script) ! ProcessLogger(sb append _) - (ret, sb.toString) + val ret = Process(script) ! ProcessLogger { line => println(line); sb.append(line) } + val output = sb.toString + println(output) // For CI, otherwise "terminal inactive for 5m0s, build cancelled" + (ret, output) } - private def deletePackages: Unit = { - def delete(path: String) = { - val file = new JFile(path) - if (file.exists) file.delete() - } + private def delete(path: String) = { + val file = new JFile(path) + if (file.exists) file.delete() + } + private def deletePackages: Unit = { try { for (jar <- Source.fromFile("./.packages").getLines()) delete(jar) @@ -88,4 +90,11 @@ class TestScripts { ret == 0 && !output.contains("rebuilding"), s"Project recompiled when it didn't need to be. Status $ret, output:$lineSep$output") } + + /** 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") + assert(retFirstBuild == 0, "building dotc failed") + } } diff --git a/project/Build.scala b/project/Build.scala index a6505a12c..96ee7cdf7 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -11,7 +11,7 @@ import sbt.Package.ManifestAttributes object DottyBuild extends Build { - val scalacVersion = "2.11.5" + val scalacVersion = "2.11.5" // Do not rename, this is grepped in bin/common. val dottyOrganization = "ch.epfl.lamp" val dottyVersion = { |