updated partest, added jline.jar to dists/latest

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@14142 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
michelou 2008-02-26 15:38:57 +00:00
parent 5fb3e569cc
commit 708ea3e486
6 changed files with 119 additions and 922 deletions

View File

@ -1786,6 +1786,7 @@ GENERATES A DISTRIBUTION
<attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-1.4"/>
</manifest>
</jar>
<copy todir="${dist.current.dir}/lib" file="${jline.jar}"/>
<!-- build source jars -->
<mkdir dir="${dist.current.dir}/src"/>

View File

@ -1,7 +1,10 @@
/* NEST (New Scala Test)
* Copyright 2007-2008 LAMP/EPFL
* @author Philipp Haller
*/
// $Id$
package scala.tools.partest.nest
import scala.tools.nsc.{Global, Settings}

View File

@ -1,7 +1,10 @@
/* NEST (New Scala Test)
* Copyright 2007-2008 LAMP/EPFL
* @author Philipp Haller
*/
// $Id$
package scala.tools.partest.nest
import java.io.{File, FilenameFilter, IOException, StringWriter}
@ -11,85 +14,58 @@ object FileManager {
val PATH_SEP = File.pathSeparatorChar
val CLASSPATH = System.getProperty("java.class.path", ".")
val PREFIX = System.getProperty("user.dir", ".")+"/.."
val SCALAHOME = System.getProperty("scala.home", ".")
val JAVACMD = System.getProperty("scalatest.javacmd", "java")
/*
if [ -d "$PREFIX/test" ]; then
TESTROOT="$PREFIX/test";
elif [ -d "$PREFIX/misc/scala-test" ]; then
TESTROOT="$PREFIX/misc/scala-test";
else
abort "Test directory not found";
*/
val TESTROOT = {
val PREFIX: File = {
val root = new File(SCALAHOME)
if (root.isDirectory)
root
else
error("Installation directory '"+SCALAHOME+"' not found")
}
val TESTROOT: File = {
val test = new File(PREFIX, "test")
val scala_test = new File(PREFIX, "misc/scala-test")
val testroot =
if (test.exists && test.isDirectory)
if (test.isDirectory)
test
else if (scala_test.exists && scala_test.isDirectory)
else if (scala_test.isDirectory)
scala_test
else
error("Test directory not found")
testroot.getAbsolutePath
error("Test directory '"+SCALAHOME+File.separator+"test' not found")
}
val EXT_CLASSPATH = {
val libs = new File(TESTROOT, "files/lib")
// add all jars in libs to EXT_CLASSPATH
(libs.listFiles(new FilenameFilter {
def accept(dir: File, name: String) =
name.endsWith(".jar")
def accept(dir: File, name: String) = name endsWith ".jar"
}) map {file => file.getCanonicalFile.getAbsolutePath}).mkString(""+PATH_SEP)
}
/*
if [ -d "$PREFIX/dists" ]; then
LATEST="$PREFIX/dists/latest/bin";
LATEST_LIB="$PREFIX/dists/latest/lib/scala-library.jar";
LATEST_COMP="$PREFIX/dists/latest/lib/scala-compiler.jar";
LATEST_PREDEF="$PREFIX/dists/latest/lib/predef.dll";
LATEST_CLDC=$QUICK_CLDC;
LATEST_CLDCAPI=$QUICK_CLDCAPI;
elif [ -d "$PREFIX/build" ]; then
LATEST="$QUICK";
LATEST_LIB=$QUICK_LIB;
LATEST_COMP=$QUICK_COMP;
LATEST_ACT=$QUICK_ACT;
LATEST_PREDEF=$QUICK_PREDEF;
LATEST_CLDC=$QUICK_CLDC;
LATEST_CLDCAPI=$QUICK_CLDCAPI;
elif [ -d "$PREFIX/bin" ]; then
LATEST="$PREFIX/bin";
LATEST_LIB="$PREFIX/lib/scala-library.jar";
LATEST_COMP="$PREFIX/lib/scala-compiler.jar";
LATEST_PREDEF="$PREFIX/lib/predef.dll";
LATEST_CLDC="$PREFIX/lib/scalaapi10-unverified.jar";
LATEST_CLDCAPI="$PREFIX/lib/scalaapi10.jar";
*/
def findLatest() {
def prefixFile(relPath: String) =
def prefixFile(relPath: String): File =
(new File(PREFIX, relPath)).getCanonicalFile
NestUI.verbose("PREFIX: "+PREFIX)
NestUI.verbose("PREFIX: "+SCALAHOME)
val dists = new File(PREFIX, "dists")
val build = new File(PREFIX, "build")
val bin = new File(PREFIX, "bin")
if (dists.exists && dists.isDirectory) {
if (dists.isDirectory) {
latestFile = prefixFile("dists/latest/bin")
latestLibFile = prefixFile("dists/latest/lib/scala-library.jar")
latestCompFile = prefixFile("dists/latest/lib/scala-compiler.jar")
latestPartestFile = prefixFile("dists/latest/lib/scala-partest.jar")
latestFjbgFile = prefixFile("lib/fjbg.jar") // starr
}
else if (build.exists && build.isDirectory) {
else if (build.isDirectory) {
latestFile = prefixFile("build/quick/bin")
latestLibFile = prefixFile("build/quick/lib/library")
latestCompFile = prefixFile("build/quick/lib/compiler")
latestPartestFile = prefixFile("build/quick/lib/partest")
latestFjbgFile = prefixFile("build/quick/lib/fjbg.jar")
latestFjbgFile = prefixFile("lib/fjbg.jar") // starr
}
else if (bin.exists && bin.isDirectory) {
else if (bin.isDirectory) {
latestFile = prefixFile("bin")
latestLibFile = prefixFile("lib/scala-library.jar")
latestCompFile = prefixFile("lib/scala-compiler.jar")
@ -123,7 +99,7 @@ elif [ -d "$PREFIX/bin" ]; then
var SCALA: String = ""
var SCALAC_CMD: String = ""
val SCALAC_OPTS = System.getProperty("scalatest.scalac_opts", "-deprecation -encoding utf8")
val SCALAC_OPTS = System.getProperty("scalatest.scalac_opts", "-deprecation")
var latestFile: File = _
var latestLibFile: File = _
@ -133,33 +109,23 @@ elif [ -d "$PREFIX/bin" ]; then
// initialize above fields
findLatest()
val srcDir = {
val dirname = System.getProperty("scalatest.cwd", "")
val dir = if (dirname.isEmpty) { // guess
val libDir = new File(new URI(classOf[Test].getResource("/").toString))
val path = libDir.getAbsolutePath
val parent = libDir.getParentFile
val rootDir =
if (path contains "quick") parent.getParentFile.getParentFile.getParentFile
else if (path contains "dists") parent.getParentFile.getParentFile
else parent
new File(rootDir, "test" + File.separator + "files")
} else
new File(dirname)
dir
}
if (!srcDir.isDirectory) {
NestUI.failure("Test directory \"" + srcDir.getAbsolutePath + "\" not found")
val srcDir: File = {
val src = new File(TESTROOT, "files")
if (src.isDirectory)
src
else {
val path = TESTROOT.getAbsolutePath + File.separator + "files"
NestUI.failure("Source directory \"" + path + "\" not found")
exit(1)
}
}
private def basename(name: String): String = {
val inx = name.lastIndexOf(".")
if (inx < 0) name else name.substring(0, inx)
}
def getLogFile(file: File, kind: String) = {
def getLogFile(file: File, kind: String): File = {
val dir = file.getParentFile
val fileBase = basename(file.getName)
new File(dir, fileBase + "-" + kind + ".log")
@ -176,8 +142,9 @@ elif [ -d "$PREFIX/bin" ]; then
* Compares two files using a Java implementation of the GNU diff
* available at http://www.bmsi.com/java/#diff.
*
* @param f1
* @param f2
* @param f1 the first file to be compared
* @param f2 the second file to be compared
* @return the text difference between the compared files
*/
def compareFiles(f1: File, f2: File): String = {
var res = ""

View File

@ -1,7 +1,10 @@
/* NEST (New Scala Test)
* Copyright 2007-2008 LAMP/EPFL
* @author Philipp Haller
*/
// $Id$
package scala.tools.partest.nest
import java.io.{File, PrintStream, FileOutputStream, BufferedReader,
@ -104,6 +107,15 @@ object NestRunner {
NestUI.outline("Scala version is : "+scalaVersion)
NestUI.outline("Scalac options are : "+FileManager.SCALAC_OPTS+"\n")
val vmBin = System.getProperty("java.home", "")+File.separator+"bin"
val vmName = System.getProperty("java.vm.name", "")+" (build "+
System.getProperty("java.vm.version", "")+", "+
System.getProperty("java.vm.info", "")+")"
val vmOpts = System.getProperty("scalatest.java_options", "?")
NestUI.outline("Java binaries in : "+vmBin+"\n")
NestUI.outline("Java runtime is : "+vmName+"\n")
NestUI.outline("Java options are : "+vmOpts+"\n")
val start = System.currentTimeMillis
val (successes, failures) = testCheckAll()
val end = System.currentTimeMillis

View File

@ -1,7 +1,10 @@
/* NEST (New Scala Test)
* Copyright 2007-2008 LAMP/EPFL
* @author Philipp Haller
*/
// $Id: $
package scala.tools.partest.nest
import java.io.File

View File

@ -1,561 +1,23 @@
#!/bin/sh
##############################################################################
# __ #
# ________ ___ / / ___ Scala Tools Launch Script #
# / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL #
# __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ #
# /____/\___/_/ |_/____/_/ | | #
# |/ #
##############################################################################
# $Id$
##############################################################################
# Error functions
# Prints a warning message on stderr.
warning() {
echo "$0: warning:" "$@" 1>&2;
}
# Prints an error message on stderr.
error() {
echo "$0:" "$@" 1>&2;
}
# Prints an error message on stderr and exits with a non-zero status.
abort() {
error "$@";
exit 1;
}
# Scala test runner 2.7.0-RC2
##############################################################################
# Printing functions
# Initializes the printf functions
printf_initialization() {
case "$1" in
many )
printf_font_outline="printf \\033[1;39m";
printf_font_success="printf \\033[1;32m";
printf_font_failure="printf \\033[1;31m";
printf_font_warning="printf \\033[1;33m";
printf_font_default="printf \\033[0;39m";
;;
some )
printf_font_outline="printf \\033[1m";
printf_font_success="printf \\033[0m";
printf_font_failure="printf \\033[1m";
printf_font_warning="printf \\033[1m";
printf_font_default="printf \\033[0m";
;;
none )
printf_font_outline="";
printf_font_success="";
printf_font_failure="";
printf_font_warning="";
printf_font_default="";
;;
* )
abort "unknown color mode \`$1'";
;;
esac;
}
# Prints formated text in outline font.
printf_outline() {
$printf_font_outline;
printf "$@";
$printf_font_default;
}
# Prints formated text in success font.
printf_success() {
$printf_font_success;
printf "$@";
$printf_font_default;
}
# Prints formated text in failure font.
printf_failure() {
$printf_font_failure;
printf "$@";
$printf_font_default;
}
# Prints formated text in warning font.
printf_warning() {
$printf_font_warning;
printf "$@";
$printf_font_default;
}
# (c) 2002-2008 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.
##############################################################################
# File name and path list conversion functions
# Prints the OS-specific form of the specified Unix form file name.
get_os_filename() {
[ $# = 1 ] || abort "internal error";
case "$UNAME" in
CYGWIN* ) cygpath --windows "$1";;
* ) echo "$@";;
esac;
}
cygwin=false;
darwin=false;
case "`uname`" in
CYGWIN*) cygwin=true ;;
Darwin*) darwin=true ;;
esac
# Prints the Unix form of the specified OS-specific form file name.
get_unix_filename() {
[ $# = 1 ] || abort "internal error";
case "$UNAME" in
CYGWIN* ) cygpath --unix "$1";;
* ) echo "$@";;
esac;
}
# Prints the OS-specific form of the specified Unix form path list.
get_os_pathlist() {
[ $# = 1 ] || abort "internal error";
case "$UNAME" in
CYGWIN* ) cygpath --window --path "$1";;
* ) echo "$@";;
esac;
}
# Prints the Unix form of the specified OS-specific form path list.
get_unix_pathlist() {
[ $# = 1 ] || abort "internal error";
case "$UNAME" in
CYGWIN* ) cygpath --unix --path "$1";;
* ) echo "$@";;
esac;
}
# Collects all jar files in the given path
get_ext_classpath() {
[ $# = 1 ] || abort "internal error";
# Constructing the extension classpath
cp=""
for ext in `ls $1/*.jar` ; do
if [ -z "$cp" ] ; then
cp="$ext"
else
cp="$cp:$ext"
fi
done
echo $cp
}
##############################################################################
# Implementation of scalatest
# Prints the scalatest usage.
test_print_usage() {
[ $# = 0 ] || abort "internal error";
echo "Usage: `basename $0` [OPTION]... [FILE]..."
}
# Prints the scalatest help.
test_print_help() {
[ $# = 0 ] || abort "internal error";
test_print_usage;
echo "";
echo "--auto use filenames to select the test to run";
echo "--dis next files test the class file disassembler";
echo "--run next files test the interpreter and all backends";
echo "--jvm next files test the JVM backend";
echo "--pos next files test a compilation success";
echo "--neg next files test a compilation failure";
echo "--res next files test the resident compiler";
echo "--msil next files test the .NET backend";
echo "--script next files test Scala embedded in scripts";
echo "--ant next files test the Ant tasks";
echo "--pending perform the tests in the 'pending' directory";
echo "--shootout next files test Debian's language shootout benchmarks";
echo "--quick use the 'quick' build instead of distribution";
echo '--installed use the installed programs on $PATH'
echo "--no-run run no test, use results of last run";
echo "--show-log show output of failed tests";
echo "--show-diff show differences between actual and expected output";
echo "--use-fsc use the Fast Scala compiler";
echo "--failed test only files that failed last time";
echo "--errors=<int> specify the number of expected errors";
echo "--flags=<flags> specify flags to pass on to the executable";
echo "--color=USAGE control the color usage (USAGE=none|some|many)";
echo "--objdir=<dir> specify where to place generated files";
echo "--help, -? display this help and exit";
echo "--version output version information and exit";
echo "";
echo "Report bugs to <scala@listes.epfl.ch>";
}
# Prints the scalatest version.
test_print_version() {
[ $# = 0 ] || abort "internal error";
echo "$SCRIPT "'$Revision$';
}
# Prints the name of the specified test file.
test_print_testing() {
[ $# = 1 ] || abort "internal error";
printf_outline "testing: ";
case "$1" in
"$TESTROOT"* )
printf "%-60s " "[...]`expr "$1" : "$TESTROOT\(.*\)"`";
return 0;
;;
esac;
printf "%-60s " "$1";
}
# Prints a test success notification.
test_print_success() {
[ $# = 0 ] || abort "internal error";
printf "[";
printf_success " OK ";
printf "]\\n";
}
# Prints a test failure notification.
test_print_failure() {
[ $# = 0 ] || abort "internal error";
printf "[";
printf_failure "FAILED";
printf "]\\n";
}
# Tests resident compiler.
test_run_res() {
rm -rf "$dstbase".obj &&
mkdir -p "$dstbase".obj &&
(cd "$srcdir" && cat "$testname".res | $SCALAC -d "$os_dstbase".obj -Xresident -sourcepath . "$@"; );
rm -rf "$dstbase".obj;
}
# Tests the JVM backend.
# NB. property '-Djavacmd=$JAVACMD' is e.g used by jvm/inner.scala
test_run_jvm() {
javaopts=$JAVA_OPTS;
if [ -f "$os_srcbase".javaopts ]; then
javaopts="$javaopts `cat "$os_srcbase".javaopts`"
if [ "$JAVA5" = "false" ]; then
# -Xss option available in Java versions 1.5 or newer
javaopts=`echo "$javaopts" | sed -e "s/-Xss[0-9]*[MmKk]//g"`
fi
fi
rm -rf "$dstbase".obj &&
mkdir -p "$dstbase".obj &&
(cd "$srcdir" && env JAVACMD="$JAVACMD" JAVA_OPTS="$javaopts" $SCALAC -d "$os_dstbase".obj \
-cp "$JVM_EXT_CLASSPATH" "$@" "$testname".scala ) &&
libpath=`get_os_pathlist "$dstdir"` &&
scala_javaopts=`echo -Djava.library.path=$libpath` &&
scala_lib=`get_os_filename "$SCALA_LIB"` &&
classpath=`get_os_pathlist "$os_dstbase".obj:$CLASSPATH` &&
env JAVA_OPTS="$scala_javaopts" $SCALA -Djavacmd="$JAVACMD" \
-Dscalatest.output=$os_dstbase.obj -Dscalatest.lib=$scala_lib \
-classpath $classpath:$JVM_EXT_CLASSPATH Test "jvm" &&
rm -rf "$dstbase".obj;
}
# Test the disassemblers.
test_run_dis() {
argsfile="$srcbase".args;
[ ! -f "$argsfile" ] && argsfile=/dev/null;
rm -rf "$dstbase".obj &&
mkdir -p "$dstbase".obj &&
$SCALAC -d "$os_dstbase".obj "$@" "$os_srcbase".scala &&
$SCALAP -classpath "$os_dstbase".obj `cat "$argsfile"` &&
rm -rf "$dstbase".obj;
}
MSIL="msil"
EXE="exe"
# Tests the .NET backend.
test_run_msil() {
assemblies=`get_os_pathlist $SCALA_ASSEM`;
rm -f "$dstbase".$MSIL &&
rm -f "$dstbase".$EXE &&
$SCALAC -nowarn -target:msil -Xassem "$os_dstbase" -Xassem-path $assemblies "$@" \
-sourcepath "$PREFIX/build/msil/src" "$os_srcbase".scala &&
case "$UNAME" in
CYGWIN* )
$ILASM /qui /nol /out="$os_dstbase".$EXE "$os_dstbase".$MSIL \
> /dev/null &&
# peverify /il "$os_dstbase".EXE > /dev/null &&
"$dstbase".$EXE_SUFFIX "msil";;
* )
$ILASM /output:"$os_dstbase".$EXE "$os_dstbase".$MSIL \
> /dev/null &&
monopath=`get_os_pathlist $PREFIX/build/msil:$PREFIX/lib` &&
env MONO_PATH="$monopath" $MONO "$dstbase.$EXE" "msil";;
esac &&
rm -f "$dstbase".$EXE &&
rm -f "$dstbase".$MSIL;
}
# Tests a script with Scala code embedded in it
test_run_script() {
argsfile="$srcbase.args"
if [ ! -r "$argsfile" ]; then
argsfile=/dev/null
fi
chmod +x "$srcbase.scala" 2> /dev/null
PATH="$BIN_DIR:$PATH" "$srcbase.scala" `cat $argsfile`
}
# Tests the Scala Ant task
test_run_ant() {
if [ "$BIN_DIR" = "" ]; then BINARY=installed
elif [ "$BIN_DIR" = "$QUICK" ]; then BINARY=quick
else BINARY=latest
fi;
testname=`basename "$srcbase"`;
buildfile=`get_os_filename "$srcdir/$testname-build.xml"`;
rm -rf "$dstbase".obj &&
$ANT -f "$buildfile" -Dbinary="$BINARY" -Dbuild.dir="$os_dstbase".obj &&
rm -rf "$dstbase".obj;
}
# Tests the shootout benchmarks
test_run_shootout() {
javaopts=$JAVA_OPTS;
if [ -f "$os_srcbase".javaopts ]; then
javaopts="$javaopts `cat "$os_srcbase".javaopts`"
if [ "$JAVA5" = "false" ]; then
# -Xss option available in Java versions 1.5 or newer
javaopts=`echo "$javaopts" | sed -e "s/-Xss[0-9]*[MmKk]//g"`
fi
fi
rm -rf "$dstbase".obj &&
mkdir -p "$dstbase".obj &&
testfile=`get_os_filename "$dstbase".obj/test.scala` &&
cat "$os_srcbase".scala.runner "$os_srcbase".scala > "$testfile" &&
$SCALAC -d "$os_dstbase".obj -cp "$JVM_EXT_CLASSPATH" "$@" "$testfile" &&
scala_lib=`get_os_filename "$SCALA_LIB"` &&
classpath=`get_os_pathlist "$os_dstbase".obj:$CLASSPATH` &&
env JAVACMD="$JAVACMD" JAVA_OPTS="$javaopts" \
$SCALA -Dscalatest.cwd="$srcdir" -Dscalatest.output=$os_dstbase.obj \
-Dscalatest.lib=$scala_lib -classpath $classpath:$JVM_EXT_CLASSPATH Test &&
rm -rf "$dstbase".obj;
}
# Checks the specified test.
test_check_test() {
[ $# = 1 ] || abort "internal error";
testfile="$1"; shift 1;
# compute test name
testname=`basename "$testfile" ."$TEST_EXT"`;
# compute source and destination directories (absolute paths)
srcdir=`dirname "$testfile"`;
srcdir=`cd "$srcdir"; pwd`;
dstdir="$OBJDIR""$srcdir";
# compute source and destination base names
srcbase="$srcdir"/"$testname";
dstbase="$dstdir"/"$testname"-$kind;
os_srcbase=`get_os_filename "$srcbase"`;
os_dstbase=`get_os_filename "$dstbase"`;
# compute flags file
flagsfile="$srcbase".flags;
[ ! -f "$flagsfile" ] && flagsfile=/dev/null;
# compute check file
checkfile="$srcbase"-$kind.check;
[ ! -f "$checkfile" ] && checkfile="$srcbase".check;
[ ! -f "$checkfile" ] && checkfile=/dev/null;
# compute log file
logfile="$dstbase".log;
# if we are testing only failed tests, skip successful tests
if [ "$FAILED" = "true" -a ! -f "$logfile" ]; then
return 0;
fi;
# print tested file
test_print_testing "$testfile";
# run test
if [ "$NORUN" = "true" ]; then
[ ! -f "$logfile" ];
else
rm -f "$logfile";
{ [ -d "$dstdir" ] || mkdir -p "$dstdir"; } &&
( test_run_$kind `cat "$flagsfile"` $FLAGS 1> "$logfile" 2>&1; ) &&
$DIFF "$logfile" "$checkfile" 1> /dev/null 2>&1 &&
rm -f "$logfile";
fi;
# print result
if [ "$?" = 0 ]; then
SUCCESS_COUNT=`echo "$SUCCESS_COUNT+1" | bc`;
test_print_success;
else
FAILURE_COUNT=`echo "$FAILURE_COUNT+1" | bc`;
test_print_failure;
[ ! -f "$logfile" ] && logfile=/dev/null;
[ "$SHOWLOG" = "true" ] && cat "$logfile";
[ "$SHOWDIFF" = "true" ] && $DIFF "$logfile" "$checkfile";
fi;
}
# Checks the specified file
test_check_file() {
[ $# = 1 ] || abort "internal error";
file="$1"; shift 1;
for testfile in "" `find "$file" -name "*.obj" -prune -o -name "*.$TEST_EXT" -a -type f -print`; do
[ -z "$testfile" ] && continue;
test_check_test "$testfile";
done;
}
load_results() {
if [ -f "$RESFILE" ]; then
FAIL=`head -1 $RESFILE`;
SUCCESS=`head -2 $RESFILE | tail -1`;
FAILURE_COUNT=`echo "$FAILURE_COUNT+$FAIL" | bc`
SUCCESS_COUNT=`echo "$SUCCESS_COUNT+$SUCCESS" | bc`
rm -f "$RESFILE";
else
abort "Couldn't load TestRunner results' file";
fi;
}
# Checks all files of the specified kind.
test_check_kind() {
[ $# -ge 2 ] || abort "internal error";
header="$1"; shift 1;
kind="$1"; shift 1;
if [ "$kind" = "res" ]; then TEST_EXT="res"; else TEST_EXT="scala"; fi;
if [ "$kind" = "testrunner" ]; then
srcdir=`get_os_filename "$SRCDIR"`;
resfile=`get_os_filename "$RESFILE"`;
javaopts=$JAVA_OPTS;
if [ -f "$os_srcbase".javaopts ]; then
javaopts="$javaopts `cat "$os_srcbase".javaopts`"
if [ "$JAVA5" = "false" ]; then
# -Xss option available in Java versions 1.5 or newer
javaopts=`echo "$javaopts" | sed -e "s/-Xss[0-9]*[MmKk]//g"`
fi;
fi;
if [ "$TEST_TYPE" = "auto" ]; then
testargs="$FILES_POS $FILES_NEG $FILES_RUN $FILES_JVM $FILES_SHOOTOUT";
else
testargs=`echo "$TEST_OPTS" --"$TEST_TYPE"`
fi;
scala_lib=`get_os_filename "$SCALA_LIB"` &&
classpath=`get_os_pathlist $CLASSPATH` &&
$SCALA -DSCALA=$SCALA -DJAVA_OPTS="$javaopts" \
-DEXT_CLASSPATH=$JVM_EXT_CLASSPATH -DCLASSPATH=$classpath \
-Dactors.corePoolsize=7 -Dactors.maxPoolSize=8 \
-Dscalatest.cwd=$srcdir -Dscalatest.lib=$scala_lib \
-classpath $classpath \
scala.tools.partest.TestRunner $testargs $resfile 2> /dev/null;
load_results;
else
[ "$@" ] && printf_outline "\\n$header\\n";
for file in "" "$@"; do
[ -z "$file" ] && continue;
test_check_file "$file";
done
fi;
#[ -z "$header" ] && echo "";
}
# Checks everything.
test_check_all() {
[ $# = 0 ] || abort "internal error";
test_check_kind "Testing disassembler" \
"dis" $FILES_DIS;
test_check_kind "Testing .NET backend" \
"msil" $FILES_MSIL;
test_check_kind "Testing Scala embedded in script files" \
"script" $FILES_SCRIPT;
test_check_kind "Testing Scala Ant tasks" \
"ant" $FILES_ANT;
test_check_kind "Testing resident compiler" \
"res" $FILES_RES;
test_check_kind "(ignored)" \
"testrunner" "";
}
# Adds a new file to the appropriate file list(s).
test_add_file() {
[ $# = 1 ] || abort "internal error";
case "$1" in
*.scala | *.res )
if [ ! \( -d "$1" -o -f "$1" \) ]; then
abort "don't know what to do with '$1'";
fi;;
* )
if [ ! -d "$1" ]; then
abort "don't know what to do with '$1'";
fi;;
esac;
TEST_ALL="false";
case "$TEST_TYPE" in
auto ) ;;
dis ) FILES_DIS="$FILES_DIS $1"; return;;
run ) FILES_RUN="$FILES_RUN $1"; return;;
jvm ) FILES_JVM="$FILES_JVM $1"; return;;
pos ) FILES_POS="$FILES_POS $1"; return;;
neg ) FILES_NEG="$FILES_NEG $1"; return;;
res ) FILES_RES="$FILES_RES $1"; return;;
msil ) FILES_MSIL="$FILES_MSIL $1"; return;;
script ) FILES_SCRIPT="$FILES_SCRIPT $1"; return;;
ant ) FILES_ANT="$FILES_ANT $1"; return;;
shootout ) FILES_SHOOTOUT="$FILES_SHOOTOUT $1"; return;;
* ) abort "unknown test type \`$TEST_TYPE'";;
esac;
case "$1" in
dis | */dis | */dis/* | dis/* ) FILES_DIS="$FILES_DIS $1";;
run | */run | */run/* | run/* ) FILES_RUN="$FILES_RUN $1";;
jvm5 | */jvm5 | */jvm5* | jvm5/* )
if [ "$JAVA5" = "true" ]; then
FILES_JVM="$FILES_JVM $1"
fi;;
jvm | */jvm | */jvm/* | jvm/* ) FILES_JVM="$FILES_JVM $1";;
pos | */pos | */pos/* | pos/* ) FILES_POS="$FILES_POS $1";;
neg | */neg | */neg/* | neg/* ) FILES_NEG="$FILES_NEG $1";;
res | */res | */res/* | res/* ) FILES_RES="$FILES_RES $1";;
msil | */msil | */msil/* | msil/* ) FILES_MSIL="$FILES_MSIL $1";;
script | */script | */script/* | script/* ) FILES_SCRIPT="$FILES_SCRIPT $1";;
shootout | */shootout | */shootout/* | shootout/* ) FILES_SHOOTOUT="$FILES_SHOOTOUT $1";;
* ) abort "don't known what to do with \`$1'";;
esac;
}
test_get_location() {
[ $# = 1 ] || abort "internal error";
source="$1"; shift 1;
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;
location=`dirname "$source"`;
location=`cd "$location"; pwd`;
echo $location;
}
##############################################################################
# Definition of UNAME, SOURCE, SCRIPT and PREFIX
unset SCRIPT;
UNAME=`uname`;
# Finding the root folder for this Scala distribution
SOURCE=$0;
SCRIPT=`basename "$SOURCE"`;
while [ -h "$SOURCE" ]; do
@ -568,308 +30,57 @@ while [ -h "$SOURCE" ]; do
SOURCE=`dirname "$SOURCE"`/${TARGET:-.};
fi;
done;
PREFIX=`dirname "$SOURCE"`/..;
PREFIX=`cd "$PREFIX"; pwd`;
SCALA_HOME=`dirname "$SOURCE"`/..;
SCALA_HOME=`cd "$SCALA_HOME"; pwd`;
if $cygwin; then
SCALA_HOME=`cygpath --windows --short-name "$SCALA_HOME"`
SCALA_HOME=`cygpath --unix "$SCALA_HOME"`
fi
##############################################################################
# Invocation of $SCRIPT
NORUN="false";
SHOWLOG="false";
SHOWDIFF="false";
USEFSC="false";
FAILED="false";
ERRORS=0;
SUCCESS_COUNT=0;
FAILURE_COUNT=0;
if [ -d "$PREFIX/test" ]; then
TESTROOT="$PREFIX/test";
elif [ -d "$PREFIX/misc/scala-test" ]; then
TESTROOT="$PREFIX/misc/scala-test";
else
abort "Test directory not found";
fi;
SRCDIR="$TESTROOT/files";
OBJDIR="""";
TEST_ALL="true";
TEST_TYPE="auto";
TEST_OPTS="";
FILES_RUN="";
FILES_JVM="";
FILES_POS="";
FILES_RES="";
FILES_NEG="";
FILES_MSIL="";
FILES_SCRIPT="";
FILES_DIS="";
FILES_ANT="";
FILES_SHOOTOUT="";
QUICK="$PREFIX/build/quick/bin"
QUICK_LIB="$PREFIX/build/quick/lib/library"
QUICK_COMP="$PREFIX/build/quick/lib/compiler"
QUICK_ACT="$PREFIX/build/quick/lib/actors"
QUICK_PAR="$PREFIX/build/quick/lib/partest"
QUICK_PREDEF="$PREFIX/build/quick/lib/predef.dll"
JVM_EXT_CLASSPATH=`get_ext_classpath $TESTROOT/files/lib`
if [ -d "$PREFIX/dists" ]; then
LATEST="$PREFIX/dists/latest/bin";
LATEST_LIB="$PREFIX/dists/latest/lib/scala-library.jar";
LATEST_COMP="$PREFIX/dists/latest/lib/scala-compiler.jar";
LATEST_PAR="$PREFIX/dists/latest/lib/scala-partest.jar";
LATEST_PREDEF="$PREFIX/dists/latest/lib/predef.dll";
elif [ -d "$PREFIX/build" ]; then
LATEST="$QUICK";
LATEST_LIB=$QUICK_LIB
LATEST_COMP=$QUICK_COMP
LATEST_ACT=$QUICK_ACT
LATEST_PAR=$QUICK_PAR
LATEST_PREDEF="$QUICK_PREDEF";
elif [ -d "$PREFIX/bin" ]; then
LATEST="$PREFIX/bin";
LATEST_LIB="$PREFIX/lib/scala-library.jar";
LATEST_COMP="$PREFIX/lib/scala-compiler.jar";
LATEST_PAR="$PREFIX/lib/scala-partest.jar";
LATEST_PREDEF="$PREFIX/lib/predef.dll";
else
abort "Scala binaries could not be found";
fi;
BIN_DIR="$LATEST/" # BIN_DIR should have a trailing / when needed, so that
# it can also be set to the empty string
SCALA_LIB="$LATEST_LIB";
SCALA_COMP="$LATEST_COMP";
SCALA_ACT="$LATEST_ACT";
SCALA_PAR="$LATEST_PAR";
SCALA_PREDEF="$LATEST_PREDEF";
SCALA_RUNTIME="$LATEST_RUNTIME";
[ -x "$JAVACMD" ] || JAVACMD=java;
[ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xmx256M -Xms16M";
case `$JAVACMD \-version 2>&1 | xargs` in
*1.5.*IBM* ) JAVA5="true"; IBM_J9="true"; JAVA_OPTS="$JAVA_OPTS -Xss2M";;
*1.6.*IBM* ) JAVA5="true"; IBM_J9="true";;
*1.[5-7].* ) JAVA5="true";;
*1.4.*GNU* ) JAVA5="false"; GIJ="true"; JAVA_OPTS="--mx256m --ms16m";;
* ) JAVA5="false";;
esac;
DIFF="diff";
case `uname` in
CYGWIN* )
DIFF="diff --text --strip-trailing-cr";
;;
esac;
while [ $# -gt 0 ]; do
case "$1" in
--auto ) TEST_TYPE="auto"; shift 1;;
--dis ) TEST_TYPE="dis"; shift 1;;
--run ) TEST_TYPE="run"; shift 1;;
--jvm ) TEST_TYPE="jvm"; shift 1;;
--pos ) TEST_TYPE="pos"; shift 1;;
--neg ) TEST_TYPE="neg"; shift 1;;
--res ) TEST_TYPE="res"; shift 1;;
--msil ) TEST_TYPE="msil"; shift 1;;
--script ) TEST_TYPE="script"; shift 1;;
--ant ) TEST_TYPE="ant"; shift 1;;
--shootout ) TEST_TYPE="shootout"; shift 1;;
--quick ) BIN_DIR="$QUICK/"; SCALA_LIB=$QUICK_LIB;
SCALA_COMP=$QUICK_COMP; SCALA_ACT=$QUICK_ACT;
SCALA_PAR=$QUICK_PAR; SCALA_PREDEF=$QUICK_PREDEF;
shift 1;;
--installed ) BIN_DIR=""; shift 1;;
--no-run ) NORUN="true"; shift 1;;
--show-log ) SHOWLOG="true"; shift 1;;
--show-diff ) SHOWDIFF="true"; shift 1;;
--use-fsc ) USEFSC="true"; shift 1;;
--failed ) FAILED="true"; shift 1;;
--pending ) SRCDIR="$TESTROOT/pending"; shift 1;;
--errors= ) abort "illegal empty argument for option --errors";;
--errors=* ) ERRORS=`expr "$1" : "--errors=\([0-9]*\)$"`;shift 1;;
--flags= ) abort "illegal empty argument for option --flags";;
--flags=* ) FLAGS=`expr "$1" : "--flags=\(.*\)"`; shift 1;;
--color= ) abort "illegal empty argument for option --color";;
--color=* ) COLOR=`expr "$1" : "--color=\(.*\)"`; shift 1;;
--objdir=* ) OBJDIR=`expr "$1" : "--objdir=\(.*\)"`; shift 1;;
--help| -? ) test_print_help; exit 0;;
--verbose ) TEST_OPTS="--verbose"; shift 1;;
--version ) test_print_version; exit 0;;
-* ) abort "unknown option $1";;
* ) test_add_file "$1"; shift 1;;
esac;
done;
if [ "$JAVA5" = "true" -a "$TEST_TYPE" != "msil" ]; then
FLAGS="$FLAGS -target:jvm-1.5"
fi;
if [ -z "$ERRORS" ]; then
abort "illegal non-numerical argument for option --errors";
fi;
if [ -z "$COLOR" -a -n "$EMACS" ]; then
COLOR="none";
fi;
printf_initialization "${COLOR:-many}";
if [ "$TEST_ALL" = "true" ]; then
case "$TEST_TYPE" in
dis ) FILES_DIS="$FILES_DIS $SRCDIR/dis";;
esac;
case "$TEST_TYPE" in
run ) FILES_RUN="$FILES_RUN $SRCDIR/run";;
esac;
case "$TEST_TYPE" in
auto | shootout ) FILES_SHOOTOUT="$FILES_SHOOTOUT $SRCDIR/shootout";;
esac;
case "$TEST_TYPE" in
auto | jvm )
FILES_JVM="$FILES_JVM $SRCDIR/run $SRCDIR/jvm"
if [ "$JAVA5" = "true" ]; then
FILES_JVM="$FILES_JVM $SRCDIR/jvm5";
fi;;
esac;
case "$TEST_TYPE" in
auto | pos ) FILES_POS="$FILES_POS $SRCDIR/pos";;
esac;
case "$TEST_TYPE" in
auto | neg ) FILES_NEG="$FILES_NEG $SRCDIR/neg";;
esac;
case "$TEST_TYPE" in
auto | res ) FILES_RES="$FILES_RES $SRCDIR/res";;
esac;
case "$TEST_TYPE" in
msil ) FILES_MSIL="$FILES_MSIL $SRCDIR/run";;
esac;
case "$TEST_TYPE" in
auto | script ) FILES_SCRIPT="$FILES_SCRIPT $SRCDIR/script";;
esac;
case "$TEST_TYPE" in
ant ) FILES_ANT="$FILES_ANT $SRCDIR/ant";;
esac;
fi;
SCALA="${BIN_DIR}scala";
[ -z "$SCALAC_OPTS" ] && SCALAC_OPTS="-deprecation -encoding iso-8859-1";
if [ "$USEFSC" = "true" ]; then
if [ "${BIN_DIR}" = "" ]; then
SCALAC_CMD=`which fsc`;
else
SCALAC_CMD="${BIN_DIR}fsc";
fi;
else
if [ "${BIN_DIR}" = "" ]; then
SCALAC_CMD=`which scalac`;
else
SCALAC_CMD="${BIN_DIR}scalac";
fi;
fi;
if [ ! -x "$SCALAC_CMD" ]; then
printf_failure "Missing command \"$SCALAC_CMD\"; run 'ant <target>'.\\n";
exit 1;
fi;
SCALAC="$SCALAC_CMD $SCALAC_OPTS";
SCALAP="scalap";
CLASSPATH=$SCALA_COMP:$SCALA_ACT:$SCALA_PAR
SCALA_ASSEM=$SCALA_PREDEF:$PREFIX/lib/scalaruntime.dll:$PREFIX/lib/mscorlib.dll
RESFILE=`mktemp -t results.XXXXXX`;
[ -f "$RESFILE" ] || RESFILE=`get_os_filename "$TESTROOT"/.results.txt`
if [ -z "$ANT" ]; then
if [ -d "$ANT_HOME" ]; then
ANT="$ANT_HOME/bin/ant";
else
ANT="ant";
# Constructing the extension classpath
EXT_CLASSPATH=""
if [ -z "$EXT_CLASSPATH" ] ; then
if [ -f "$SCALA_HOME/lib/scala-partest.jar" ] ; then
EXT_CLASSPATH="$SCALA_HOME/lib/scala-partest.jar"
elif [ -d "$SCALA_HOME/build/quick/lib/partest" ] ; then
EXT_CLASSPATH="$SCALA_HOME/build/quick/lib/partest"
fi
fi;
if [ -z "$ILASM" ]; then
if [ -d "$MONO_HOME" ]; then
ILASM="$MONO_HOME/bin/ilasm";
else
ILASM="ilasm";
fi
# Setting the boot class-path to be the standard library (either as a JAR or a folder)
BOOT_CLASSPATH=""
if [ -z "$BOOT_CLASSPATH" ] ; then
if [ -f "$SCALA_HOME/lib/scala-library.jar" ] ; then
BOOT_CLASSPATH="$SCALA_HOME/lib/scala-library.jar"
elif [ -d "$SCALA_HOME/lib/library" ] ; then
BOOT_CLASSPATH="$SCALA_HOME/lib/library"
fi
fi;
if [ -z "$MONO" ]; then
if [ -d "$MONO_HOME" ]; then
MONO="$MONO_HOME/bin/mono";
else
MONO="mono";
fi
# Setting the test directory
TEST_DIR=""
if [ -z "$TEST_DIR" ] ; then
if [ -f "$SCALA_HOME/misc/scala-test" ] ; then
TEST_DIR="$SCALA_HOME/misc/scala-test"
elif [ -d "$SCALA_HOME/test" ] ; then
TEST_DIR="$SCALA_HOME/test"
fi
fi;
fi
if [ -n "$OBJDIR" ]; then
if [ -d "$OBJDIR" ] || mkdir -p "$OBJDIR"; then
OBJDIR=`cd "$OBJDIR"; pwd`;
if $cygwin; then
if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then
format=mixed
else
abort "could not create directory '$OBJDIR'";
format=windows
fi
fi;
SCALA_HOME=`cygpath --$format "$SCALA_HOME"`
EXT_CLASSPATH=`cygpath --path --$format "$EXT_CLASSPATH"`
BOOT_CLASSPATH=`cygpath --path --$format "$BOOT_CLASSPATH"`
TEST_DIR=`cygpath --$format "$TEST_DIR"`
fi
printf_outline "Source directory is : $SRCDIR\\n";
bin_dir=$BIN_DIR
if [ -z "$bin_dir" ]; then
scalac=`which $SCALAC_CMD`;
bin_dir=`test_get_location $scalac`;
fi;
printf_outline "Scala binaries in : $bin_dir\\n";
scala_version=`${SCALAC_CMD} -version 2>&1`
printf_outline "Scala version is : $scala_version\\n";
[ -n "$SCALAC_OPTS" ] && printf_outline "Scalac options are : $SCALAC_OPTS\\n";
# Reminder: substitution ${JAVA_OPTS:=-Xmx256M -Xms16M} DO NOT work on Solaris
[ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xmx1024M -Xms256M -XX:MaxPermSize=256M"
[ -n "$SCALAC_OPTS" ] || SCALAC_OPTS="-deprecation"
if [ $TEST_TYPE = "msil" ]; then
ilasm_version=`$ILASM --version 2>&1`;
printf_outline "ILasm version is : $ilasm_version\\n";
mono_version=`$MONO --version | head -1`;
printf_outline "Mono version is : $mono_version\\n";
if [ -f "$SCALA_PREDEF" ]; then
printf_outline "DLL library is : $SCALA_PREDEF\\n";
else
printf_failure "Missing library \"predef.dll\"; run 'ant msil'.\\n";
exit 1;
fi
else
javacmd=`which $JAVACMD 2>/dev/null`;
bin_dir=`test_get_location $javacmd`;
printf_outline "Java binaries in : $bin_dir\\n";
if [ "$GIJ" = "true" ]; then
jvm_version=`$JAVACMD -version 2>&1 | head -2 | tail -1`
else
jvm_version=`$JAVACMD -version 2>&1 | head -3 | tail -1`
fi;
printf_outline "Java runtime is : $jvm_version\\n";
[ -n "$JAVA_OPTS" ] && printf_outline "Java options are : $JAVA_OPTS\\n";
if [ "$TEST_TYPE" = "ant" ]; then
ant_version=`$ANT -version`;
printf_outline "Ant version is : $ant_version\\n";
fi
fi;
START_SECONDS=`date +%s`;
test_check_all;
END_SECONDS=`date +%s`;
TOTAL_COUNT=`echo "$FAILURE_COUNT+$SUCCESS_COUNT" | bc`;
ELAPSED_SECONDS=`expr $END_SECONDS - $START_SECONDS`;
ELAPSED_TIME=`date --date="1970-01-01 $ELAPSED_SECONDS sec" +%T`;
if [ $FAILURE_COUNT -eq 0 ]; then
printf_success "All of $TOTAL_COUNT tests were successful (elapsed time: $ELAPSED_TIME)\\n";
else
printf_failure "$FAILURE_COUNT of $TOTAL_COUNT tests failed (elapsed time: $ELAPSED_TIME)\\n";
fi;
if [ $FAILURE_COUNT -eq "$ERRORS" ]; then
exit 0;
else
exit 1;
fi;
##############################################################################
${JAVACMD:=java} $JAVA_OPTS -Xbootclasspath/a:"$BOOT_CLASSPATH" -cp "$EXT_CLASSPATH" -Dscala.home="${SCALA_HOME}" -Dscalatest.javacmd="${JAVACMD}" -Dscalatest.java_options="${JAVA_OPTS}" -Dscalatest.cwd="${TEST_DIR}" -Dscalatest.scalac_options="${SCALAC_OPTS}" scala.tools.partest.nest.NestRunner "$@"