added scalatest option "--cldc"

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@13303 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
michelou 2007-11-19 18:52:02 +00:00
parent 23b7170a78
commit db4592e115
4 changed files with 103 additions and 9 deletions

View File

@ -656,8 +656,8 @@ BUILD QUICK-TEST LAYER
<!-- =========================================================================== <!-- ===========================================================================
CLDC CLDC
============================================================================ --> ============================================================================ -->
<property name="cldc.name" value="cldcapi10.jar"/>
<property name="cldc.jar" value="${lib.dir}/${cldc.name}"/> <property name="cldcapi.jar" value="${lib.dir}/cldcapi10.jar"/>
<target name="cldc.sources" <target name="cldc.sources"
description="Create the source directory for the J2ME (CLDC) library" description="Create the source directory for the J2ME (CLDC) library"
@ -693,15 +693,16 @@ CLDC
depends="setup.quick, cldc.sources" depends="setup.quick, cldc.sources"
description="Builds the Scala library for J2ME (CLDC)" description="Builds the Scala library for J2ME (CLDC)"
> >
<mkdir dir="${cldc.dir}/lib/library"/>
<javac <javac
srcdir="${cldc.dir}/src" srcdir="${cldc.dir}/src"
destdir="${cldc.dir}" destdir="${cldc.dir}/lib/library"
source="1.1" source="1.1"
target="1.1" target="1.1"
deprecation="${jc.deprecation}" deprecation="${jc.deprecation}"
> >
<bootclasspath> <bootclasspath>
<pathelement location="${cldc.jar}"/> <pathelement location="${cldcapi.jar}"/>
</bootclasspath> </bootclasspath>
<include name="**/*.java"/> <include name="**/*.java"/>
<exclude name="scala/runtime/FloatRef.java"/> <exclude name="scala/runtime/FloatRef.java"/>
@ -710,14 +711,14 @@ CLDC
<quick <quick
srcdir="${cldc.dir}/src" srcdir="${cldc.dir}/src"
destdir="${cldc.dir}" destdir="${cldc.dir}/lib/library"
usepredefs="no" usepredefs="no"
addparams="${nsc.params}" addparams="${nsc.params}"
target="cldc" target="cldc"
scalacdebugging="${nsc.log-files}" scalacdebugging="${nsc.log-files}"
> >
<bootclasspath> <bootclasspath>
<pathelement location="${cldc.jar}"/> <pathelement location="${cldcapi.jar}"/>
</bootclasspath> </bootclasspath>
<classpath> <classpath>
<pathelement location="${cldc.dir}"/> <pathelement location="${cldc.dir}"/>
@ -726,13 +727,13 @@ CLDC
</quick> </quick>
<quick <quick
srcdir="${cldc.dir}/src" srcdir="${cldc.dir}/src"
destdir="${cldc.dir}" destdir="${cldc.dir}/lib/library"
target="cldc" target="cldc"
addparams="${nsc.params}" addparams="${nsc.params}"
scalacdebugging="${nsc.log-files}" scalacdebugging="${nsc.log-files}"
> >
<bootclasspath> <bootclasspath>
<pathelement location="${cldc.jar}"/> <pathelement location="${cldcapi.jar}"/>
</bootclasspath> </bootclasspath>
<classpath> <classpath>
<pathelement location="${cldc.dir}"/> <pathelement location="${cldc.dir}"/>
@ -754,7 +755,11 @@ CLDC
<exclude name="scala/xml/**"/> <exclude name="scala/xml/**"/>
<excludesfile name="${nsc.excludes}" if="excludes.avail"/> <excludesfile name="${nsc.excludes}" if="excludes.avail"/>
</quick> </quick>
<jar
destfile="${cldc.dir}/lib/scala-cldc-library.jar"
basedir="${cldc.dir}/lib/library"
includes="scala/**/*.class"
/>
</target> </target>
<!-- =========================================================================== <!-- ===========================================================================
@ -1506,6 +1511,16 @@ GENERATES A DISTRIBUTION
<binset dir="${quick.dir}/bin" includes="scala*net*"/> <binset dir="${quick.dir}/bin" includes="scala*net*"/>
<libset dir="${quick.dir}/lib" includes="*.dll"/> <libset dir="${quick.dir}/lib" includes="*.dll"/>
</quicksbaz> </quicksbaz>
<!-- Creates the CLDC package -->
<quicksbaz
file="${dist.dir}/scala-cldc-${version.number}.sbp"
adfile="${dist.dir}/scala-cldc-${version.number}.advert"
name="scala-cldc"
version="${version.number}"
desc="The Scala CLDC package contains everything needed to use Scala on CLDC devices."
link="${sbaz.universe}/scala-cldc-${version.number}.sbp">
<libset dir="${cldc.dir}/lib" includes="*.jar"/>
</quicksbaz>
</target> </target>
<target name="build.archive" depends="build.dist"> <target name="build.archive" depends="build.dist">

View File

@ -0,0 +1 @@
Execution completed.

View File

@ -0,0 +1,29 @@
import javax.microedition.lcdui._
import javax.microedition.midlet.MIDlet
class Test extends MIDlet with CommandListener {
def startApp {
val display = Display.getDisplay(this)
val mainForm = new Form("randoms")
mainForm append "Welcome to the world of MIDlets!"
mainForm append "(build with Scala)"
//val rnd = new Random
//for (i <- 0 until 10) mainForm append rnd.nextInt.toString
val exitCommand = new Command("Exit", Command.EXIT, 0)
mainForm addCommand exitCommand
mainForm setCommandListener this
display setCurrent mainForm
}
def pauseApp {}
def destroyApp(unconditional: Boolean) {}
def commandAction(c: Command, s: Displayable) {
if (c.getCommandType == Command.EXIT)
notifyDestroyed
}
}

View File

@ -315,6 +315,32 @@ test_run_msil() {
rm -f "$dstbase".$MSIL; rm -f "$dstbase".$MSIL;
} }
# Tests the CLDC backend/runtime.
test_run_cldc() {
rm -rf "$dstbase".unverified "$dstbase".preverified &&
mkdir -p "$dstbase".unverified "$dstbase".preverified &&
cpath=`get_os_pathlist $KVEM_CLDC:$KVEM_MIDP:$SCALA_CLDC:"$dstbase".unverified` &&
$SCALAC -bootclasspath $cpath -target:cldc -d "$os_dstbase".unverified "$os_srcbase".scala &&
$KVEM_PREVERIFY -classpath $cpath -target cldc1.0 -d "$os_dstbase".preverified "$os_dstbase".unverified &&
( echo MIDlet-Name: Test;
echo MIDlet-Version: 1.0.0;
echo MIDlet-Vendor: LAMP ) > "$dstbase".mf &&
$JARCMD cfm "$dstbase".jar "$dstbase".mf -C "$os_dstbase".preverified . &&
jarsize=`wc -c "$dstbase".jar | cut -d ' ' -f 1` &&
( echo MIDlet-1: Test, , Test;
echo MIDlet-Name: Test;
echo MIDlet-Version: 1.0.0;
echo MIDlet-Vendor: LAMP;
echo MIDlet-Jar-URL: "$dstbase".jar;
echo MIDlet-Jar-Size: $jarsize;
echo MicroEdition-Profile: MIDP-1.0;
echo MicroEdition-Configuration: CLDC-1.0 ) > "$dstbase".jad &&
cpath=`get_os_pathlist $SCALA_CLDC:"$dstbase".jar` &&
$KVEM_EMULATOR -cp $cpath -Xdescriptor:"$dstbase".jad 2> /dev/null &&
head $logfile -n 4 | tail -n 1 > $logfile.0 &&
mv $logfile.0 $logfile
}
# Tests a script with Scala code embedded in it # Tests a script with Scala code embedded in it
test_run_script() { test_run_script() {
argsfile="$srcbase.args" argsfile="$srcbase.args"
@ -476,6 +502,8 @@ test_check_all() {
"res" $FILES_RES; "res" $FILES_RES;
test_check_kind "Testing shootout benchmarks" \ test_check_kind "Testing shootout benchmarks" \
"shootout" $FILES_SHOOTOUT; "shootout" $FILES_SHOOTOUT;
test_check_kind "Testing CLDC benchmarks" \
"cldc" $FILES_CLDC;
} }
@ -495,6 +523,7 @@ test_add_file() {
TEST_ALL="false"; TEST_ALL="false";
case "$TEST_TYPE" in case "$TEST_TYPE" in
auto ) ;; auto ) ;;
cldc ) FILES_CLDC="$FILES_CLDC $1"; return;;
dis ) FILES_DIS="$FILES_DIS $1"; return;; dis ) FILES_DIS="$FILES_DIS $1"; return;;
run ) FILES_RUN="$FILES_RUN $1"; return;; run ) FILES_RUN="$FILES_RUN $1"; return;;
jvm ) FILES_JVM="$FILES_JVM $1"; return;; jvm ) FILES_JVM="$FILES_JVM $1"; return;;
@ -508,6 +537,7 @@ test_add_file() {
* ) abort "unknown test type \`$TEST_TYPE'";; * ) abort "unknown test type \`$TEST_TYPE'";;
esac; esac;
case "$1" in case "$1" in
cldc | */cldc | */cldc/* | cldc/* ) FILES_CLDC="$FILES_CLDC $1";;
dis | */dis | */dis/* | dis/* ) FILES_DIS="$FILES_DIS $1";; dis | */dis | */dis/* | dis/* ) FILES_DIS="$FILES_DIS $1";;
run | */run | */run/* | run/* ) FILES_RUN="$FILES_RUN $1";; run | */run | */run/* | run/* ) FILES_RUN="$FILES_RUN $1";;
jvm5 | */jvm5 | */jvm5* | jvm5/* ) jvm5 | */jvm5 | */jvm5* | jvm5/* )
@ -597,11 +627,13 @@ FILES_SCRIPT="";
FILES_DIS=""; FILES_DIS="";
FILES_ANT=""; FILES_ANT="";
FILES_SHOOTOUT=""; FILES_SHOOTOUT="";
FILES_CLDC="";
QUICK="$PREFIX/build/quick/bin" QUICK="$PREFIX/build/quick/bin"
QUICK_LIB="$PREFIX/build/quick/lib/library" QUICK_LIB="$PREFIX/build/quick/lib/library"
QUICK_COMP="$PREFIX/build/quick/lib/compiler" QUICK_COMP="$PREFIX/build/quick/lib/compiler"
QUICK_ACT="$PREFIX/build/quick/lib/actors" QUICK_ACT="$PREFIX/build/quick/lib/actors"
QUICK_CLDC="$PREFIX/build/cldc/lib/library"
JVM_EXT_CLASSPATH=`get_ext_classpath $TESTROOT/files/lib` JVM_EXT_CLASSPATH=`get_ext_classpath $TESTROOT/files/lib`
@ -633,6 +665,7 @@ BIN_DIR="$LATEST/" # BIN_DIR should have a trailing / when needed, so that
SCALA_LIB="$LATEST_LIB"; SCALA_LIB="$LATEST_LIB";
SCALA_COMP="$LATEST_COMP"; SCALA_COMP="$LATEST_COMP";
SCALA_ACT="$LATEST_ACT"; SCALA_ACT="$LATEST_ACT";
SCALA_CLDC="$QUICK_CLDC";
[ -x "$JAVACMD" ] || JAVACMD=java; [ -x "$JAVACMD" ] || JAVACMD=java;
[ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xmx256M -Xms16M"; [ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xmx256M -Xms16M";
@ -652,6 +685,7 @@ esac;
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case "$1" in case "$1" in
--auto ) TEST_TYPE="auto"; shift 1;; --auto ) TEST_TYPE="auto"; shift 1;;
--cldc ) TEST_TYPE="cldc"; shift 1;;
--dis ) TEST_TYPE="dis"; shift 1;; --dis ) TEST_TYPE="dis"; shift 1;;
--run ) TEST_TYPE="run"; shift 1;; --run ) TEST_TYPE="run"; shift 1;;
--jvm ) TEST_TYPE="jvm"; shift 1;; --jvm ) TEST_TYPE="jvm"; shift 1;;
@ -699,6 +733,9 @@ fi;
printf_initialization "${COLOR:-many}"; printf_initialization "${COLOR:-many}";
if [ "$TEST_ALL" = "true" ]; then if [ "$TEST_ALL" = "true" ]; then
case "$TEST_TYPE" in
cldc ) FILES_CLDC="$FILES_CLDC $SRCDIR/cldc";;
esac;
case "$TEST_TYPE" in case "$TEST_TYPE" in
dis ) FILES_DIS="$FILES_DIS $SRCDIR/dis";; dis ) FILES_DIS="$FILES_DIS $SRCDIR/dis";;
esac; esac;
@ -819,6 +856,18 @@ else
if [ "$TEST_TYPE" = "ant" ]; then if [ "$TEST_TYPE" = "ant" ]; then
ant_version=`$ANT -version`; ant_version=`$ANT -version`;
printf_outline "Ant version is : $ant_version\\n"; printf_outline "Ant version is : $ant_version\\n";
elif [ "$TEST_TYPE" = "cldc" ]; then
if [ -d "$KVEM_HOME" ]; then
KVEM_PREVERIFY="$KVEM_HOME/bin/preverify";
KVEM_EMULATOR="$KVEM_HOME/bin/emulator";
KVEM_CLDC=$PREFIX/lib/cldcapi10.jar;
KVEM_MIDP=$KVEM_HOME/lib/midpapi10.jar;
JARCMD=$bin_dir/jar;
else
abort "option 'cldc' requires variable KVEM_HOME to be set";
fi
kvem_version=`$KVEM_EMULATOR -version | head -1`;
printf_outline "Emulator version is : $kvem_version\\n";
fi fi
fi; fi;
printf_outline "\\n"; printf_outline "\\n";