summaryrefslogtreecommitdiff
path: root/test/partest
diff options
context:
space:
mode:
Diffstat (limited to 'test/partest')
-rwxr-xr-xtest/partest30
1 files changed, 12 insertions, 18 deletions
diff --git a/test/partest b/test/partest
index 0259cdb791..b74e04a208 100755
--- a/test/partest
+++ b/test/partest
@@ -1,6 +1,5 @@
#!/usr/bin/env bash
#
-
##############################################################################
# Scala test runner 2.10.0
##############################################################################
@@ -11,6 +10,17 @@
# 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.
term_colors=$(tput colors 2>/dev/null)
if [[ $? == 0 ]] && [[ $term_colors -gt 2 ]]; then
@@ -29,23 +39,7 @@ case "`uname`" in
esac
# Finding the root folder for this Scala distribution
-SOURCE=$0;
-SCRIPT=`basename "$SOURCE"`;
-while [ -h "$SOURCE" ]; do
- SCRIPT=`basename "$SOURCE"`;
- LOOKUP=`ls -ld "$SOURCE"`;
- TARGET=`expr "$LOOKUP" : '.*-> \(.*\)$'`;
- if expr "${TARGET:-.}/" : '/.*/$' > /dev/null; then
- SOURCE=${TARGET:-.};
- else
- SOURCE=`dirname "$SOURCE"`/${TARGET:-.};
- fi;
-done;
-
-# see #2092
-SCALA_HOME=`dirname "$SOURCE"`
-SCALA_HOME=`cd "$SCALA_HOME"; pwd -P`
-SCALA_HOME=`cd "$SCALA_HOME"/..; pwd`
+SCALA_HOME="$(findScalaHome)"
if $cygwin; then
SCALA_HOME=`cygpath --windows --short-name "$SCALA_HOME"`