summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeth Tisue <seth@tisue.net>2017-02-16 13:50:52 -0800
committerGitHub <noreply@github.com>2017-02-16 13:50:52 -0800
commitc8e550420a1fd9bd5958671bbaed2bfadc88ba60 (patch)
tree2da3345d1826908750420ea3f420f802f82d5f2e
parent98a7d4ce0234dc1c4b080ecaeed9ced09d39578a (diff)
parentf207ffc42927f3aae1543ba476b8c48ff4e1b7b4 (diff)
downloadscala-c8e550420a1fd9bd5958671bbaed2bfadc88ba60.tar.gz
scala-c8e550420a1fd9bd5958671bbaed2bfadc88ba60.tar.bz2
scala-c8e550420a1fd9bd5958671bbaed2bfadc88ba60.zip
Merge pull request #5684 from SethTisue/partest-sbt-only-plz
run partest from sbt always, command line never
-rw-r--r--project/PartestUtil.scala2
-rwxr-xr-xtest/partest152
-rwxr-xr-xtools/partest-ack131
-rwxr-xr-xtools/partest-paths27
4 files changed, 1 insertions, 311 deletions
diff --git a/project/PartestUtil.scala b/project/PartestUtil.scala
index ab7e62b3b4..23570a88ec 100644
--- a/project/PartestUtil.scala
+++ b/project/PartestUtil.scala
@@ -90,6 +90,6 @@ object PartestUtil {
val ScalacOptsParser = (token("-Dpartest.scalac_opts=") ~ token(NotSpace)) map { case opt ~ v => opt + v }
val P = oneOf(knownUnaryOptions.map(x => token(x))) | SrcPath | TestPathParser | Grep | ScalacOptsParser
- (Space ~> repsep(P, oneOrMore(Space))).map(_.mkString(" ")).?.map(_.getOrElse("")) <~ OptSpace
+ (Space ~> repsep(P, oneOrMore(Space))).map(_.mkString(" ")).?.map(_.getOrElse(""))
}
}
diff --git a/test/partest b/test/partest
deleted file mode 100755
index d74176aa8a..0000000000
--- a/test/partest
+++ /dev/null
@@ -1,152 +0,0 @@
-#!/usr/bin/env bash
-#
-##############################################################################
-# Scala test runner 2.10.0
-##############################################################################
-# (c) 2002-2013 LAMP/EPFL
-#
-# This is free software; see the distribution for copying conditions.
-# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-##############################################################################
-
-findScalaHome () {
- # see SI-2092 and SI-5792
- local source="${BASH_SOURCE[0]}"
- while [ -h "$source" ] ; do
- local linked="$(readlink "$source")"
- local dir="$( cd -P $(dirname "$source") && cd -P $(dirname "$linked") && pwd )"
- source="$dir/$(basename "$linked")"
- done
- ( ( cd -P "$(dirname "$source")/.." > /dev/null ) && pwd )
-}
-
-# Use tput to detect color-capable terminal.
-# (note: I have found that on Cygwin, the script sometimes dies here.
-# it doesn't happen from the Cygwin prompt when ssh'ing in to
-# jenkins-worker-windows-publish, only when I make a Jenkins job
-# that runs this script. I don't know why. it may have to do with
-# which bash flags are set (-e? -x?) and with bash flags propagating
-# from one script to another? not sure. anyway, normally in a CI
-# context we run partest through sbt, not through this script, so I'm
-# not investigating further for now.)
-term_colors=$(tput colors 2>/dev/null)
-if [[ $? == 0 ]] && [[ $term_colors -gt 2 ]]; then
- git_diff_options="--color=always --word-diff"
- color_opts="-Dpartest.colors=$term_colors"
-else
- unset color_opts
- git_diff_options="--nocolor"
-fi
-
-cygwin=false;
-darwin=false;
-case "`uname`" in
- CYGWIN*) cygwin=true ;;
- Darwin*) darwin=true ;;
-esac
-
-# Finding the root folder for this Scala distribution
-SCALA_HOME="$(findScalaHome)"
-
-if $cygwin; then
- SCALA_HOME=`cygpath --windows --short-name "$SCALA_HOME"`
- SCALA_HOME=`cygpath --unix "$SCALA_HOME"`
-fi
-
-# Let sbt construct the classpath used to run partest (downloading partest from maven if necessary)
-# PARTEST_CLASSPATH=""
-if [ -z "$PARTEST_CLASSPATH" ] ; then
- if [ ! -f "$SCALA_HOME/build/quick/partest.properties" ] ; then
- (cd "$SCALA_HOME" && sbt dist/mkQuick) # builds quick, downloads partest and writes classpath to build/quick/partest.properties
- fi
-
- PARTEST_CLASSPATH=$( cat "$SCALA_HOME/build/quick/partest.properties" | grep partest.classpath | sed -e 's/\\:/:/g' | cut -f2- -d= )
-
- # sanity check, disabled to save time
- # $( javap -classpath $PARTEST_CLASSPATH scala.tools.partest.nest.NestRunner &> /dev/null ) || unset PARTEST_CLASSPATH
-fi
-
-# if [ -z "$PARTEST_CLASSPATH" ] ; then
-# if [ -f "$SCALA_HOME/lib/scala-partest.jar" ] ; then
-# for ext in "$SCALA_HOME"/lib/* ; do
-# if [ -z "$PARTEST_CLASSPATH" ] ; then
-# PARTEST_CLASSPATH="$ext"
-# else
-# PARTEST_CLASSPATH="$PARTEST_CLASSPATH:$ext"
-# fi
-# done
-# elif [ -f "$SCALA_HOME/build/pack/lib/scala-partest.jar" ] ; then
-# for lib in `echo "scala-partest scala-library scala-parser-combinators scala-xml scala-reflect scala-compiler diffutils"`; do
-# ext="$SCALA_HOME/build/pack/lib/$lib.jar"
-# if [ -z "$PARTEST_CLASSPATH" ] ; then
-# PARTEST_CLASSPATH="$ext"
-# else
-# PARTEST_CLASSPATH="$PARTEST_CLASSPATH:$ext"
-# fi
-# done
-# fi
-# fi
-
-# Locate a javac command
-# Try: JAVA_HOME, sibling to specific JAVACMD, or PATH
-# Don't fail if there is no javac, since not all tests require it.
-if [ -z "$JAVAC_CMD" ] ; then
- if [ -n "${JAVA_HOME}" ] && [ -f "${JAVA_HOME}/bin/javac" ] ; then
- JAVAC_CMD="${JAVA_HOME}/bin/javac"
- fi
- if [ -z "$JAVAC_CMD" ] && [ -n "$JAVACMD" ] ; then
- JDIR=`dirname "${JAVACMD}"`
- JAVAC_CMD="${JDIR}/javac"
- fi
- if [ -z "$JAVAC_CMD" ] ; then
- JAVAC_CMD=`type -p javac`
- fi
-fi
-
-if $cygwin; then
- if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then
- format=mixed
- else
- format=windows
- fi
- if [ -n "${JAVA_HOME}" ] ; then
- JAVA_HOME=`cygpath --$format "$JAVA_HOME"`
- fi
- if [ -n "${JAVACMD}" ] ; then
- JAVACMD=`cygpath --$format "$JAVACMD"`
- fi
- if [ -n "${JAVAC_CMD}" ] ; then
- JAVAC_CMD=`cygpath --$format "$JAVAC_CMD"`
- fi
- SCALA_HOME=`cygpath --$format "$SCALA_HOME"`
-fi
-
-# last arg wins, so if JAVA_OPTS already contains -Xmx or -Xms the
-# supplied argument will be used.
-JAVA_OPTS="-Xmx1024M -Xms64M $JAVA_OPTS"
-
-# the sbt task doesn't supply any options by default,
-# so don't do that here either -- note that you may want to pass -optimise
-# to mimic what happens during nightlies.
-# [ -n "$SCALAC_OPTS" ] || SCALAC_OPTS="-deprecation"
-
-partestDebugStr=""
-if [ ! -z "${PARTEST_DEBUG}" ] ; then
- partestDebugStr="-Dpartest.debug=${PARTEST_DEBUG}"
-fi
-
-# note that variables which may intentionally be empty must not
-# be quoted: otherwise an empty string will appear as a command line
-# argument, and java will think that is the program to run.
-"${JAVACMD:=java}" \
- $JAVA_OPTS -cp "$PARTEST_CLASSPATH" \
- ${partestDebugStr} \
- ${color_opts} \
- -Dfile.encoding=UTF-8 \
- -Dscala.home="${SCALA_HOME}" \
- -Dpartest.javacmd="${JAVACMD}" \
- -Dpartest.java_opts="${JAVA_OPTS}" \
- -Dpartest.scalac_opts="${SCALAC_OPTS}" \
- -Dpartest.javac_cmd="${JAVAC_CMD}" \
- scala.tools.partest.nest.ConsoleRunner "$@"
diff --git a/tools/partest-ack b/tools/partest-ack
deleted file mode 100755
index ab722e3b1c..0000000000
--- a/tools/partest-ack
+++ /dev/null
@@ -1,131 +0,0 @@
-#!/usr/bin/env bash
-#
-# wrapper around partest for fine-grained test selection via ack
-
-declare quiet failed update partest_debug
-declare cotouched since sortCommand
-declare -a ack_args partest_args scalac_args
-declare -r standard_ack_args="--noenv -s --java --scala --type-add=scala:ext:flags,check --files-with-matches"
-
-partest_args=( --show-diff )
-bindir="$(cd "$(dirname "$0")" && pwd)"
-base="$bindir/.."
-cd "$base" || { echo "Could not change to base directory $base" && exit 1; }
-filesdir="test/files"
-sortCommand="sort -u"
-partestPaths="$bindir/partest-paths"
-
-[[ -x "$partestPaths" ]] || { echo "Cannot find partest-paths in $partestPaths" && exit 1; }
-
-[[ $# -gt 0 ]] || {
- cat <<EOM
-Usage: $0 <regex> [-dfquvp] [ack options]
-
- -f pass --failed to partest
- -q pass --terse to partest
- -u pass --update-check to partest
- -p <path> select tests appearing in commits where <path> was also modified
- -s <time> select tests touched since <time> (git format, e.g. 1.month.ago)
- -r run tests in random order
-
-Given a regular expression (and optionally, any arguments accepted by ack)
-runs all the tests for which any associated file matches the regex. Associated
-files include .check and .flags files. Tests in directories will match if any
-file matches. A file can match the regex by its contents or by its name.
-
-You must have ack version 2.12+ installed: http://beyondgrep.com/ack-2.12-single-file
-
-Examples:
-
- > tools/partest-ack 'case (class|object) Baz'
- % testsWithMatchingPaths ... 0
- % testsWithMatchingCode ... 3
- # 3 tests to run.
-
- > tools/partest-ack -s 12.hours.ago
- % testsTouchedSinceGitTime ... 33
- # 33 tests to run.
-
- > tools/partest-ack -p src/library/scala/Enumeration.scala
- % testsModifiedInSameCommit ... 80
- # 80 tests to run.
-
- > tools/partest-ack -f
- % tests-which-failed ... 42
- # 42 tests to run.
-
- > tools/partest-ack "kinds of the type arguments"
- % testsWithMatchingPaths ... 0
- % testsWithMatchingCode ... 6
- # 6 tests to run.
-EOM
-
- exit 0
-}
-
-while getopts :fuvdrp:s: opt; do
- case $opt in
- f) failed=true && partest_args+=" --failed" ;;
- p) cotouched="$cotouched $OPTARG" ;;
- r) sortCommand="randomSort" ;;
- s) since="$OPTARG" ;;
- q) partest_args+=" --terse" ;;
- u) partest_args+=" --update-check" ;;
- v) partest_args+=" --verbose" ;;
- :) echo "Option -$OPTARG requires an argument." >&2 ;;
- *) ack_args+="-$OPTARG" ;; # don't drop unknown args, assume they're for ack
- esac
-done
-
-shift $((OPTIND-1))
-ack_args=( "${ack_args[@]}" "$@" )
-
-# These methods all just create paths which may or may not be tests
-# all are filtered through partest-paths which limits the output to actual tests
-regexPathTests () { find "$filesdir" | ack --noenv "$@"; }
-failedTests () { for p in $(find "$filesdir" -name '*.log'); do p1=${p%.log} && p2=${p1%-*} && echo "$p2"; done; }
-sinceTests() { git log --since="$@" --name-only --pretty="format:" -- "$filesdir"; }
-regexCodeTests () { ack $standard_ack_args "$@" -- "$filesdir"; }
-sameCommitTests() { for rev in $(git rev-list HEAD -- "$@"); do git --no-pager show --pretty="format:" --name-only "$rev" -- "$filesdir"; done; }
-
-countStdout () {
- local -i count=0
- while read line; do
- printf "$line\n" && count+=1
- done
-
- printf >&2 " $count\n"
-}
-
-randomSort () {
- sort -u | while read line; do echo "$RANDOM $line"; done | sort | sed -E 's/^[0-9]+ //'
-}
-
-testRun () {
- local description="$1" && shift
- printf >&2 "%% tests %-25s ... " "$description"
- "$@" | "$partestPaths" | countStdout | egrep -v '^[ ]*$'
-}
-
-allMatches() {
- [[ -n $ack_args ]] && testRun "with matching paths" regexPathTests "${ack_args[@]}"
- [[ -n $ack_args ]] && testRun "with matching code" regexCodeTests "${ack_args[@]}"
- [[ -n $cotouched ]] && testRun "modified in same commit" sameCommitTests $cotouched
- [[ -n $since ]] && testRun "modified since time" sinceTests "$since"
- [[ -n $failed ]] && testRun "failed on last run" failedTests
-}
-
-paths=$(allMatches | $sortCommand)
-
-[[ -z $paths ]] && [[ -z $failed ]] && echo >&2 "No matching tests." && exit 0;
-
-count=$(echo $(echo "$paths" | wc -w))
-[[ "$count" -eq 0 ]] && echo >&2 "No tests to run." && exit 0;
-
-# Output a command line which will re-run these same tests.
-echo "# $count tests to run."
-printf "%-52s %s\n" "$base/test/partest ${partest_args[*]}" "\\"
-for path in $paths; do printf " %-50s %s\n" "$path" "\\"; done
-echo ""
-
-test/partest ${partest_args[*]} $paths
diff --git a/tools/partest-paths b/tools/partest-paths
deleted file mode 100755
index 6ce403a04e..0000000000
--- a/tools/partest-paths
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-#
-# Given a list of files on stdin, translates them into a set
-# of tests covering those files. That means paths which aren't
-# part of a test are dropped and the rest are rewritten to the
-# primary test path, with duplicates dropped.
-
-cd "$(dirname "$0")/.."
-
-# We have to enumerate good test dirs since partest chokes and fails
-# on continuations, bench, etc. tests
-pathRegex="test/files/(pos|neg|jvm|run|scalap|presentation)/[^/.]+([.]scala)?\$"
-
-# Echo the argument only if it matches our idea of a test and exists.
-isPath () { [[ "$1" =~ $pathRegex ]] && [[ -e "$1" ]]; }
-
-# Filter stdin down to actual test paths.
-asTestPaths() {
- while read -r p; do
- # Matched file at the standard test depth
- p1="${p%.*}" && isPath "$p1.scala" && echo "$p1.scala" && continue
- # Or, matched file may be in a test subdirectory, so strip the last path segment and check
- p2="${p1%/*}" && isPath "$p2" && echo "$p2" && continue
- done
-}
-
-asTestPaths | sort -u