summaryrefslogtreecommitdiff
path: root/test/partest
blob: 8d94facba3b3ba562a908de215a4f145b1c3f2d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/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.
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

# Constructing the extension classpath
EXT_CLASSPATH=""
if [ -z "$EXT_CLASSPATH" ] ; then
    if [ -f "$SCALA_HOME/lib/scala-partest.jar" ] ; then
        for ext in "$SCALA_HOME"/lib/* ; do
            if [ -z "$EXT_CLASSPATH" ] ; then
                EXT_CLASSPATH="$ext"
            else
                EXT_CLASSPATH="$EXT_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 "$EXT_CLASSPATH" ] ; then
                EXT_CLASSPATH="$ext"
            else
                EXT_CLASSPATH="$EXT_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"`
    EXT_CLASSPATH=`cygpath --path --$format "$EXT_CLASSPATH"`
fi

# last arg wins, so if JAVA_OPTS already contains -Xmx or -Xms the
# supplied argument will be used.
# At this writing it is reported test/partest --all requires 108m permgen.
JAVA_OPTS="-Xmx1024M -Xms64M -XX:MaxPermSize=128M $JAVA_OPTS"

# the ant 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 "$EXT_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.NestRunner "$@"