First step towards a faster commit build.
1. Added new Ant tasks to build the compiler in a memory-efficient way. 2. Modified Partest to make it more extensible and added an Ant task to run it. 3. Created a SuperSABBUS build file (beta) using these new tasks. git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@14226 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
16a5651682
commit
e4216bbee2
|
@ -655,6 +655,7 @@ BUILD QUICK-TEST LAYER
|
|||
<pathelement location="${quick.dir}/lib/library"/>
|
||||
<pathelement location="${quick.dir}/lib/compiler"/>
|
||||
<pathelement location="${quick.dir}/lib/actors"/>
|
||||
<pathelement location="${ant.jar}"/>
|
||||
</classpath>
|
||||
</locker>
|
||||
<echo
|
||||
|
|
|
@ -0,0 +1,645 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project name="sabbus" default="build">
|
||||
|
||||
<description>
|
||||
I am SuperSABBUS for Scala core, the fast but simple version of SABBUS.
|
||||
</description>
|
||||
|
||||
<echo message="SuperSABBUS is BETA: quality cannot be inferred from its result"/>
|
||||
|
||||
<!-- ===========================================================================
|
||||
PROPERTIES
|
||||
============================================================================ -->
|
||||
|
||||
<property environment="env"/>
|
||||
|
||||
<!-- Prevents system classpath from being used -->
|
||||
<property name="build.sysclasspath" value="ignore"/>
|
||||
|
||||
<!-- Defines the repository layout -->
|
||||
<property name="docs.dir" value="${basedir}/docs"/>
|
||||
<property name="lib.dir" value="${basedir}/lib"/>
|
||||
<property name="src.dir" value="${basedir}/src"/>
|
||||
<property name="test.dir" value="${basedir}/test"/>
|
||||
|
||||
<!-- Loads custom properties definitions -->
|
||||
<property name="properties.file" value="${basedir}/build.properties"/>
|
||||
<property file="${properties.file}"/>
|
||||
|
||||
<!-- Sets location of pre-compiled libraries -->
|
||||
<property name="lib.starr.jar" value="${lib.dir}/scala-library.jar"/>
|
||||
<property name="comp.starr.jar" value="${lib.dir}/scala-compiler.jar"/>
|
||||
<property name="fjbg.jar" value="${lib.dir}/fjbg.jar"/>
|
||||
<property name="msil.jar" value="${lib.dir}/msil.jar"/>
|
||||
<property name="jline.jar" value="${lib.dir}/jline.jar"/>
|
||||
<property name="ant.jar" value="${ant.home}/lib/ant.jar"/>
|
||||
<property name="ant-contrib.jar" value="${lib.dir}/ant-contrib.jar"/>
|
||||
|
||||
<!-- Sets location of build folders -->
|
||||
<property name="build.dir" value="${basedir}/build"/>
|
||||
<property name="build-locker.dir" value="${build.dir}/locker"/>
|
||||
<property name="build-quick.dir" value="${build.dir}/quick"/>
|
||||
<property name="build-strap.dir" value="${build.dir}/strap"/>
|
||||
<property name="build-docs.dir" value="${build.dir}/scaladoc"/>
|
||||
<property name="build-partest.dir" value="${build.dir}/partest"/>
|
||||
|
||||
<property name="dists.dir" value="${basedir}/dists"/>
|
||||
|
||||
<property name="copyright.string" value="Copyright 2002-2008, LAMP/EPFL"/>
|
||||
|
||||
<!-- ===========================================================================
|
||||
INITIALISATION
|
||||
============================================================================ -->
|
||||
|
||||
<target name="init">
|
||||
<!-- Setting-up Ant contrib tasks -->
|
||||
<taskdef resource="net/sf/antcontrib/antlib.xml"
|
||||
classpath="${ant-contrib.jar}"/>
|
||||
<!-- This is the start time for the distribution -->
|
||||
<stopwatch name="timer.dist"/>
|
||||
<tstamp prefix="time">
|
||||
<format property="human" pattern="EEEE, d MMMM yyyy, HH:mm:ss (zz)"/>
|
||||
<format property="short" pattern="yyyyMMddHHmmss"/>
|
||||
</tstamp>
|
||||
<!-- Finding out SVN revision -->
|
||||
<exec
|
||||
executable="svn" vmlauncher="no"
|
||||
errorproperty="svn.err" outputproperty="svn.out">
|
||||
<arg line=" info ${basedir}"/>
|
||||
</exec>
|
||||
<propertyregex
|
||||
property="svn.number" input="${svn.out}" select="\1"
|
||||
regexp="Revision: ([0-9]+)"
|
||||
defaultValue="0"/>
|
||||
<property name="init.avail" value="yes"/>
|
||||
<!-- Generating version number -->
|
||||
<property file="${basedir}/build.number"/>
|
||||
<property
|
||||
name="version.number"
|
||||
value="${version.major}.${version.minor}.${version.patch}.r${svn.number}-b${time.short}"/>
|
||||
<!-- And print-out what we are building -->
|
||||
<echo level="info" message="Build number is '${version.number}'"/>
|
||||
<echo level="info" message="Built ${time.human} from SVN revision ${svn.number}"/>
|
||||
<!-- Creating class-pathes -->
|
||||
<path id="starr.classpath">
|
||||
<pathelement location="${lib.starr.jar}"/>
|
||||
<pathelement location="${comp.starr.jar}"/>
|
||||
<pathelement location="${lib.dir}/sabbus.jar"/>
|
||||
<pathelement location="${fjbg.jar}"/>
|
||||
<pathelement location="${ant.jar}"/>
|
||||
</path>
|
||||
<!-- Creating boot-level tasks -->
|
||||
<taskdef resource="scala/tools/ant/sabbus/antlib.xml" classpathref="starr.classpath"/>
|
||||
</target>
|
||||
|
||||
<!-- ===========================================================================
|
||||
BUILD EVERYTHING
|
||||
============================================================================ -->
|
||||
|
||||
<target name="build" depends="test, distribution.build"/>
|
||||
|
||||
<!-- ===========================================================================
|
||||
BUILD LOCAL REFERENCE (LOCKER) LAYER
|
||||
============================================================================ -->
|
||||
|
||||
<target name="locker.check" depends="init">
|
||||
<condition property="locker.available">
|
||||
<available file="${build-locker.dir}/complete"/>
|
||||
</condition>
|
||||
</target>
|
||||
|
||||
<target name="locker.build" depends="locker.check" unless="locker.available">
|
||||
<stopwatch name="locker.timer"/>
|
||||
<!-- Build library -->
|
||||
<mkdir dir="${build-locker.dir}/lib/library"/>
|
||||
<javac
|
||||
srcdir="${src.dir}/library"
|
||||
destdir="${build-locker.dir}/lib/library"
|
||||
classpath="${build-locker.dir}/lib/library"
|
||||
includes="**/*.java"/>
|
||||
<sabmake id="starr.lib.scalac"
|
||||
destdir="${build-locker.dir}/lib/library"
|
||||
compilerpathref="starr.classpath"
|
||||
srcpath="${src.dir}/library">
|
||||
<compilationpath>
|
||||
<pathelement location="${build-locker.dir}/lib/library"/>
|
||||
</compilationpath>
|
||||
</sabmake>
|
||||
<sabuse id="starr.lib.scalac" srcdir="${src.dir}/library">
|
||||
<include name="scala/Predef.scala"/>
|
||||
</sabuse>
|
||||
<sabuse id="starr.lib.scalac" srcdir="${src.dir}/library">
|
||||
<include name="**/*.scala"/>
|
||||
<exclude name="scala/Predef.scala"/>
|
||||
<exclude name="scala/dbc/**"/>
|
||||
<exclude name="scala/actors/**"/>
|
||||
</sabuse>
|
||||
<propertyfile file="${build-locker.dir}/lib/library/library.properties">
|
||||
<entry key="version.number" value="${version.number}"/>
|
||||
<entry key="copyright.string" value="${copyright.string}"/>
|
||||
</propertyfile>
|
||||
<copy todir="${build-locker.dir}/lib/library">
|
||||
<fileset dir="${src.dir}/library">
|
||||
<include name="**/*.tmpl"/>
|
||||
<include name="**/*.xml"/>
|
||||
<include name="**/*.js"/>
|
||||
<include name="**/*.css"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<symlink link="${build-locker.dir}/lib/fjbg.jar" resource="${fjbg.jar}" overwrite="yes"/>
|
||||
<sabbreak id="starr.lib.scalac"/>
|
||||
<!-- Build compiler -->
|
||||
<mkdir dir="${build-locker.dir}/lib/compiler"/>
|
||||
<sabmake id="starr.comp.scalac"
|
||||
destdir="${build-locker.dir}/lib/compiler"
|
||||
compilerpathref="starr.classpath"
|
||||
srcpath="${src.dir}/compiler">
|
||||
<compilationpath>
|
||||
<pathelement location="${build-locker.dir}/lib/library"/>
|
||||
<pathelement location="${build-locker.dir}/lib/compiler"/>
|
||||
<pathelement location="${fjbg.jar}"/>
|
||||
<pathelement location="${msil.jar}"/>
|
||||
<pathelement location="${jline.jar}"/>
|
||||
<pathelement location="${ant.jar}"/>
|
||||
</compilationpath>
|
||||
</sabmake>
|
||||
<sabuse id="starr.comp.scalac" srcdir="${src.dir}/compiler">
|
||||
<include name="**/*.scala"/>
|
||||
</sabuse>
|
||||
<propertyfile file="${build-locker.dir}/lib/compiler/compiler.properties">
|
||||
<entry key="version.number" value="${version.number}"/>
|
||||
<entry key="copyright.string" value="${copyright.string}"/>
|
||||
</propertyfile>
|
||||
<copy todir="${build-locker.dir}/lib/compiler">
|
||||
<fileset dir="${src.dir}/compiler">
|
||||
<include name="**/*.tmpl"/>
|
||||
<include name="**/*.xml"/>
|
||||
<include name="**/*.js"/>
|
||||
<include name="**/*.css"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<sabbreak id="starr.comp.scalac"/>
|
||||
<!-- Timing the build -->
|
||||
<touch file="${build-locker.dir}/complete" verbose="no"/>
|
||||
<stopwatch name="locker.timer" action="total"/>
|
||||
</target>
|
||||
|
||||
<target name="locker.init" depends="locker.build">
|
||||
<path id="locker.classpath">
|
||||
<pathelement location="${build-locker.dir}/lib/library"/>
|
||||
<pathelement location="${build-locker.dir}/lib/compiler"/>
|
||||
<pathelement location="${fjbg.jar}"/>
|
||||
<pathelement location="${ant.jar}"/>
|
||||
</path>
|
||||
</target>
|
||||
|
||||
<!-- ===========================================================================
|
||||
BUILD QUICK LAYER
|
||||
============================================================================ -->
|
||||
|
||||
<target name="quick.check" depends="locker.init">
|
||||
<uptodate property="quick.available" targetfile="${build-quick.dir}/complete">
|
||||
<srcfiles dir="${src.dir}">
|
||||
<include name="library/**"/>
|
||||
<include name="compiler/**"/>
|
||||
<include name="dbc/**"/>
|
||||
<include name="actors/**"/>
|
||||
</srcfiles>
|
||||
</uptodate>
|
||||
</target>
|
||||
|
||||
<target name="quick.build" depends="quick.check" unless="quick.available">
|
||||
<stopwatch name="quick.timer"/>
|
||||
<!-- Build library -->
|
||||
<mkdir dir="${build-quick.dir}/lib/library"/>
|
||||
<javac
|
||||
srcdir="${src.dir}/library"
|
||||
destdir="${build-quick.dir}/lib/library"
|
||||
classpath="${build-quick.dir}/lib/library"
|
||||
includes="**/*.java"/>
|
||||
<javac srcdir="${src.dir}/actors"
|
||||
destdir="${build-quick.dir}/lib/library"
|
||||
classpath="${build-quick.dir}/lib/library"
|
||||
includes="**/*.java"/>
|
||||
<sabmake id="locker.lib.scalac"
|
||||
destdir="${build-quick.dir}/lib/library"
|
||||
compilerpathref="locker.classpath"
|
||||
srcpath="${src.dir}/library">
|
||||
<compilationpath>
|
||||
<pathelement location="${build-quick.dir}/lib/library"/>
|
||||
</compilationpath>
|
||||
</sabmake>
|
||||
<sabuse id="locker.lib.scalac" srcdir="${src.dir}/library">
|
||||
<include name="scala/Predef.scala"/>
|
||||
</sabuse>
|
||||
<sabuse id="locker.lib.scalac" srcdir="${src.dir}/library">
|
||||
<include name="**/*.scala"/>
|
||||
<exclude name="scala/Predef.scala"/>
|
||||
</sabuse>
|
||||
<sabuse id="locker.lib.scalac" srcdir="${src.dir}/actors">
|
||||
<include name="**/*.scala"/>
|
||||
</sabuse>
|
||||
<sabuse id="locker.lib.scalac" srcdir="${src.dir}/dbc">
|
||||
<include name="**/*.scala"/>
|
||||
</sabuse>
|
||||
<propertyfile file="${build-quick.dir}/lib/library/library.properties">
|
||||
<entry key="version.number" value="${version.number}"/>
|
||||
<entry key="copyright.string" value="${copyright.string}"/>
|
||||
</propertyfile>
|
||||
<copy todir="${build-quick.dir}/lib/library">
|
||||
<fileset dir="${src.dir}/library">
|
||||
<include name="**/*.tmpl"/>
|
||||
<include name="**/*.xml"/>
|
||||
<include name="**/*.js"/>
|
||||
<include name="**/*.css"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<symlink link="${build-quick.dir}/lib/fjbg.jar" resource="${fjbg.jar}" overwrite="yes"/>
|
||||
<sabbreak id="locker.lib.scalac"/>
|
||||
<!-- Build compiler -->
|
||||
<mkdir dir="${build-quick.dir}/lib/compiler"/>
|
||||
<sabmake id="locker.comp.scalac"
|
||||
destdir="${build-quick.dir}/lib/compiler"
|
||||
compilerpathref="locker.classpath"
|
||||
srcpath="${src.dir}/compiler">
|
||||
<compilationpath>
|
||||
<pathelement location="${build-quick.dir}/lib/library"/>
|
||||
<pathelement location="${build-quick.dir}/lib/compiler"/>
|
||||
<pathelement location="${fjbg.jar}"/>
|
||||
<pathelement location="${msil.jar}"/>
|
||||
<pathelement location="${jline.jar}"/>
|
||||
<pathelement location="${ant.jar}"/>
|
||||
</compilationpath>
|
||||
</sabmake>
|
||||
<sabuse id="locker.comp.scalac" srcdir="${src.dir}/compiler">
|
||||
<include name="**/*.scala"/>
|
||||
</sabuse>
|
||||
<propertyfile file="${build-quick.dir}/lib/compiler/compiler.properties">
|
||||
<entry key="version.number" value="${version.number}"/>
|
||||
<entry key="copyright.string" value="${copyright.string}"/>
|
||||
</propertyfile>
|
||||
<copy todir="${build-quick.dir}/lib/compiler">
|
||||
<fileset dir="${src.dir}/compiler">
|
||||
<include name="**/*.tmpl"/>
|
||||
<include name="**/*.xml"/>
|
||||
<include name="**/*.js"/>
|
||||
<include name="**/*.css"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<sabbreak id="locker.comp.scalac"/>
|
||||
<!-- Timing the build -->
|
||||
<touch file="${build-quick.dir}/complete" verbose="no"/>
|
||||
<stopwatch name="quick.timer" action="total"/>
|
||||
</target>
|
||||
|
||||
<target name="quick.init" depends="quick.build">
|
||||
<path id="quick.classpath">
|
||||
<pathelement location="${build-quick.dir}/lib/library"/>
|
||||
<pathelement location="${build-quick.dir}/lib/compiler"/>
|
||||
<pathelement location="${fjbg.jar}"/>
|
||||
<pathelement location="${ant.jar}"/>
|
||||
</path>
|
||||
<taskdef resource="scala/tools/ant/antlib.xml" classpathref="quick.classpath"/>
|
||||
</target>
|
||||
|
||||
<!-- ===========================================================================
|
||||
BUILD STRAP LAYER
|
||||
============================================================================ -->
|
||||
|
||||
<target name="strap.check" depends="quick.init">
|
||||
<uptodate property="strap.available" targetfile="${build-strap.dir}/complete">
|
||||
<srcfiles dir="${src.dir}">
|
||||
<include name="library/**"/>
|
||||
<include name="compiler/**"/>
|
||||
<include name="dbc/**"/>
|
||||
<include name="actors/**"/>
|
||||
</srcfiles>
|
||||
</uptodate>
|
||||
</target>
|
||||
|
||||
<target name="strap.build" depends="strap.check" unless="strap.available">
|
||||
<stopwatch name="strap.timer"/>
|
||||
<!-- Build library -->
|
||||
<mkdir dir="${build-strap.dir}/lib/library"/>
|
||||
<javac
|
||||
srcdir="${src.dir}/library"
|
||||
destdir="${build-strap.dir}/lib/library"
|
||||
classpath="${build-strap.dir}/lib/library"
|
||||
includes="**/*.java"/>
|
||||
<javac srcdir="${src.dir}/actors"
|
||||
destdir="${build-strap.dir}/lib/library"
|
||||
classpath="${build-strap.dir}/lib/library"
|
||||
includes="**/*.java"/>
|
||||
<sabmake id="quick.lib.scalac"
|
||||
destdir="${build-strap.dir}/lib/library"
|
||||
compilerpathref="quick.classpath"
|
||||
srcpath="${src.dir}/library">
|
||||
<compilationpath>
|
||||
<pathelement location="${build-strap.dir}/lib/library"/>
|
||||
</compilationpath>
|
||||
</sabmake>
|
||||
<sabuse id="quick.lib.scalac" srcdir="${src.dir}/library">
|
||||
<include name="scala/Predef.scala"/>
|
||||
</sabuse>
|
||||
<sabuse id="quick.lib.scalac" srcdir="${src.dir}/library">
|
||||
<include name="**/*.scala"/>
|
||||
<exclude name="scala/Predef.scala"/>
|
||||
</sabuse>
|
||||
<sabuse id="quick.lib.scalac" srcdir="${src.dir}/actors">
|
||||
<include name="**/*.scala"/>
|
||||
</sabuse>
|
||||
<sabuse id="quick.lib.scalac" srcdir="${src.dir}/dbc">
|
||||
<include name="**/*.scala"/>
|
||||
</sabuse>
|
||||
<propertyfile file="${build-strap.dir}/lib/library/library.properties">
|
||||
<entry key="version.number" value="${version.number}"/>
|
||||
<entry key="copyright.string" value="${copyright.string}"/>
|
||||
</propertyfile>
|
||||
<copy todir="${build-strap.dir}/lib/library">
|
||||
<fileset dir="${src.dir}/library">
|
||||
<include name="**/*.tmpl"/>
|
||||
<include name="**/*.xml"/>
|
||||
<include name="**/*.js"/>
|
||||
<include name="**/*.css"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<symlink link="${build-strap.dir}/lib/fjbg.jar" resource="${fjbg.jar}" overwrite="yes"/>
|
||||
<sabbreak id="quick.lib.scalac"/>
|
||||
<!-- Build compiler -->
|
||||
<mkdir dir="${build-strap.dir}/lib/compiler"/>
|
||||
<sabmake id="quick.comp.scalac"
|
||||
destdir="${build-strap.dir}/lib/compiler"
|
||||
compilerpathref="quick.classpath"
|
||||
srcpath="${src.dir}/compiler">
|
||||
<compilationpath>
|
||||
<pathelement location="${build-strap.dir}/lib/library"/>
|
||||
<pathelement location="${build-strap.dir}/lib/compiler"/>
|
||||
<pathelement location="${fjbg.jar}"/>
|
||||
<pathelement location="${msil.jar}"/>
|
||||
<pathelement location="${jline.jar}"/>
|
||||
<pathelement location="${ant.jar}"/>
|
||||
</compilationpath>
|
||||
</sabmake>
|
||||
<sabuse id="quick.comp.scalac" srcdir="${src.dir}/compiler">
|
||||
<include name="**/*.scala"/>
|
||||
</sabuse>
|
||||
<propertyfile file="${build-strap.dir}/lib/compiler/compiler.properties">
|
||||
<entry key="version.number" value="${version.number}"/>
|
||||
<entry key="copyright.string" value="${copyright.string}"/>
|
||||
</propertyfile>
|
||||
<copy todir="${build-strap.dir}/lib/compiler">
|
||||
<fileset dir="${src.dir}/compiler">
|
||||
<include name="**/*.tmpl"/>
|
||||
<include name="**/*.xml"/>
|
||||
<include name="**/*.js"/>
|
||||
<include name="**/*.css"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<sabbreak id="quick.comp.scalac"/>
|
||||
<!-- Timing the build -->
|
||||
<touch file="${build-strap.dir}/complete" verbose="no"/>
|
||||
<stopwatch name="strap.timer" action="total"/>
|
||||
</target>
|
||||
|
||||
<!-- ===========================================================================
|
||||
BUILD DOCUMENTATION
|
||||
============================================================================ -->
|
||||
|
||||
<target name="doc.check" depends="quick.init">
|
||||
<uptodate property="doc.available" targetfile="${build-docs.dir}/complete">
|
||||
<srcfiles dir="${src.dir}">
|
||||
<include name="library/**"/>
|
||||
<include name="dbc/**"/>
|
||||
<include name="actors/**"/>
|
||||
</srcfiles>
|
||||
</uptodate>
|
||||
</target>
|
||||
|
||||
<target name="doc.build" depends="doc.check" unless="doc.available">
|
||||
<stopwatch name="doc.timer"/>
|
||||
<mkdir dir="${build-docs.dir}"/>
|
||||
<scaladoc
|
||||
srcdir="${src.dir}"
|
||||
destdir="${build-docs.dir}"
|
||||
windowtitle="Scala Library"
|
||||
doctitle="Scala ${version.number} API"
|
||||
classpathref="quick.classpath">
|
||||
<include name="dbc/**/*.scala"/>
|
||||
<include name="actors/**/*.scala"/>
|
||||
<include name="library/**/*.scala"/>
|
||||
</scaladoc>
|
||||
<touch file="${build-docs.dir}/complete" verbose="no"/>
|
||||
<stopwatch name="doc.timer" action="total"/>
|
||||
</target>
|
||||
|
||||
<!-- ===========================================================================
|
||||
MAKE SMALL DISTRIBUTION
|
||||
============================================================================ -->
|
||||
|
||||
<target name="dist.check" depends="quick.init, partest.build">
|
||||
<uptodate property="dist.available" targetfile="${dists.dir}/complete">
|
||||
<srcfiles file="${build-quick.dir}/complete"/>
|
||||
<srcfiles file="${build-partest.dir}/complete"/>
|
||||
</uptodate>
|
||||
</target>
|
||||
|
||||
<target name="dist.build" depends="dist.check" unless="dist.available">
|
||||
<property name="dist.dir" value="${dists.dir}/scala-${version.number}"/>
|
||||
<!-- Packages libraries -->
|
||||
<mkdir dir="${dist.dir}/lib"/>
|
||||
<jar destfile="${dist.dir}/lib/scala-library.jar" update="true">
|
||||
<fileset dir="${build-quick.dir}/lib/library">
|
||||
<exclude name="scala/dbc/**"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
<jar destfile="${dist.dir}/lib/scala-dbc.jar" update="true">
|
||||
<fileset dir="${build-quick.dir}/lib/library">
|
||||
<include name="scala/dbc/**"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
<jar destfile="${dist.dir}/lib/scala-compiler.jar" update="true">
|
||||
<fileset dir="${build-quick.dir}/lib/compiler"/>
|
||||
<zipfileset src="${fjbg.jar}"/>
|
||||
<zipfileset src="${msil.jar}"/>
|
||||
</jar>
|
||||
<jar destfile="${dist.dir}/lib/scala-partest.jar" update="true">
|
||||
<fileset dir="${build-partest.dir}/lib"/>
|
||||
</jar>
|
||||
<!-- Make executables -->
|
||||
<mkdir dir="${dist.dir}/bin"/>
|
||||
<scalatool
|
||||
file="${dist.dir}/bin/scala"
|
||||
name="Scala code runner"
|
||||
class="scala.tools.nsc.MainGenericRunner"
|
||||
version="${version.number}"/>
|
||||
<scalatool
|
||||
file="${dist.dir}/bin/scalac"
|
||||
name="Scala compiler"
|
||||
class="scala.tools.nsc.Main"
|
||||
version="${version.number}"/>
|
||||
<scalatool
|
||||
file="${dist.dir}/bin/scaladoc"
|
||||
name="Scala doc generator"
|
||||
class="scala.tools.nsc.Main"
|
||||
toolflags="-Ydoc"
|
||||
version="${version.number}"/>
|
||||
<scalatool
|
||||
file="${dist.dir}/bin/fsc"
|
||||
name="Fast Scala compiler"
|
||||
class="scala.tools.nsc.CompileClient"
|
||||
version="${version.number}"/>
|
||||
<chmod perm="ugo+rx" file="${dist.dir}/bin/scala"/>
|
||||
<chmod perm="ugo+rx" file="${dist.dir}/bin/scalac"/>
|
||||
<chmod perm="ugo+rx" file="${dist.dir}/bin/scaladoc"/>
|
||||
<chmod perm="ugo+rx" file="${dist.dir}/bin/fsc"/>
|
||||
<!-- Point to latest -->
|
||||
<symlink link="${dists.dir}/latest" resource="${dist.dir}" overwrite="yes"/>
|
||||
<touch file="${dists.dir}/complete" verbose="no"/>
|
||||
</target>
|
||||
|
||||
<target name="dist.init" depends="dist.build">
|
||||
<path id="dist.classpath">
|
||||
<pathelement location="${dists.dir}/latest/lib/scala-library.jar"/>
|
||||
<pathelement location="${dists.dir}/latest/lib/scala-compiler.jar"/>
|
||||
<pathelement location="${dists.dir}/latest/lib/scala-partest.jar"/>
|
||||
<pathelement location="${ant.jar}"/>
|
||||
</path>
|
||||
</target>
|
||||
|
||||
<!-- ===========================================================================
|
||||
COMPLETE SMALL DISTRIBUTION
|
||||
============================================================================ -->
|
||||
|
||||
<target name="distribution.check" depends="doc.build, dist.build">
|
||||
</target>
|
||||
|
||||
<target name="distribution.build" depends="distribution.check" unless="distribution.available">
|
||||
<!-- Packages doc -->
|
||||
<mkdir dir="${dist.dir}/doc/api"/>
|
||||
<copy toDir="${dist.dir}/doc/api">
|
||||
<fileset dir="${build-docs.dir}"/>
|
||||
</copy>
|
||||
<!-- Packages source -->
|
||||
<mkdir dir="${dist.dir}/src"/>
|
||||
<jar destfile="${dist.dir}/src/scala-library-src.jar" update="true">
|
||||
<fileset dir="${src.dir}/library"/>
|
||||
<fileset dir="${src.dir}/actors"/>
|
||||
</jar>
|
||||
<jar destfile="${dist.dir}/src/scala-dbc-src.jar" update="true">
|
||||
<fileset dir="${src.dir}/dbc"/>
|
||||
</jar>
|
||||
<jar destfile="${dist.dir}/src/scala-compiler-src.jar" update="true">
|
||||
<fileset dir="${src.dir}/compiler"/>
|
||||
</jar>
|
||||
<touch file="${dists.dir}/complete-all" verbose="no"/>
|
||||
</target>
|
||||
|
||||
<!-- ===========================================================================
|
||||
BUILD PARTEST
|
||||
============================================================================ -->
|
||||
|
||||
<target name="partest.check" depends="quick.init">
|
||||
</target>
|
||||
|
||||
<target name="partest.build" depends="partest.check" unless="partest.available">
|
||||
<mkdir dir="${build-partest.dir}/lib"/>
|
||||
<javac
|
||||
srcdir="${src.dir}/partest"
|
||||
destdir="${build-partest.dir}/lib">
|
||||
<classpath>
|
||||
<path refid="quick.classpath"/>
|
||||
<pathelement location="${build-partest.dir}/lib"/>
|
||||
</classpath>
|
||||
<include name="**/*.java"/>
|
||||
</javac>
|
||||
<scalac
|
||||
srcdir="${src.dir}/partest"
|
||||
destdir="${build-partest.dir}/lib">
|
||||
<classpath>
|
||||
<path refid="quick.classpath"/>
|
||||
<pathelement location="${build-partest.dir}/lib"/>
|
||||
</classpath>
|
||||
<include name="**/*.scala"/>
|
||||
</scalac>
|
||||
<copy todir="${build-partest.dir}/lib">
|
||||
<fileset dir="${src.dir}/partest">
|
||||
<include name="**/*.xml"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<touch file="${build-partest.dir}/complete" verbose="no"/>
|
||||
</target>
|
||||
|
||||
<target name="partest.init" depends="partest.build"/>
|
||||
|
||||
<!-- ===========================================================================
|
||||
TEST DISTRIBUTION
|
||||
============================================================================ -->
|
||||
|
||||
<target name="stability.test" depends="strap.build">
|
||||
<stopwatch name="stability.timer"/>
|
||||
<same dir="${build-quick.dir}" todir="${build-strap.dir}" failondifferent="no">
|
||||
<exclude name="**/*.properties"/>
|
||||
</same>
|
||||
<stopwatch name="stability.timer" action="total"/>
|
||||
</target>
|
||||
|
||||
<target name="suite.test" depends="partest.init, dist.init">
|
||||
<taskdef resource="scala/tools/partest/antlib.xml" classpathref="dist.classpath"/>
|
||||
<partest classpathref="dist.classpath" showlog="yes">
|
||||
<postests dir="${test.dir}/files/pos" includes="*.scala"/>
|
||||
<negtests dir="${test.dir}/files/neg" includes="*.scala"/>
|
||||
<runtests dir="${test.dir}/files">
|
||||
<include name="run/**/*.scala"/>
|
||||
<include name="jvm/**/*.scala"/>
|
||||
<include name="jvm5/**/*.scala"/>
|
||||
</runtests>
|
||||
</partest>
|
||||
</target>
|
||||
|
||||
<target name="test" depends="stability.test, suite.test"/>
|
||||
|
||||
<!-- ===========================================================================
|
||||
MAKE SABBUS JAR (to remove once sabbus is part of starr library)
|
||||
============================================================================ -->
|
||||
|
||||
<target name="sabbus.build" depends="quick.init">
|
||||
<mkdir dir="${build.dir}/sabbus"/>
|
||||
<scalac
|
||||
srcdir="${src.dir}/compiler/scala/tools/ant/sabbus/"
|
||||
destdir="${build.dir}/sabbus">
|
||||
<include name="*.scala"/>
|
||||
<classpath>
|
||||
<pathelement location="${lib.starr.jar}"/>
|
||||
<pathelement location="${comp.starr.jar}"/>
|
||||
<pathelement location="${ant.jar}"/>
|
||||
</classpath>
|
||||
</scalac>
|
||||
<copy
|
||||
file="${src.dir}/compiler/scala/tools/ant/sabbus/antlib.xml"
|
||||
todir="${build.dir}/sabbus/scala/tools/ant/sabbus"/>
|
||||
<jar
|
||||
destfile="${lib.dir}/sabbus.jar"
|
||||
basedir="${build.dir}/sabbus"/>
|
||||
</target>
|
||||
|
||||
<target name="sabbus.init" depends="sabbus.build">
|
||||
|
||||
</target>
|
||||
|
||||
<!-- ===========================================================================
|
||||
CLEAN
|
||||
============================================================================ -->
|
||||
|
||||
<target name="build.clean"
|
||||
description="Removes all build products">
|
||||
<delete dir="${build.dir}" includeemptydirs="yes" quiet="yes" failonerror="no"/>
|
||||
</target>
|
||||
|
||||
<target name="clean"
|
||||
description="Removes all build products and distributions">
|
||||
<delete dir="${build.dir}" includeemptydirs="yes" quiet="yes" failonerror="no"/>
|
||||
<delete dir="${dists.dir}" includeemptydirs="yes" quiet="yes" failonerror="no"/>
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,170 @@
|
|||
/* __ *\
|
||||
** ________ ___ / / ___ Scala Ant Tasks **
|
||||
** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL **
|
||||
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||
** /____/\___/_/ |_/____/_/ | | **
|
||||
** |/ **
|
||||
\* */
|
||||
|
||||
// $Id: ScalaTool.scala 11911 2007-06-05 15:57:59Z odersky $
|
||||
|
||||
package scala.tools.ant
|
||||
|
||||
import java.io.{File, FileInputStream}
|
||||
|
||||
import org.apache.tools.ant.{BuildException, Project}
|
||||
import org.apache.tools.ant.taskdefs.MatchingTask
|
||||
import org.apache.tools.ant.util.FileUtils
|
||||
import org.apache.tools.ant.util.{FileNameMapper, IdentityMapper}
|
||||
|
||||
import org.apache.tools.ant.types.Mapper
|
||||
|
||||
/** <p>
|
||||
* An Ant task that, for a set of files, tests them for byte-to-byte
|
||||
* equality with one or more other files.
|
||||
* This task supports the following parameters as attributes:
|
||||
* </p><ul>
|
||||
* <li>dir</li>
|
||||
* <li>todir</li>
|
||||
* <li>resultproperty (a property to be set when all tested files pairs are equal, if not set, the task will fail instead),</li>
|
||||
* <li>failing (whether to stop if all files are not equal).</li></ul>
|
||||
* <p>It also support the following nested elements:</p><ul>
|
||||
* <li>mapper (a mapper from original files to test files).</li></ul>
|
||||
* <p>This task itself defines a fileset that represents the set of original files.</p>
|
||||
*
|
||||
* @author Gilles Dubochet
|
||||
* @version 1.0 */
|
||||
class Same extends MatchingTask {
|
||||
|
||||
/** The unique Ant file utilities instance to use in this task. */
|
||||
private val fileUtils = FileUtils.newFileUtils()
|
||||
|
||||
/*============================================================================*\
|
||||
** Ant user-properties **
|
||||
\*============================================================================*/
|
||||
|
||||
private var origin: Option[File] = None
|
||||
private var destination: Option[File] = None
|
||||
|
||||
private var resultProperty: Option[String] = None
|
||||
private var failing: Boolean = false
|
||||
|
||||
private var mapperElement: Option[Mapper] = None
|
||||
|
||||
/*============================================================================*\
|
||||
** Properties setters **
|
||||
\*============================================================================*/
|
||||
|
||||
def setDir(input: File) =
|
||||
origin = Some(input)
|
||||
|
||||
def setTodir(input: File) =
|
||||
destination = Some(input)
|
||||
|
||||
def setResultproperty(input: String) =
|
||||
resultProperty = Some(input)
|
||||
|
||||
def setFailondifferent(input: Boolean) =
|
||||
failing = input
|
||||
|
||||
def createMapper(): Mapper =
|
||||
if (mapperElement.isEmpty) {
|
||||
val mapper = new Mapper(getProject)
|
||||
mapperElement = Some(mapper)
|
||||
mapper
|
||||
}
|
||||
else throw new BuildException("Cannot define more than one mapper", getLocation)
|
||||
|
||||
def add(fileNameMapper: FileNameMapper) =
|
||||
createMapper().add(fileNameMapper)
|
||||
|
||||
/*============================================================================*\
|
||||
** Properties getters **
|
||||
\*============================================================================*/
|
||||
|
||||
private def getMapper: FileNameMapper = mapperElement match {
|
||||
case None =>
|
||||
new IdentityMapper()
|
||||
case Some(me) =>
|
||||
me.getImplementation
|
||||
}
|
||||
|
||||
/*============================================================================*\
|
||||
** Support methods **
|
||||
\*============================================================================*/
|
||||
|
||||
private var allEqualNow = true
|
||||
|
||||
/** Tests if all mandatory attributes are set and valid. */
|
||||
private def validateAttributes = {
|
||||
if (origin.isEmpty) error("Mandatory attribute 'dir' is not set.")
|
||||
if (destination.isEmpty) error("Mandatory attribute 'todir' is not set.")
|
||||
}
|
||||
|
||||
private def reportDiff(f1: File, f2: File) = {
|
||||
allEqualNow = false
|
||||
log("File '" + f1 + "' is different from correspondant.")
|
||||
}
|
||||
|
||||
private def reportMissing(f1: File) = {
|
||||
allEqualNow = false
|
||||
log("File '" + f1 + "' has no correspondant.")
|
||||
}
|
||||
|
||||
/*============================================================================*\
|
||||
** The big execute method **
|
||||
\*============================================================================*/
|
||||
|
||||
override def execute() = {
|
||||
validateAttributes
|
||||
val mapper = getMapper
|
||||
allEqualNow = true
|
||||
val originNames: Array[String] = getDirectoryScanner(origin.get).getIncludedFiles
|
||||
val bufferSize = 1024
|
||||
val originBuffer = new Array[Byte](bufferSize)
|
||||
val destBuffer = new Array[Byte](bufferSize)
|
||||
for (
|
||||
originName: String <- originNames;
|
||||
destName: String <- mapper.mapFileName(originName.toString)
|
||||
) {
|
||||
//println("originName="+originName)
|
||||
//println("destName ="+destName)
|
||||
var equalNow = true
|
||||
val originFile = new File(origin.get, originName)
|
||||
val destFile = new File(destination.get, destName)
|
||||
if (originFile.canRead && destFile.canRead) {
|
||||
val originStream = new FileInputStream(originFile)
|
||||
val destStream = new FileInputStream(destFile)
|
||||
var originRemaining = originStream.read(originBuffer)
|
||||
var destRemaining = destStream.read(destBuffer)
|
||||
while (originRemaining > 0 && equalNow) {
|
||||
if (originRemaining == destRemaining)
|
||||
for (idx <- 0 until originRemaining)
|
||||
equalNow = equalNow && (originBuffer(idx) == destBuffer(idx))
|
||||
else
|
||||
equalNow = false
|
||||
originRemaining = originStream.read(originBuffer)
|
||||
destRemaining = destStream.read(destBuffer)
|
||||
}
|
||||
if (destRemaining > 0)
|
||||
equalNow = false
|
||||
if (!equalNow)
|
||||
reportDiff(originFile, destFile)
|
||||
originStream.close
|
||||
destStream.close
|
||||
}
|
||||
else reportMissing(originFile)
|
||||
}
|
||||
if (!allEqualNow)
|
||||
if (failing)
|
||||
error("There were differences between '" + origin.get + "' and '" + destination.get + "'")
|
||||
else
|
||||
log("There were differences between '" + origin.get + "' and '" + destination.get + "'")
|
||||
else {
|
||||
if (!resultProperty.isEmpty)
|
||||
getProject.setProperty(resultProperty.get, "yes")
|
||||
log("All files in '" + origin.get + "' and '" + destination.get + "' are equal", Project.MSG_VERBOSE)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -11,6 +11,10 @@
|
|||
classname="scala.tools.ant.ScalaBazaar"/>
|
||||
<taskdef name="scaladoc"
|
||||
classname="scala.tools.ant.Scaladoc"/>
|
||||
<taskdef name="scalatool"
|
||||
classname="scala.tools.ant.ScalaTool"/>
|
||||
<taskdef name="same"
|
||||
classname="scala.tools.ant.Same"/>
|
||||
<!--<taskdef name="scalatest"
|
||||
classname="scala.tools.ant.ScalaDoc"/>-->
|
||||
</antlib>
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/* __ *\
|
||||
** ________ ___ / / ___ Scala Ant Tasks **
|
||||
** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL **
|
||||
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||
** /____/\___/_/ |_/____/_/ | | **
|
||||
** |/ **
|
||||
\* */
|
||||
|
||||
package scala.tools.ant.sabbus
|
||||
|
||||
import org.apache.tools.ant.Task
|
||||
|
||||
class Break extends Task {
|
||||
|
||||
def setId(input: String): Unit = {
|
||||
id = Some(input)
|
||||
}
|
||||
|
||||
private var id: Option[String] = None
|
||||
|
||||
override def execute: Unit = {
|
||||
if (id.isEmpty) error("Attribute 'id' is not set")
|
||||
Compilers.break(id.get)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
/* __ *\
|
||||
** ________ ___ / / ___ Scala Ant Tasks **
|
||||
** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL **
|
||||
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||
** /____/\___/_/ |_/____/_/ | | **
|
||||
** |/ **
|
||||
\* */
|
||||
|
||||
package scala.tools.ant.sabbus
|
||||
|
||||
case class CompilationFailure(message: String, cause: Exception) extends Exception(message, cause)
|
|
@ -0,0 +1,46 @@
|
|||
/* __ *\
|
||||
** ________ ___ / / ___ Scala Ant Tasks **
|
||||
** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL **
|
||||
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||
** /____/\___/_/ |_/____/_/ | | **
|
||||
** |/ **
|
||||
\* */
|
||||
|
||||
package scala.tools.ant.sabbus
|
||||
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
|
||||
class Compiler(classpath: Array[URL], val settings: CompilerSettings) {
|
||||
|
||||
private lazy val classLoader: ClassLoader =
|
||||
new java.net.URLClassLoader(classpath, null)
|
||||
|
||||
private lazy val foreignCompilerName: String =
|
||||
"scala.tools.ant.sabbus.ForeignCompiler"
|
||||
private lazy val foreignCompiler: AnyRef =
|
||||
classLoader.loadClass(foreignCompilerName).newInstance.asInstanceOf[AnyRef]
|
||||
|
||||
foreignInvoke("args_$eq", Array(classOf[String]), Array(settings.toArgs))
|
||||
|
||||
private def foreignInvoke(method: String, types: Array[Class[T] forSome { type T }] , args: Array[AnyRef]) =
|
||||
try {
|
||||
foreignCompiler.getClass.getMethod(method, types).invoke(foreignCompiler, args)
|
||||
}
|
||||
catch {
|
||||
case e: InvocationTargetException => throw e.getCause
|
||||
}
|
||||
|
||||
def compile(files: Array[File]): (Int, Int) = //(errors, warnings)
|
||||
try {
|
||||
val result =
|
||||
foreignInvoke("compile", Array(classOf[Array[File]]), Array(files)).asInstanceOf[Int]
|
||||
(result >> 16, result & 0x00FF)
|
||||
}
|
||||
catch {
|
||||
case ex: Exception =>
|
||||
throw CompilationFailure(ex.getMessage, ex)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
/* __ *\
|
||||
** ________ ___ / / ___ Scala Ant Tasks **
|
||||
** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL **
|
||||
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||
** /____/\___/_/ |_/____/_/ | | **
|
||||
** |/ **
|
||||
\* */
|
||||
|
||||
package scala.tools.ant.sabbus
|
||||
|
||||
import java.io.File
|
||||
|
||||
import org.apache.tools.ant.types.{Path, Reference}
|
||||
|
||||
class CompilerSettings {
|
||||
|
||||
private var gBf: Option[String] = None
|
||||
def g = gBf.get
|
||||
def g_=(s: String): this.type = { gBf = Some(s); this }
|
||||
|
||||
private var uncheckedBf: Boolean = false
|
||||
def unchecked = uncheckedBf
|
||||
def unchecked_=(b: Boolean): this.type = { uncheckedBf = b; this }
|
||||
|
||||
private var classpathBf: Option[Path] = None
|
||||
def classpath = classpathBf.get
|
||||
def classpath_=(p: Path): this.type = { classpathBf = Some(p); this }
|
||||
|
||||
private var sourcepathBf: Option[Path] = None
|
||||
def sourcepath = sourcepathBf.get
|
||||
def sourcepath_=(p: Path): this.type = { sourcepathBf = Some(p); this }
|
||||
|
||||
private var bootclasspathBf: Option[Path] = None
|
||||
def bootclasspath = bootclasspathBf.get
|
||||
def bootclasspath_=(p: Path): this.type = { bootclasspathBf = Some(p); this }
|
||||
|
||||
private var extdirsBf: Option[Path] = None
|
||||
def extdirs = extdirsBf.get
|
||||
def extdirs_=(p: Path): this.type = { extdirsBf = Some(p); this }
|
||||
|
||||
private var dBf: Option[File] = None
|
||||
def d = dBf.get
|
||||
def d_=(f: File): this.type = { dBf = Some(f); this }
|
||||
|
||||
private var encodingBf: Option[String] = None
|
||||
def encoding = encodingBf.get
|
||||
def encoding_=(s: String): this.type = { encodingBf = Some(s); this }
|
||||
|
||||
private var targetBf: Option[String] = None
|
||||
def target = targetBf.get
|
||||
def target_=(s: String): this.type = { targetBf = Some(s); this }
|
||||
|
||||
private var optimiseBf: Boolean = false
|
||||
def optimise = optimiseBf
|
||||
def optimise_=(b: Boolean): Unit = { optimiseBf = b }
|
||||
|
||||
private var moreBf: Option[String] = None
|
||||
def more = moreBf.get
|
||||
def more_=(s: String): this.type = { moreBf = Some(s); this }
|
||||
|
||||
def toArgs: String = ("" +
|
||||
(if (!gBf.isEmpty) "-g:" + g + " " else "") +
|
||||
(if (uncheckedBf) "-unchecked " else "") +
|
||||
(if (!classpathBf.isEmpty) "-classpath " + classpath + " " else "") +
|
||||
(if (!sourcepathBf.isEmpty) "-sourcepath " + sourcepath + " " else "") +
|
||||
(if (!bootclasspathBf.isEmpty) "-bootclasspath " + bootclasspath + " " else "") +
|
||||
(if (!extdirsBf.isEmpty) "-extdirs " + extdirs + " " else "") +
|
||||
(if (!dBf.isEmpty) "-d " + d + " " else "") +
|
||||
(if (!encodingBf.isEmpty) "-encoding " + encoding + " " else "") +
|
||||
(if (!targetBf.isEmpty) "-target:" + target + " " else "") +
|
||||
(if (optimiseBf) "-optimise " else "") +
|
||||
(if (!moreBf.isEmpty) more else "")
|
||||
)
|
||||
|
||||
override def equals(that: Any): Boolean = that match {
|
||||
case cs: CompilerSettings =>
|
||||
this.gBf == cs.gBf &&
|
||||
this.uncheckedBf == cs.uncheckedBf &&
|
||||
this.classpathBf == cs.classpathBf &&
|
||||
this.sourcepathBf == cs.sourcepathBf &&
|
||||
this.bootclasspathBf == cs.bootclasspathBf &&
|
||||
this.extdirsBf == cs.extdirsBf &&
|
||||
this.dBf == cs.dBf &&
|
||||
this.encodingBf == cs.encodingBf &&
|
||||
this.targetBf == cs.targetBf &&
|
||||
this.optimiseBf == cs.optimiseBf &&
|
||||
this.moreBf == cs.moreBf
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/* __ *\
|
||||
** ________ ___ / / ___ Scala Ant Tasks **
|
||||
** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL **
|
||||
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||
** /____/\___/_/ |_/____/_/ | | **
|
||||
** |/ **
|
||||
\* */
|
||||
|
||||
package scala.tools.ant.sabbus
|
||||
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
|
||||
object CompilerTest {
|
||||
|
||||
def main(args: Array[String]): Unit = {
|
||||
|
||||
implicit def fileToURL(file: File): URL = file.toURL
|
||||
|
||||
val scalalib = new File("/Developer/Scala/latest/lib")
|
||||
val sabbus = new File("/Users/Dubochet/Documents/Eclipse/FaSabbus")
|
||||
|
||||
val classpath: Array[URL] = Array (
|
||||
new File(scalalib, "scala-library.jar"),
|
||||
new File(scalalib, "scala-compiler.jar"),
|
||||
new File(sabbus, "bin")
|
||||
)
|
||||
|
||||
val settings = new CompilerSettings
|
||||
settings.d = new File("/Users/Dubochet/Documents/Eclipse/FaSabbus/bin_sabbus")
|
||||
val compiler = new Compiler(classpath, settings)
|
||||
|
||||
val files: Array[File] = Array (
|
||||
new File(sabbus, "src/scala/tools/ant/sabbus/CompilationFailure.scala"),
|
||||
new File(sabbus, "src/scala/tools/ant/sabbus/Compiler.scala"),
|
||||
new File(sabbus, "src/scala/tools/ant/sabbus/CompilerTest.scala"),
|
||||
new File(sabbus, "src/scala/tools/ant/sabbus/ForeignCompiler.scala")
|
||||
)
|
||||
|
||||
if (compiler.compile(files)._1 == 0)
|
||||
println("Everything a-okey, sir!")
|
||||
else
|
||||
println("We had some issues, sir!")
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/* __ *\
|
||||
** ________ ___ / / ___ Scala Ant Tasks **
|
||||
** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL **
|
||||
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||
** /____/\___/_/ |_/____/_/ | | **
|
||||
** |/ **
|
||||
\* */
|
||||
|
||||
package scala.tools.ant.sabbus
|
||||
|
||||
import java.net.URL
|
||||
|
||||
object Compilers extends collection.Map[String, Compiler] {
|
||||
|
||||
val debug = false
|
||||
|
||||
private val container = new collection.mutable.HashMap[String, Compiler]
|
||||
|
||||
def elements = container.elements
|
||||
|
||||
def get(id: String) = container.get(id)
|
||||
|
||||
def size = container.size
|
||||
|
||||
def make(id: String, classpath: Array[URL], settings: CompilerSettings): Compiler = {
|
||||
val runtime = Runtime.getRuntime
|
||||
if (debug) println("Making compiler " + id)
|
||||
if (debug) println(" memory before: " + (runtime.freeMemory/1048576.).formatted("%10.2f") + " MB")
|
||||
val comp = new Compiler(classpath, settings)
|
||||
container += Pair(id, comp)
|
||||
if (debug) println(" memory after: " + (runtime.freeMemory/1048576.).formatted("%10.2f") + " MB")
|
||||
comp
|
||||
}
|
||||
|
||||
def break(id: String): Null = {
|
||||
val runtime = Runtime.getRuntime
|
||||
if (debug) println("Breaking compiler " + id)
|
||||
if (debug) println(" memory before: " + (runtime.freeMemory/1048576.).formatted("%10.2f") + " MB")
|
||||
container -= id
|
||||
System.gc
|
||||
if (debug) println(" memory after: " + (runtime.freeMemory/1048576.).formatted("%10.2f") + " MB")
|
||||
null
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/* __ *\
|
||||
** ________ ___ / / ___ Scala Ant Tasks **
|
||||
** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL **
|
||||
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||
** /____/\___/_/ |_/____/_/ | | **
|
||||
** |/ **
|
||||
\* */
|
||||
|
||||
package scala.tools.ant.sabbus
|
||||
|
||||
import java.io.File
|
||||
|
||||
import scala.tools.nsc._
|
||||
import scala.tools.nsc.reporters.ConsoleReporter
|
||||
|
||||
class ForeignCompiler {
|
||||
|
||||
private var argsBuffer: String = null
|
||||
def args: String = argsBuffer
|
||||
def args_=(a: String): Unit = {
|
||||
if (args != null) throw new Error("Argument must be set only once")
|
||||
argsBuffer = a
|
||||
nsc
|
||||
}
|
||||
|
||||
private val error: (String => Nothing) = { msg => throw new Exception(msg) }
|
||||
|
||||
private def settings = new Settings(error)
|
||||
|
||||
private lazy val reporter = new ConsoleReporter(settings)
|
||||
|
||||
private lazy val nsc: Global = {
|
||||
try {
|
||||
val command = new CompilerCommand(List.fromString(args, ' '), settings, error, false)
|
||||
new Global(command.settings, reporter)
|
||||
}
|
||||
catch {
|
||||
case ex @ FatalError(msg) =>
|
||||
throw new Exception(msg, ex)
|
||||
}
|
||||
}
|
||||
|
||||
def compile(files: Array[File]): Int = {
|
||||
val command = new CompilerCommand(files.toList.map(_.toString), settings, error, true)
|
||||
(new nsc.Run) compile command.files
|
||||
reporter.ERROR.count << 16 | reporter.WARNING.count
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/* __ *\
|
||||
** ________ ___ / / ___ Scala Ant Tasks **
|
||||
** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL **
|
||||
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||
** /____/\___/_/ |_/____/_/ | | **
|
||||
** |/ **
|
||||
\* */
|
||||
|
||||
package scala.tools.ant.sabbus
|
||||
|
||||
import java.net.URL
|
||||
import java.io.File
|
||||
import org.apache.tools.ant.Task
|
||||
import org.apache.tools.ant.types.{Path, Reference}
|
||||
|
||||
class Make extends Task {
|
||||
|
||||
def setId(input: String): Unit = {
|
||||
id = Some(input)
|
||||
}
|
||||
|
||||
def setParams(input: String): Unit = {
|
||||
params = params match {
|
||||
case None => Some(input)
|
||||
case Some(ps) => Some(ps + " " + input)
|
||||
}
|
||||
}
|
||||
|
||||
def setCompilationPath(input: Path): Unit = {
|
||||
if (compilationPath.isEmpty) compilationPath = Some(input)
|
||||
else compilationPath.get.append(input)
|
||||
}
|
||||
|
||||
def createCompilationPath: Path = {
|
||||
if (compilationPath.isEmpty) compilationPath = Some(new Path(getProject()))
|
||||
compilationPath.get.createPath()
|
||||
}
|
||||
|
||||
def setCompilationPathRef(input: Reference): Unit = {
|
||||
createCompilationPath.setRefid(input)
|
||||
}
|
||||
|
||||
def setSrcPath(input: Path): Unit = {
|
||||
if (sourcePath.isEmpty) sourcePath = Some(input)
|
||||
else sourcePath.get.append(input)
|
||||
}
|
||||
|
||||
def createSrcPath: Path = {
|
||||
if (sourcePath.isEmpty) sourcePath = Some(new Path(getProject()))
|
||||
sourcePath.get.createPath()
|
||||
}
|
||||
|
||||
def setSrcPathRef(input: Reference): Unit = {
|
||||
createSrcPath.setRefid(input)
|
||||
}
|
||||
|
||||
def setCompilerPath(input: Path): Unit = {
|
||||
if (compilerPath.isEmpty) compilerPath = Some(input)
|
||||
else compilerPath.get.append(input)
|
||||
}
|
||||
|
||||
def createCompilerPath: Path = {
|
||||
if (compilerPath.isEmpty) compilerPath = Some(new Path(getProject()))
|
||||
compilerPath.get.createPath()
|
||||
}
|
||||
|
||||
def setCompilerPathRef(input: Reference): Unit = {
|
||||
createCompilerPath.setRefid(input)
|
||||
}
|
||||
|
||||
def setDestdir(input: File): Unit = {
|
||||
destinationDir = Some(input)
|
||||
}
|
||||
|
||||
private var id: Option[String] = None
|
||||
private var params: Option[String] = None
|
||||
private var compilationPath: Option[Path] = None
|
||||
private var sourcePath: Option[Path] = None
|
||||
private var compilerPath: Option[Path] = None
|
||||
private var destinationDir: Option[File] = None
|
||||
|
||||
override def execute: Unit = {
|
||||
if (id.isEmpty) error("Mandatory attribute 'id' is not set.")
|
||||
if (compilerPath.isEmpty) error("Mandatory attribute 'compilerpath' is not set.")
|
||||
if (destinationDir.isEmpty) error("Mandatory attribute 'destdir' is not set.")
|
||||
val settings = new CompilerSettings
|
||||
if (!destinationDir.isEmpty) settings.d = destinationDir.get
|
||||
if (!compilationPath.isEmpty) settings.classpath = compilationPath.get
|
||||
if (!sourcePath.isEmpty) settings.sourcepath = sourcePath.get
|
||||
if (!params.isEmpty) settings.more = params.get
|
||||
Compilers.make(id.get, (compilerPath.get.list.map{ path => new File(path).toURL }), settings)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/* __ *\
|
||||
** ________ ___ / / ___ Scala Ant Tasks **
|
||||
** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL **
|
||||
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||
** /____/\___/_/ |_/____/_/ | | **
|
||||
** |/ **
|
||||
\* */
|
||||
|
||||
package scala.tools.ant.sabbus
|
||||
|
||||
import java.io.File
|
||||
|
||||
import org.apache.tools.ant.taskdefs.MatchingTask
|
||||
import org.apache.tools.ant.types.{Path, Reference}
|
||||
import org.apache.tools.ant.util.{GlobPatternMapper, SourceFileScanner}
|
||||
|
||||
class Use extends MatchingTask {
|
||||
|
||||
def setId(input: String): Unit = {
|
||||
id = Some(input)
|
||||
}
|
||||
|
||||
def setSrcdir(input: File) {
|
||||
sourceDir = Some(input)
|
||||
}
|
||||
|
||||
def setFailOnError(input: Boolean): Unit = {
|
||||
failOnError = input
|
||||
}
|
||||
|
||||
private var id: Option[String] = None
|
||||
private var sourceDir: Option[File] = None
|
||||
private var failOnError: Boolean = true
|
||||
|
||||
override def execute(): Unit = {
|
||||
if (id.isEmpty) error("Mandatory attribute 'id' is not set.")
|
||||
if (sourceDir.isEmpty) error("Mandatory attribute 'srcdir' is not set.")
|
||||
val compiler = Compilers(id.get)
|
||||
val mapper = new GlobPatternMapper()
|
||||
mapper.setTo("*.class")
|
||||
mapper.setFrom("*.scala")
|
||||
val includedFiles: Array[File] =
|
||||
new SourceFileScanner(this).restrict(
|
||||
getDirectoryScanner(sourceDir.get).getIncludedFiles,
|
||||
sourceDir.get,
|
||||
compiler.settings.d,
|
||||
mapper
|
||||
) map (new File(sourceDir.get, _))
|
||||
if (includedFiles.size > 0)
|
||||
try {
|
||||
log("Compiling " + includedFiles.size + " file" + (if (includedFiles.size > 1) "s" else "") + " to " + compiler.settings.d.getAbsolutePath)
|
||||
//for (f <- includedFiles) log(" " + f.getAbsolutePath)
|
||||
//log("Attributes are " + compiler.settings.toArgs)
|
||||
val (errors, warnings) = compiler.compile(includedFiles)
|
||||
if (errors > 0)
|
||||
error("Compilation failed with " + errors + " error" + (if (errors > 1) "s" else "") + ".")
|
||||
else if (warnings > 0)
|
||||
log("Compilation suceeded with " + warnings + " warning" + (if (warnings > 1) "s" else "") + ".")
|
||||
}
|
||||
catch {
|
||||
case CompilationFailure(msg, ex) =>
|
||||
ex.printStackTrace
|
||||
val errorMsg =
|
||||
"Compilation failed because of an internal compiler error (" + msg + "); see the error output for details."
|
||||
if (failOnError) error(errorMsg) else log(errorMsg)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<antlib>
|
||||
<taskdef name="sabmake"
|
||||
classname="scala.tools.ant.sabbus.Make"/>
|
||||
<taskdef name="sabuse"
|
||||
classname="scala.tools.ant.sabbus.Use"/>
|
||||
<taskdef name="sabbreak"
|
||||
classname="scala.tools.ant.sabbus.Break"/>
|
||||
</antlib>
|
|
@ -0,0 +1,169 @@
|
|||
/* __ *\
|
||||
** ________ ___ / / ___ Scala Parallel Testing **
|
||||
** / __/ __// _ | / / / _ | (c) 2007-2008, LAMP/EPFL **
|
||||
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||
** /____/\___/_/ |_/____/_/ | | **
|
||||
** |/ **
|
||||
\* */
|
||||
|
||||
package scala.tools.partest
|
||||
|
||||
import scala.actors.Actor._
|
||||
|
||||
import java.io.File
|
||||
import java.net.URLClassLoader
|
||||
|
||||
import org.apache.tools.ant.Task
|
||||
import org.apache.tools.ant.types.{Path, Reference, FileSet}
|
||||
|
||||
class PartestTask extends Task {
|
||||
|
||||
def addConfiguredPosTests(input: FileSet): Unit =
|
||||
posFiles = Some(input)
|
||||
|
||||
def addConfiguredNegTests(input: FileSet): Unit =
|
||||
negFiles = Some(input)
|
||||
|
||||
def addConfiguredRunTests(input: FileSet): Unit =
|
||||
runFiles = Some(input)
|
||||
|
||||
def setClasspath(input: Path): Unit =
|
||||
if (classpath.isEmpty)
|
||||
classpath = Some(input)
|
||||
else
|
||||
classpath.get.append(input)
|
||||
|
||||
def createClasspath(): Path = {
|
||||
if (classpath.isEmpty) classpath = Some(new Path(getProject()))
|
||||
classpath.get.createPath()
|
||||
}
|
||||
|
||||
def setClasspathref(input: Reference): Unit =
|
||||
createClasspath().setRefid(input)
|
||||
|
||||
def setShowLog(input: Boolean): Unit =
|
||||
showLog = input
|
||||
|
||||
def setShowDiff(input: Boolean): Unit =
|
||||
showDiff = input
|
||||
|
||||
private var classpath: Option[Path] = None
|
||||
private var javacmd: Option[File] = None
|
||||
private var showDiff: Boolean = false
|
||||
private var showLog: Boolean = false
|
||||
private var runFailed: Boolean = false
|
||||
private var posFiles: Option[FileSet] = None
|
||||
private var negFiles: Option[FileSet] = None
|
||||
private var runFiles: Option[FileSet] = None
|
||||
|
||||
private def getPosFiles: Array[File] =
|
||||
if (!posFiles.isEmpty) {
|
||||
val files = posFiles.get
|
||||
(files.getDirectoryScanner(getProject).getIncludedFiles map { fs => new File(files.getDir(getProject), fs) })
|
||||
}
|
||||
else
|
||||
Array()
|
||||
|
||||
private def getNegFiles: Array[File] =
|
||||
if (!negFiles.isEmpty) {
|
||||
val files = negFiles.get
|
||||
(files.getDirectoryScanner(getProject).getIncludedFiles map { fs => new File(files.getDir(getProject), fs) })
|
||||
}
|
||||
else
|
||||
Array()
|
||||
|
||||
private def getRunFiles: Array[File] =
|
||||
if (!runFiles.isEmpty) {
|
||||
val files = runFiles.get
|
||||
(files.getDirectoryScanner(getProject).getIncludedFiles map { fs => new File(files.getDir(getProject), fs) })
|
||||
}
|
||||
else
|
||||
Array()
|
||||
|
||||
|
||||
override def execute(): Unit = {
|
||||
|
||||
if (classpath.isEmpty)
|
||||
error("Mandatory attribute 'classpath' is not set.")
|
||||
|
||||
val scalaLibrary =
|
||||
(classpath.get.list map { fs => new File(fs) }) find { f =>
|
||||
f.getName match {
|
||||
case "scala-library.jar" => true
|
||||
case "lib" if (f.getParentFile.getName == "library") => true
|
||||
case _ => false
|
||||
}
|
||||
}
|
||||
|
||||
if (scalaLibrary.isEmpty)
|
||||
error("Provided classpath does not contain a Scala library.")
|
||||
|
||||
val classloader = this.getClass.getClassLoader
|
||||
|
||||
val antRunner: AnyRef =
|
||||
classloader.loadClass("scala.tools.partest.nest.AntRunner").newInstance().asInstanceOf[AnyRef]
|
||||
val antFileManager: AnyRef =
|
||||
antRunner.getClass.getMethod("fileManager", Array()).invoke(antRunner, Array())
|
||||
|
||||
val runMethod =
|
||||
antRunner.getClass.getMethod("reflectiveRunTestsForFiles", Array(classOf[Array[File]], classOf[String]))
|
||||
|
||||
def runTestsForFiles(kindFiles: Array[File], kind: String): (Int, Int) = {
|
||||
val result = runMethod.invoke(antRunner, Array(kindFiles, kind)).asInstanceOf[Int]
|
||||
(result >> 16, result & 0x00FF)
|
||||
}
|
||||
|
||||
def setFileManagerBooleanProperty(name: String, value: Boolean) = {
|
||||
val setMethod =
|
||||
antFileManager.getClass.getMethod(name+"_$eq", Array(classOf[Boolean]))
|
||||
setMethod.invoke(antFileManager, Array(new java.lang.Boolean(value)))
|
||||
}
|
||||
|
||||
def setFileManagerStringProperty(name: String, value: String) = {
|
||||
val setMethod =
|
||||
antFileManager.getClass.getMethod(name+"_$eq", Array(classOf[String]))
|
||||
setMethod.invoke(antFileManager, Array(value))
|
||||
}
|
||||
|
||||
setFileManagerBooleanProperty("showDiff", showDiff)
|
||||
setFileManagerBooleanProperty("showLog", showLog)
|
||||
setFileManagerBooleanProperty("failed", runFailed)
|
||||
if (!javacmd.isEmpty)
|
||||
setFileManagerStringProperty("JAVACMD", javacmd.get.getAbsolutePath)
|
||||
setFileManagerStringProperty("CLASSPATH", classpath.get.list.mkString(File.pathSeparator))
|
||||
setFileManagerStringProperty("LATEST_LIB", scalaLibrary.get.getAbsolutePath)
|
||||
|
||||
var allSucesses: int = 0
|
||||
var allFailures: int = 0
|
||||
|
||||
if (getPosFiles.size > 0) {
|
||||
log("Compiling files that are expected to build")
|
||||
val (successes, failures) = runTestsForFiles(getPosFiles, "pos")
|
||||
allSucesses += successes
|
||||
allFailures += failures
|
||||
}
|
||||
|
||||
if (getNegFiles.size > 0) {
|
||||
log("Compiling files that are expected to fail")
|
||||
val (successes, failures) = runTestsForFiles(getNegFiles, "neg")
|
||||
allSucesses += successes
|
||||
allFailures += failures
|
||||
}
|
||||
|
||||
if (getRunFiles.size > 0) {
|
||||
log("Compiling and running files")
|
||||
val (successes, failures) = runTestsForFiles(getRunFiles, "run")
|
||||
allSucesses += successes
|
||||
allFailures += failures
|
||||
}
|
||||
|
||||
if ((getPosFiles.size + getNegFiles.size + getRunFiles.size) == 0)
|
||||
log("There where no tests to run.")
|
||||
else if (allFailures == 0)
|
||||
log("Test suite finished with no failures.")
|
||||
else
|
||||
log("Test suite finished with " + allFailures + " case" + (if (allFailures > 0) "s" else "") + " failing.")
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
<antlib>
|
||||
<taskdef name="partest"
|
||||
classname="scala.tools.partest.PartestTask"/>
|
||||
</antlib>
|
|
@ -0,0 +1,35 @@
|
|||
/* __ *\
|
||||
** ________ ___ / / ___ Scala Parallel Testing **
|
||||
** / __/ __// _ | / / / _ | (c) 2007-2008, LAMP/EPFL **
|
||||
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||
** /____/\___/_/ |_/____/_/ | | **
|
||||
** |/ **
|
||||
\* */
|
||||
|
||||
package scala.tools.partest.nest
|
||||
|
||||
import scala.actors.Actor._
|
||||
|
||||
import java.io.File
|
||||
import java.net.URLClassLoader
|
||||
|
||||
import org.apache.tools.ant.Task
|
||||
import org.apache.tools.ant.types.{Path, Reference, FileSet}
|
||||
|
||||
class AntRunner extends DirectRunner {
|
||||
|
||||
val fileManager = new FileManager {
|
||||
|
||||
var JAVACMD: String = "java"
|
||||
|
||||
var CLASSPATH: String = _
|
||||
var LATEST_LIB: String = _
|
||||
|
||||
}
|
||||
|
||||
def reflectiveRunTestsForFiles(kindFiles: Array[File], kind: String): Int = {
|
||||
val (succs, fails) = runTestsForFiles(kindFiles.toList, kind)
|
||||
succs << 16 | fails
|
||||
}
|
||||
|
||||
}
|
|
@ -24,7 +24,7 @@ abstract class SimpleCompiler {
|
|||
def compile(file: File, kind: String, log: File): Boolean
|
||||
}
|
||||
|
||||
class DirectCompiler extends SimpleCompiler {
|
||||
class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler {
|
||||
def newGlobal(settings: Settings, reporter: Reporter): Global =
|
||||
new Global(settings, reporter)
|
||||
|
||||
|
@ -54,12 +54,12 @@ class DirectCompiler extends SimpleCompiler {
|
|||
val testRep: ExtConsoleReporter = global.reporter.asInstanceOf[ExtConsoleReporter]
|
||||
|
||||
val test: TestFile = kind match {
|
||||
case "pos" => PosTestFile(file)
|
||||
case "neg" => NegTestFile(file)
|
||||
case "run" => RunTestFile(file)
|
||||
case "jvm" => JvmTestFile(file)
|
||||
case "jvm5" => Jvm5TestFile(file)
|
||||
case "shootout" => ShootoutTestFile(file)
|
||||
case "pos" => PosTestFile(file, fileManager)
|
||||
case "neg" => NegTestFile(file, fileManager)
|
||||
case "run" => RunTestFile(file, fileManager)
|
||||
case "jvm" => JvmTestFile(file, fileManager)
|
||||
case "jvm5" => Jvm5TestFile(file, fileManager)
|
||||
case "shootout" => ShootoutTestFile(file, fileManager)
|
||||
}
|
||||
test.defineSettings(testSettings)
|
||||
|
||||
|
@ -83,12 +83,12 @@ class DirectCompiler extends SimpleCompiler {
|
|||
val global = newGlobal(testSettings, testRep)
|
||||
|
||||
val test: TestFile = kind match {
|
||||
case "pos" => PosTestFile(file)
|
||||
case "neg" => NegTestFile(file)
|
||||
case "run" => RunTestFile(file)
|
||||
case "jvm" => JvmTestFile(file)
|
||||
case "jvm5" => Jvm5TestFile(file)
|
||||
case "shootout" => ShootoutTestFile(file)
|
||||
case "pos" => PosTestFile(file, fileManager)
|
||||
case "neg" => NegTestFile(file, fileManager)
|
||||
case "run" => RunTestFile(file, fileManager)
|
||||
case "jvm" => JvmTestFile(file, fileManager)
|
||||
case "jvm5" => Jvm5TestFile(file, fileManager)
|
||||
case "shootout" => ShootoutTestFile(file, fileManager)
|
||||
}
|
||||
test.defineSettings(testSettings)
|
||||
|
||||
|
@ -107,8 +107,8 @@ class DirectCompiler extends SimpleCompiler {
|
|||
}
|
||||
}
|
||||
|
||||
class ReflectiveCompiler extends SimpleCompiler {
|
||||
import FileManager.{latestCompFile, latestPartestFile, latestFjbgFile}
|
||||
class ReflectiveCompiler(val fileManager: ConsoleFileManager) extends SimpleCompiler {
|
||||
import fileManager.{latestCompFile, latestPartestFile, latestFjbgFile}
|
||||
|
||||
val sepUrls = Array(latestCompFile.toURL, latestPartestFile.toURL,
|
||||
latestFjbgFile.toURL)
|
||||
|
@ -151,13 +151,13 @@ class ReflectiveCompiler extends SimpleCompiler {
|
|||
}
|
||||
}
|
||||
|
||||
class CompileManager {
|
||||
var compiler: SimpleCompiler = new /*ReflectiveCompiler*/ DirectCompiler
|
||||
class CompileManager(val fileManager: FileManager) {
|
||||
var compiler: SimpleCompiler = new /*ReflectiveCompiler*/ DirectCompiler(fileManager)
|
||||
|
||||
var numSeparateCompilers = 1
|
||||
def createSeparateCompiler() = {
|
||||
numSeparateCompilers += 1
|
||||
compiler = new /*ReflectiveCompiler*/ DirectCompiler
|
||||
compiler = new /*ReflectiveCompiler*/ DirectCompiler(fileManager)
|
||||
}
|
||||
|
||||
/* This method returns true iff compilation succeeds.
|
||||
|
|
|
@ -0,0 +1,164 @@
|
|||
/* NEST (New Scala Test)
|
||||
* Copyright 2007-2008 LAMP/EPFL
|
||||
* @author Philipp Haller
|
||||
*/
|
||||
|
||||
// $Id: FileManager.scala 14161 2008-02-27 19:45:27Z phaller $
|
||||
|
||||
package scala.tools.partest.nest
|
||||
|
||||
import java.io.{File, FilenameFilter, IOException, StringWriter}
|
||||
import java.net.URI
|
||||
|
||||
class ConsoleFileManager extends FileManager {
|
||||
|
||||
var CLASSPATH = System.getProperty("java.class.path", ".")
|
||||
NestUI.verbose("CLASSPATH: "+CLASSPATH)
|
||||
val SCALAHOME = System.getProperty("scala.home", ".")
|
||||
NestUI.verbose("SCALAHOME: "+SCALAHOME)
|
||||
var JAVACMD = System.getProperty("scalatest.javacmd", "java")
|
||||
val PREFIX = (new File(SCALAHOME)).getAbsolutePath
|
||||
|
||||
/*
|
||||
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 test = new File(SCALAHOME, "test")
|
||||
val scala_test = new File(SCALAHOME, "misc/scala-test")
|
||||
val testroot =
|
||||
if (test.isDirectory)
|
||||
test
|
||||
else if (scala_test.isDirectory)
|
||||
scala_test
|
||||
else
|
||||
error("Test directory not found")
|
||||
testroot.getAbsolutePath
|
||||
}
|
||||
|
||||
CLASSPATH += File.pathSeparator + {
|
||||
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"
|
||||
}) map {file => file.getCanonicalFile.getAbsolutePath}).mkString(""+File.pathSeparator)
|
||||
}
|
||||
def findLatest() {
|
||||
def prefixFile(relPath: String): File =
|
||||
(new File(PREFIX, relPath)).getCanonicalFile
|
||||
|
||||
NestUI.verbose("PREFIX: "+PREFIX)
|
||||
val dists = new File(PREFIX, "dists")
|
||||
val build = new File(PREFIX, "build")
|
||||
val bin = new File(PREFIX, "bin")
|
||||
|
||||
if (dists.isDirectory) {
|
||||
latestFile = prefixFile("dists/latest/bin")
|
||||
latestLibFile = prefixFile("dists/latest/lib/scala-library.jar")
|
||||
latestActFile = 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.isDirectory) {
|
||||
latestFile = prefixFile("build/quick/bin")
|
||||
latestLibFile = prefixFile("build/quick/lib/library")
|
||||
latestActFile = prefixFile("build/quick/lib/actors")
|
||||
latestCompFile = prefixFile("build/quick/lib/compiler")
|
||||
latestPartestFile = prefixFile("build/quick/lib/partest")
|
||||
latestFjbgFile = prefixFile("lib/fjbg.jar") // starr
|
||||
}
|
||||
else if (bin.isDirectory) {
|
||||
latestFile = prefixFile("bin")
|
||||
latestLibFile = prefixFile("lib/scala-library.jar")
|
||||
latestActFile = prefixFile("lib/scala-library.jar")
|
||||
latestCompFile = prefixFile("lib/scala-compiler.jar")
|
||||
latestPartestFile = prefixFile("lib/scala-partest.jar")
|
||||
}
|
||||
else
|
||||
error("Scala binaries could not be found")
|
||||
|
||||
println("latestPartestFile="+latestPartestFile)
|
||||
|
||||
BIN_DIR = latestFile.getAbsolutePath
|
||||
LATEST_LIB = latestLibFile.getAbsolutePath
|
||||
LATEST_COMP = latestCompFile.getAbsolutePath
|
||||
LATEST_PARTEST = latestPartestFile.getAbsolutePath
|
||||
|
||||
// detect whether we are running on Windows
|
||||
val osName = System.getProperty("os.name")
|
||||
NestUI.verbose("OS: "+osName)
|
||||
|
||||
val scalaCommand = if (osName startsWith "Windows")
|
||||
"scala.bat" else "scala"
|
||||
val scalacCommand = if (osName startsWith "Windows")
|
||||
"scalac.bat" else "scalac"
|
||||
|
||||
SCALA = (new File(latestFile, scalaCommand)).getAbsolutePath
|
||||
SCALAC_CMD = (new File(latestFile, scalacCommand)).getAbsolutePath
|
||||
}
|
||||
|
||||
var BIN_DIR: String = ""
|
||||
var LATEST_LIB: String = ""
|
||||
var LATEST_COMP: String = ""
|
||||
var LATEST_PARTEST: String = ""
|
||||
var SCALA: String = ""
|
||||
var SCALAC_CMD: String = ""
|
||||
|
||||
val SCALAC_OPTS = System.getProperty("scalatest.scalac_opts", "-deprecation")
|
||||
|
||||
var latestFile: File = _
|
||||
var latestLibFile: File = _
|
||||
var latestActFile: File = _
|
||||
var latestCompFile: File = _
|
||||
var latestPartestFile: File = _
|
||||
var latestFjbgFile: File = _
|
||||
// initialize above fields
|
||||
findLatest()
|
||||
|
||||
val srcDir: File = {
|
||||
val src = new File(TESTROOT, "files")
|
||||
if (src.isDirectory)
|
||||
src
|
||||
else {
|
||||
val path = TESTROOT + 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)
|
||||
}
|
||||
|
||||
var testFiles: List[File] = List()
|
||||
|
||||
def getFiles(kind: String, doCheck: Boolean, ending: String): List[File] = {
|
||||
val filter = new FilenameFilter {
|
||||
def accept(dir: File, name: String): Boolean = name endsWith ending
|
||||
}
|
||||
val dir = new File(srcDir, kind)
|
||||
NestUI.verbose("look in "+dir+" for tests")
|
||||
if (dir.isDirectory) {
|
||||
if (!testFiles.isEmpty) {
|
||||
val dirpath = dir.getAbsolutePath
|
||||
testFiles filter { _.getParentFile.getAbsolutePath == dirpath }
|
||||
} else if (doCheck)
|
||||
dir.listFiles(filter).toList
|
||||
else // skip
|
||||
Nil
|
||||
} else {
|
||||
NestUI.failure("Directory \"" + dir.getPath + "\" not found")
|
||||
Nil
|
||||
}
|
||||
}
|
||||
|
||||
def getFiles(kind: String, doCheck: Boolean): List[File] =
|
||||
getFiles(kind, doCheck, ".scala")
|
||||
|
||||
}
|
|
@ -0,0 +1,199 @@
|
|||
/* 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,
|
||||
InputStreamReader, StringWriter, PrintWriter}
|
||||
import java.util.StringTokenizer
|
||||
|
||||
import scala.actors.Actor._
|
||||
|
||||
class ConsoleRunner extends DirectRunner {
|
||||
|
||||
val fileManager: ConsoleFileManager = new ConsoleFileManager
|
||||
|
||||
private val version = System.getProperty("java.version", "")
|
||||
private val isJava5 = version matches "1.[5|6|7].*"
|
||||
|
||||
private var posCheck = false
|
||||
private var negCheck = false
|
||||
private var runCheck = false
|
||||
private var jvmCheck = false
|
||||
private var jvm5Check = false
|
||||
private var resCheck = false
|
||||
private var runAll = false
|
||||
|
||||
private var testFiles: List[File] = List()
|
||||
private val con = new PrintStream(Console.out)
|
||||
private var out = con
|
||||
|
||||
private val errors =
|
||||
Integer.parseInt(System.getProperty("scalatest.errors", "0"))
|
||||
|
||||
def denotesTestSet(arg: String) =
|
||||
arg match {
|
||||
case "--pos" => true
|
||||
case "--neg" => true
|
||||
case "--run" => true
|
||||
case "--jvm" => true
|
||||
case "--jvm5" => true
|
||||
case "--res" => true
|
||||
case _ => false
|
||||
}
|
||||
|
||||
def main(argstr: String) {
|
||||
// tokenize args
|
||||
var args: List[String] = List()
|
||||
val st = new StringTokenizer(argstr)
|
||||
while (st.hasMoreTokens) {
|
||||
args = args ::: List(st.nextToken())
|
||||
}
|
||||
|
||||
if (args.length == 0)
|
||||
NestUI.usage()
|
||||
else {
|
||||
if (!args.exists(denotesTestSet(_))) runAll = true
|
||||
for (arg <- args) {
|
||||
arg match {
|
||||
case "--pos" => posCheck = true
|
||||
case "--neg" => negCheck = true
|
||||
case "--run" => runCheck = true
|
||||
case "--jvm" => jvmCheck = true
|
||||
case "--jvm5" => jvm5Check = true
|
||||
case "--res" => resCheck = true
|
||||
case "--verbose" => NestUI._verbose = true
|
||||
case "--show-diff" => fileManager.showDiff = true
|
||||
case "--show-log" => fileManager.showLog = true
|
||||
case "--failed" => fileManager.failed = true
|
||||
case "--version" => //todo: printVersion
|
||||
case "--ansi" => NestUI.initialize(NestUI.MANY)
|
||||
case _ =>
|
||||
if (arg endsWith ".scala") {
|
||||
val file = new File(arg)
|
||||
if (file.isFile) {
|
||||
NestUI.verbose("adding test file "+file)
|
||||
testFiles = file :: testFiles
|
||||
} else {
|
||||
NestUI.failure("File \"" + arg + "\" not found")
|
||||
System.exit(1)
|
||||
}
|
||||
} else if (out eq con) {
|
||||
val file = new File(arg)
|
||||
if (file.isFile || file.createNewFile)
|
||||
out = new PrintStream(new FileOutputStream(file))
|
||||
else {
|
||||
NestUI.failure("Result file \"" + arg + "\" not found")
|
||||
System.exit(1)
|
||||
}
|
||||
} else
|
||||
NestUI.usage()
|
||||
}
|
||||
}
|
||||
|
||||
NestUI.outline("Source directory is : "+fileManager.srcDir.getAbsolutePath+"\n")
|
||||
NestUI.outline("Scala binaries in : "+fileManager.BIN_DIR+"\n")
|
||||
|
||||
// obtain scalac version
|
||||
val cmd = fileManager.SCALAC_CMD+" -version"
|
||||
NestUI.verbose("running "+cmd)
|
||||
val proc = Runtime.getRuntime.exec(cmd)
|
||||
val in = proc.getInputStream
|
||||
val err = proc.getErrorStream
|
||||
val exitCode = proc.waitFor()
|
||||
NestUI.verbose("exit code: "+exitCode)
|
||||
val scalaVersion = StreamAppender.appendToString(in, err)
|
||||
|
||||
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
|
||||
val total = successes + failures
|
||||
|
||||
val elapsedSecs = (end - start)/1000
|
||||
val elapsedMins = elapsedSecs/60
|
||||
val elapsedHrs = elapsedMins/60
|
||||
val dispMins = elapsedMins - elapsedHrs * 60
|
||||
val dispSecs = elapsedSecs - elapsedMins * 60
|
||||
val dispElapsed = {
|
||||
def form(num: Long) = if (num < 10) "0"+num else ""+num
|
||||
form(elapsedHrs)+":"+form(dispMins)+":"+form(dispSecs)
|
||||
}
|
||||
|
||||
println
|
||||
if (failures == 0)
|
||||
NestUI.success("All of "+total+" tests were successful (elapsed time: "+dispElapsed+")\n")
|
||||
else
|
||||
NestUI.failure(failures+" of "+total+" tests failed (elapsed time: "+dispElapsed+")\n")
|
||||
|
||||
if (failures == errors)
|
||||
System.exit(0)
|
||||
else
|
||||
System.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
def runTests(kind: String, check: Boolean, msg: String): (Int, Int) = {
|
||||
if (check) {
|
||||
val kindFiles =
|
||||
if (!testFiles.isEmpty) {
|
||||
NestUI.verbose("testing "+testFiles)
|
||||
testFiles
|
||||
}
|
||||
else if (kind == "res") //TODO: is there a nicer way?
|
||||
fileManager.getFiles(kind, check, ".res")
|
||||
else
|
||||
fileManager.getFiles(kind, check)
|
||||
if (!kindFiles.isEmpty) {
|
||||
NestUI.outline("\n"+msg+"\n")
|
||||
|
||||
runTestsForFiles(kindFiles, kind)
|
||||
|
||||
//val worker = new Worker
|
||||
//worker.runTests(kind, kindFiles)
|
||||
} else {
|
||||
NestUI.failure("test dir empty")
|
||||
(0, 0)
|
||||
}
|
||||
} else (0, 0)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return (success count, failure count)
|
||||
*/
|
||||
def testCheckAll(): (Int, Int) = {
|
||||
if (runAll) { // run all tests
|
||||
posCheck = true
|
||||
negCheck = true
|
||||
runCheck = true
|
||||
jvmCheck = true
|
||||
jvm5Check = true
|
||||
//resCheck = true
|
||||
}
|
||||
val results = List(runTests("pos", posCheck, "Testing compiler (on files whose compilation should succeed)"),
|
||||
runTests("neg", negCheck, "Testing compiler (on files whose compilation should fail)"),
|
||||
runTests("run", runCheck, "Testing JVM backend"),
|
||||
runTests("jvm", jvmCheck, "Testing JVM backend"),
|
||||
runTests("jvm5", jvm5Check, "Testing JVM backend"),
|
||||
runTests("res", resCheck, "Testing resident compiler"))
|
||||
results reduceLeft { (p: (Int, Int), q: (Int, Int)) =>
|
||||
(p._1+q._1, p._2+q._2) }
|
||||
}
|
||||
}
|
|
@ -13,221 +13,48 @@ import java.util.StringTokenizer
|
|||
|
||||
import scala.actors.Actor._
|
||||
|
||||
class DirectRunner {
|
||||
private val version = System.getProperty("java.version", "")
|
||||
private val isJava5 = version matches "1.[5|6|7].*"
|
||||
|
||||
private val numActors = Integer.parseInt(System.getProperty("scalatest.actors", "8"))
|
||||
|
||||
private var posCheck = false
|
||||
private var negCheck = false
|
||||
private var runCheck = false
|
||||
private var jvmCheck = false
|
||||
private var jvm5Check = false
|
||||
private var resCheck = false
|
||||
private var runAll = false
|
||||
|
||||
private var testFiles: List[File] = List()
|
||||
private val con = new PrintStream(Console.out)
|
||||
private var out = con
|
||||
|
||||
private val errors =
|
||||
Integer.parseInt(System.getProperty("scalatest.errors", "0"))
|
||||
|
||||
def denotesTestSet(arg: String) =
|
||||
arg match {
|
||||
case "--pos" => true
|
||||
case "--neg" => true
|
||||
case "--run" => true
|
||||
case "--jvm" => true
|
||||
case "--jvm5" => true
|
||||
case "--res" => true
|
||||
case _ => false
|
||||
}
|
||||
|
||||
def main(argstr: String) {
|
||||
// tokenize args
|
||||
var args: List[String] = List()
|
||||
val st = new StringTokenizer(argstr)
|
||||
while (st.hasMoreTokens) {
|
||||
args = args ::: List(st.nextToken())
|
||||
}
|
||||
|
||||
if (args.length == 0)
|
||||
NestUI.usage()
|
||||
else {
|
||||
if (!args.exists(denotesTestSet(_))) runAll = true
|
||||
for (arg <- args) {
|
||||
arg match {
|
||||
case "--pos" => posCheck = true
|
||||
case "--neg" => negCheck = true
|
||||
case "--run" => runCheck = true
|
||||
case "--jvm" => jvmCheck = true
|
||||
case "--jvm5" => jvm5Check = true
|
||||
case "--res" => resCheck = true
|
||||
case "--verbose" => NestUI._verbose = true
|
||||
case "--show-diff" => FileManager.showDiff = true
|
||||
case "--show-log" => FileManager.showLog = true
|
||||
case "--failed" => FileManager.failed = true
|
||||
case "--version" => //todo: printVersion
|
||||
case "--ansi" => NestUI.initialize(NestUI.MANY)
|
||||
case _ =>
|
||||
if (arg endsWith ".scala") {
|
||||
val file = new File(arg)
|
||||
if (file.isFile) {
|
||||
NestUI.verbose("adding test file "+file)
|
||||
testFiles = file :: testFiles
|
||||
} else {
|
||||
NestUI.failure("File \"" + arg + "\" not found")
|
||||
System.exit(1)
|
||||
}
|
||||
} else if (out eq con) {
|
||||
val file = new File(arg)
|
||||
if (file.isFile || file.createNewFile)
|
||||
out = new PrintStream(new FileOutputStream(file))
|
||||
else {
|
||||
NestUI.failure("Result file \"" + arg + "\" not found")
|
||||
System.exit(1)
|
||||
}
|
||||
} else
|
||||
NestUI.usage()
|
||||
}
|
||||
}
|
||||
|
||||
NestUI.outline("Source directory is : "+FileManager.srcDir.getAbsolutePath+"\n")
|
||||
NestUI.outline("Scala binaries in : "+FileManager.BIN_DIR+"\n")
|
||||
|
||||
// obtain scalac version
|
||||
val cmd = FileManager.SCALAC_CMD+" -version"
|
||||
NestUI.verbose("running "+cmd)
|
||||
val proc = Runtime.getRuntime.exec(cmd)
|
||||
val in = proc.getInputStream
|
||||
val err = proc.getErrorStream
|
||||
val exitCode = proc.waitFor()
|
||||
NestUI.verbose("exit code: "+exitCode)
|
||||
val scalaVersion = StreamAppender.appendToString(in, err)
|
||||
|
||||
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
|
||||
val total = successes + failures
|
||||
|
||||
val elapsedSecs = (end - start)/1000
|
||||
val elapsedMins = elapsedSecs/60
|
||||
val elapsedHrs = elapsedMins/60
|
||||
val dispMins = elapsedMins - elapsedHrs * 60
|
||||
val dispSecs = elapsedSecs - elapsedMins * 60
|
||||
val dispElapsed = {
|
||||
def form(num: Long) = if (num < 10) "0"+num else ""+num
|
||||
form(elapsedHrs)+":"+form(dispMins)+":"+form(dispSecs)
|
||||
}
|
||||
|
||||
println
|
||||
if (failures == 0)
|
||||
NestUI.success("All of "+total+" tests were successful (elapsed time: "+dispElapsed+")\n")
|
||||
trait DirectRunner {
|
||||
|
||||
def fileManager: FileManager
|
||||
|
||||
protected val numActors = Integer.parseInt(System.getProperty("scalatest.actors", "8"))
|
||||
|
||||
def runTestsForFiles(kindFiles: List[File], kind: String): (Int, Int) = {
|
||||
val len = kindFiles.length
|
||||
val (testsEach, lastFrag) = (len/numActors, len%numActors)
|
||||
val last = numActors-1
|
||||
val workers = for (i <- List.range(0, numActors)) yield {
|
||||
val toTest = kindFiles.slice(i*testsEach, (i+1)*testsEach)
|
||||
val worker = new Worker(fileManager)
|
||||
worker.start()
|
||||
if (i == last)
|
||||
worker ! RunTests(kind, (kindFiles splitAt (last*testsEach))._2)
|
||||
else
|
||||
NestUI.failure(failures+" of "+total+" tests failed (elapsed time: "+dispElapsed+")\n")
|
||||
|
||||
if (failures == errors)
|
||||
System.exit(0)
|
||||
else
|
||||
System.exit(1)
|
||||
worker ! RunTests(kind, toTest)
|
||||
worker
|
||||
}
|
||||
}
|
||||
|
||||
def runTests(kind: String, check: Boolean, msg: String): (Int, Int) = {
|
||||
if (check) {
|
||||
val fileMgr = new FileManager
|
||||
val kindFiles =
|
||||
if (!testFiles.isEmpty) {
|
||||
NestUI.verbose("testing "+testFiles)
|
||||
testFiles
|
||||
}
|
||||
else if (kind == "res") //TODO: is there a nicer way?
|
||||
fileMgr.getFiles(kind, check, ".res")
|
||||
else
|
||||
fileMgr.getFiles(kind, check)
|
||||
if (!kindFiles.isEmpty) {
|
||||
NestUI.outline("\n"+msg+"\n")
|
||||
|
||||
val len = kindFiles.length
|
||||
val (testsEach, lastFrag) = (len/numActors, len%numActors)
|
||||
val last = numActors-1
|
||||
val workers = for (i <- List.range(0, numActors)) yield {
|
||||
val toTest = kindFiles.slice(i*testsEach, (i+1)*testsEach)
|
||||
val worker = new Worker
|
||||
worker.start()
|
||||
if (i == last)
|
||||
worker ! RunTests(kind, (kindFiles splitAt (last*testsEach))._2)
|
||||
else
|
||||
worker ! RunTests(kind, toTest)
|
||||
worker
|
||||
}
|
||||
var succs = 0; var fails = 0
|
||||
var logsToDelete: List[File] = List()
|
||||
var outdirsToDelete: List[File] = List()
|
||||
workers foreach { w =>
|
||||
receive {
|
||||
case Results(s, f, logs, outdirs) =>
|
||||
logsToDelete = logsToDelete ::: logs.filter(_.toDelete)
|
||||
outdirsToDelete = outdirsToDelete ::: outdirs
|
||||
succs += s
|
||||
fails += f
|
||||
}
|
||||
}
|
||||
logsToDelete.foreach { log =>
|
||||
NestUI.verbose("deleting "+log+"\n")
|
||||
FileManager.deleteRecursive(log)
|
||||
}
|
||||
outdirsToDelete.foreach { outdir =>
|
||||
NestUI.verbose("deleting "+outdir+"\n")
|
||||
FileManager.deleteRecursive(outdir)
|
||||
}
|
||||
|
||||
(succs, fails)
|
||||
|
||||
//val worker = new Worker
|
||||
//worker.runTests(kind, kindFiles)
|
||||
} else {
|
||||
NestUI.failure("test dir empty")
|
||||
(0, 0)
|
||||
var succs = 0; var fails = 0
|
||||
var logsToDelete: List[File] = List()
|
||||
var outdirsToDelete: List[File] = List()
|
||||
workers foreach { w =>
|
||||
receive {
|
||||
case Results(s, f, logs, outdirs) =>
|
||||
logsToDelete = logsToDelete ::: logs.filter(_.toDelete)
|
||||
outdirsToDelete = outdirsToDelete ::: outdirs
|
||||
succs += s
|
||||
fails += f
|
||||
}
|
||||
} else (0, 0)
|
||||
}
|
||||
logsToDelete.foreach { log =>
|
||||
NestUI.verbose("deleting "+log+"\n")
|
||||
fileManager.deleteRecursive(log)
|
||||
}
|
||||
outdirsToDelete.foreach { outdir =>
|
||||
NestUI.verbose("deleting "+outdir+"\n")
|
||||
fileManager.deleteRecursive(outdir)
|
||||
}
|
||||
|
||||
(succs, fails)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return (success count, failure count)
|
||||
*/
|
||||
def testCheckAll(): (Int, Int) = {
|
||||
if (runAll) { // run all tests
|
||||
posCheck = true
|
||||
negCheck = true
|
||||
runCheck = true
|
||||
jvmCheck = true
|
||||
jvm5Check = true
|
||||
//resCheck = true
|
||||
}
|
||||
val results = List(runTests("pos", posCheck, "Testing compiler (on files whose compilation should succeed)"),
|
||||
runTests("neg", negCheck, "Testing compiler (on files whose compilation should fail)"),
|
||||
runTests("run", runCheck, "Testing JVM backend"),
|
||||
runTests("jvm", jvmCheck, "Testing JVM backend"),
|
||||
runTests("jvm5", jvm5Check, "Testing JVM backend"),
|
||||
runTests("res", resCheck, "Testing resident compiler"))
|
||||
results reduceLeft { (p: (Int, Int), q: (Int, Int)) =>
|
||||
(p._1+q._1, p._2+q._2) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,159 +10,7 @@ package scala.tools.partest.nest
|
|||
import java.io.{File, FilenameFilter, IOException, StringWriter}
|
||||
import java.net.URI
|
||||
|
||||
object FileManager {
|
||||
|
||||
val PATH_SEP = File.pathSeparatorChar
|
||||
val CLASSPATH = System.getProperty("java.class.path", ".")
|
||||
NestUI.verbose("CLASSPATH: "+CLASSPATH)
|
||||
val SCALAHOME = System.getProperty("scala.home", ".")
|
||||
NestUI.verbose("SCALAHOME: "+SCALAHOME)
|
||||
val JAVACMD = System.getProperty("scalatest.javacmd", "java")
|
||||
val PREFIX = (new File(SCALAHOME)).getAbsolutePath
|
||||
|
||||
/*
|
||||
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 test = new File(SCALAHOME, "test")
|
||||
val scala_test = new File(SCALAHOME, "misc/scala-test")
|
||||
val testroot =
|
||||
if (test.isDirectory)
|
||||
test
|
||||
else if (scala_test.isDirectory)
|
||||
scala_test
|
||||
else
|
||||
error("Test directory not found")
|
||||
testroot.getAbsolutePath
|
||||
}
|
||||
|
||||
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"
|
||||
}) 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): File =
|
||||
(new File(PREFIX, relPath)).getCanonicalFile
|
||||
|
||||
NestUI.verbose("PREFIX: "+PREFIX)
|
||||
val dists = new File(PREFIX, "dists")
|
||||
val build = new File(PREFIX, "build")
|
||||
val bin = new File(PREFIX, "bin")
|
||||
|
||||
if (dists.isDirectory) {
|
||||
latestFile = prefixFile("dists/latest/bin")
|
||||
latestLibFile = prefixFile("dists/latest/lib/scala-library.jar")
|
||||
latestActFile = 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.isDirectory) {
|
||||
latestFile = prefixFile("build/quick/bin")
|
||||
latestLibFile = prefixFile("build/quick/lib/library")
|
||||
latestActFile = prefixFile("build/quick/lib/actors")
|
||||
latestCompFile = prefixFile("build/quick/lib/compiler")
|
||||
latestPartestFile = prefixFile("build/quick/lib/partest")
|
||||
latestFjbgFile = prefixFile("lib/fjbg.jar") // starr
|
||||
}
|
||||
else if (bin.isDirectory) {
|
||||
latestFile = prefixFile("bin")
|
||||
latestLibFile = prefixFile("lib/scala-library.jar")
|
||||
latestActFile = prefixFile("lib/scala-library.jar")
|
||||
latestCompFile = prefixFile("lib/scala-compiler.jar")
|
||||
latestPartestFile = prefixFile("lib/scala-partest.jar")
|
||||
}
|
||||
else
|
||||
error("Scala binaries could not be found")
|
||||
|
||||
BIN_DIR = latestFile.getAbsolutePath
|
||||
LATEST_LIB = latestLibFile.getAbsolutePath
|
||||
LATEST_COMP = latestCompFile.getAbsolutePath
|
||||
LATEST_PARTEST = latestPartestFile.getAbsolutePath
|
||||
|
||||
// detect whether we are running on Windows
|
||||
val osName = System.getProperty("os.name")
|
||||
NestUI.verbose("OS: "+osName)
|
||||
|
||||
val scalaCommand = if (osName startsWith "Windows")
|
||||
"scala.bat" else "scala"
|
||||
val scalacCommand = if (osName startsWith "Windows")
|
||||
"scalac.bat" else "scalac"
|
||||
|
||||
SCALA = (new File(latestFile, scalaCommand)).getAbsolutePath
|
||||
SCALAC_CMD = (new File(latestFile, scalacCommand)).getAbsolutePath
|
||||
}
|
||||
|
||||
var BIN_DIR: String = ""
|
||||
var LATEST_LIB: String = ""
|
||||
var LATEST_COMP: String = ""
|
||||
var LATEST_PARTEST: String = ""
|
||||
var SCALA: String = ""
|
||||
var SCALAC_CMD: String = ""
|
||||
|
||||
val SCALAC_OPTS = System.getProperty("scalatest.scalac_opts", "-deprecation")
|
||||
|
||||
var latestFile: File = _
|
||||
var latestLibFile: File = _
|
||||
var latestActFile: File = _
|
||||
var latestCompFile: File = _
|
||||
var latestPartestFile: File = _
|
||||
var latestFjbgFile: File = _
|
||||
// initialize above fields
|
||||
findLatest()
|
||||
|
||||
val srcDir: File = {
|
||||
val src = new File(TESTROOT, "files")
|
||||
if (src.isDirectory)
|
||||
src
|
||||
else {
|
||||
val path = TESTROOT + File.separator + "files"
|
||||
NestUI.failure("Source directory \"" + path + "\" not found")
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
var showDiff = false
|
||||
var showLog = false
|
||||
var failed = false
|
||||
|
||||
private def basename(name: String): String = {
|
||||
val inx = name.lastIndexOf(".")
|
||||
if (inx < 0) name else name.substring(0, inx)
|
||||
}
|
||||
trait FileManager {
|
||||
|
||||
def deleteRecursive(dir: File) {
|
||||
if (dir.isDirectory) {
|
||||
|
@ -170,7 +18,7 @@ elif [ -d "$PREFIX/bin" ]; then
|
|||
}
|
||||
dir.delete
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compares two files using a Java implementation of the GNU diff
|
||||
* available at http://www.bmsi.com/java/#diff.
|
||||
|
@ -194,32 +42,15 @@ elif [ -d "$PREFIX/bin" ]; then
|
|||
}
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
class FileManager {
|
||||
|
||||
var testFiles: List[File] = List()
|
||||
|
||||
def getFiles(kind: String, doCheck: Boolean, ending: String): List[File] = {
|
||||
val filter = new FilenameFilter {
|
||||
def accept(dir: File, name: String): Boolean = name endsWith ending
|
||||
}
|
||||
val dir = new File(FileManager.srcDir, kind)
|
||||
NestUI.verbose("look in "+dir+" for tests")
|
||||
if (dir.isDirectory) {
|
||||
if (!testFiles.isEmpty) {
|
||||
val dirpath = dir.getAbsolutePath
|
||||
testFiles filter { _.getParentFile.getAbsolutePath == dirpath }
|
||||
} else if (doCheck)
|
||||
dir.listFiles(filter).toList
|
||||
else // skip
|
||||
Nil
|
||||
} else {
|
||||
NestUI.failure("Directory \"" + dir.getPath + "\" not found")
|
||||
Nil
|
||||
}
|
||||
}
|
||||
|
||||
def getFiles(kind: String, doCheck: Boolean): List[File] =
|
||||
getFiles(kind, doCheck, ".scala")
|
||||
|
||||
|
||||
var JAVACMD: String
|
||||
|
||||
var CLASSPATH: String
|
||||
var LATEST_LIB: String
|
||||
|
||||
var showDiff = false
|
||||
var showLog = false
|
||||
var failed = false
|
||||
|
||||
}
|
||||
|
|
|
@ -18,8 +18,10 @@ class ReflectiveRunner {
|
|||
// we might also use FileManager.CLASSPATH
|
||||
// to use the same classes as used by `scala` that
|
||||
// was used to start the runner.
|
||||
|
||||
val fileManager = new ConsoleFileManager
|
||||
|
||||
import FileManager.{latestCompFile, latestLibFile, latestActFile,
|
||||
import fileManager.{latestCompFile, latestLibFile, latestActFile,
|
||||
latestPartestFile, latestFjbgFile}
|
||||
|
||||
val sepUrls = Array(latestCompFile.toURL, latestLibFile.toURL,
|
||||
|
@ -28,7 +30,7 @@ class ReflectiveRunner {
|
|||
val sepLoader = new java.net.URLClassLoader(sepUrls, null)
|
||||
|
||||
val sepRunnerClass =
|
||||
sepLoader.loadClass("scala.tools.partest.nest.DirectRunner")
|
||||
sepLoader.loadClass("scala.tools.partest.nest.ConsoleRunner")
|
||||
val sepRunner = sepRunnerClass.newInstance()
|
||||
|
||||
val stringClass = Class.forName("java.lang.String")
|
||||
|
|
|
@ -10,7 +10,7 @@ package scala.tools.partest.nest
|
|||
import java.io.File
|
||||
import scala.tools.nsc.Settings
|
||||
|
||||
class TestFile(kind: String, val file: File) {
|
||||
class TestFile(kind: String, val file: File, val fileManager: FileManager) {
|
||||
val dir = file.getParentFile
|
||||
val dirpath = dir.getAbsolutePath
|
||||
|
||||
|
@ -48,41 +48,60 @@ class TestFile(kind: String, val file: File) {
|
|||
override def toString(): String = kind+" "+file
|
||||
}
|
||||
|
||||
case class PosTestFile(override val file: File) extends TestFile("pos", file)
|
||||
|
||||
case class NegTestFile(override val file: File) extends TestFile("neg", file)
|
||||
|
||||
case class RunTestFile(override val file: File) extends TestFile("run", file) {
|
||||
override def defineSettings(settings: Settings) {
|
||||
baseSettings(settings)
|
||||
}
|
||||
}
|
||||
|
||||
case class JvmTestFile(override val file: File) extends TestFile("jvm", file) {
|
||||
import FileManager.{CLASSPATH, EXT_CLASSPATH, PATH_SEP}
|
||||
case class PosTestFile(override val file: File, override val fileManager: FileManager) extends TestFile("pos", file, fileManager) {
|
||||
import fileManager.CLASSPATH
|
||||
|
||||
override def defineSettings(settings: Settings) {
|
||||
baseSettings(settings)
|
||||
settings.classpath.value = CLASSPATH+PATH_SEP+EXT_CLASSPATH
|
||||
settings.classpath.value = CLASSPATH
|
||||
//println("settings.classpath.value="+settings.classpath.value)
|
||||
}
|
||||
}
|
||||
|
||||
case class Jvm5TestFile(override val file: File) extends TestFile("jvm5", file) {
|
||||
import FileManager.{CLASSPATH, EXT_CLASSPATH, PATH_SEP}
|
||||
case class NegTestFile(override val file: File, override val fileManager: FileManager) extends TestFile("neg", file, fileManager) {
|
||||
import fileManager.CLASSPATH
|
||||
|
||||
override def defineSettings(settings: Settings) {
|
||||
baseSettings(settings)
|
||||
settings.classpath.value = CLASSPATH+PATH_SEP+EXT_CLASSPATH
|
||||
settings.classpath.value = CLASSPATH
|
||||
//println("settings.classpath.value="+settings.classpath.value)
|
||||
}
|
||||
}
|
||||
|
||||
case class RunTestFile(override val file: File, override val fileManager: FileManager) extends TestFile("run", file, fileManager) {
|
||||
import fileManager.CLASSPATH
|
||||
override def defineSettings(settings: Settings) {
|
||||
baseSettings(settings)
|
||||
settings.classpath.value = CLASSPATH
|
||||
}
|
||||
}
|
||||
|
||||
case class JvmTestFile(override val file: File, override val fileManager: FileManager) extends TestFile("jvm", file, fileManager) {
|
||||
import fileManager.CLASSPATH
|
||||
|
||||
override def defineSettings(settings: Settings) {
|
||||
baseSettings(settings)
|
||||
settings.classpath.value = CLASSPATH
|
||||
//println("settings.classpath.value="+settings.classpath.value)
|
||||
}
|
||||
}
|
||||
|
||||
case class Jvm5TestFile(override val file: File, override val fileManager: FileManager) extends TestFile("jvm5", file, fileManager) {
|
||||
import fileManager.CLASSPATH
|
||||
|
||||
override def defineSettings(settings: Settings) {
|
||||
baseSettings(settings)
|
||||
settings.classpath.value = CLASSPATH
|
||||
settings.target.value = "jvm-1.5"
|
||||
//println("settings.classpath.value="+settings.classpath.value)
|
||||
}
|
||||
}
|
||||
|
||||
case class ShootoutTestFile(override val file: File) extends TestFile("shootout", file) {
|
||||
case class ShootoutTestFile(override val file: File, override val fileManager: FileManager) extends TestFile("shootout", file, fileManager) {
|
||||
import fileManager.CLASSPATH
|
||||
override def defineSettings(settings: Settings) {
|
||||
baseSettings(settings)
|
||||
settings.classpath.value = System.getProperty("EXT_CLASSPATH")
|
||||
settings.classpath.value = CLASSPATH
|
||||
//println("CLASSPATH="+settings.classpath.value)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@ import scala.tools.nsc.ObjectRunner
|
|||
import scala.actors.Actor
|
||||
import scala.actors.Actor._
|
||||
|
||||
import FileManager._
|
||||
|
||||
case class RunTests(kind: String, files: List[File])
|
||||
case class Results(succ: Int, fail: Int, logs: List[LogFile], outdirs: List[File])
|
||||
|
||||
|
@ -24,7 +22,8 @@ class LogFile(parent: File, child: String) extends File(parent, child) {
|
|||
var toDelete = false
|
||||
}
|
||||
|
||||
class Worker extends Actor {
|
||||
class Worker(val fileManager: FileManager) extends Actor {
|
||||
import fileManager._
|
||||
def act() {
|
||||
react {
|
||||
case RunTests(kind, files) =>
|
||||
|
@ -93,9 +92,7 @@ class Worker extends Actor {
|
|||
val classpath: List[URL] =
|
||||
outDir.toURL ::
|
||||
List(file.getParentFile.toURL) :::
|
||||
(List.fromString(CLASSPATH, PATH_SEP) map { x =>
|
||||
(new File(x)).toURL }) :::
|
||||
(List.fromString(EXT_CLASSPATH, PATH_SEP) map { x =>
|
||||
(List.fromString(CLASSPATH, File.pathSeparatorChar) map { x =>
|
||||
(new File(x)).toURL })
|
||||
try {
|
||||
NestUI.verbose("classpath: "+classpath)
|
||||
|
@ -114,7 +111,7 @@ class Worker extends Actor {
|
|||
def execTest(outDir: File, logFile: File) {
|
||||
val cmd =
|
||||
JAVACMD+
|
||||
" -classpath "+outDir+PATH_SEP+CLASSPATH+PATH_SEP+EXT_CLASSPATH+
|
||||
" -classpath "+outDir+File.pathSeparatorChar+CLASSPATH+
|
||||
" -Djava.library.path="+logFile.getParentFile.getAbsolutePath+
|
||||
" -Dscalatest.output="+outDir.getAbsolutePath+
|
||||
" -Dscalatest.lib="+LATEST_LIB+
|
||||
|
@ -159,7 +156,7 @@ class Worker extends Actor {
|
|||
err.close
|
||||
out.close*/
|
||||
|
||||
if (FileManager.showLog) {
|
||||
if (fileManager.showLog) {
|
||||
// produce log as string in `log`
|
||||
val reader = new BufferedReader(new FileReader(logFile))
|
||||
val swriter = new StringWriter
|
||||
|
@ -180,12 +177,12 @@ class Worker extends Actor {
|
|||
new File(dir, fileBase + "-" + kind + ".check")
|
||||
}
|
||||
if (!checkFile.exists || !checkFile.canRead) ""
|
||||
else FileManager.compareFiles(logFile, checkFile)
|
||||
else fileManager.compareFiles(logFile, checkFile)
|
||||
}
|
||||
|
||||
def runJvmTests(kind: String, files: List[File]): (Int, Int) = {
|
||||
NestUI.verbose("testing "+files)
|
||||
val compileMgr = new CompileManager
|
||||
val compileMgr = new CompileManager(fileManager)
|
||||
var errors = 0
|
||||
var success = true
|
||||
var diff = ""
|
||||
|
@ -199,7 +196,7 @@ class Worker extends Actor {
|
|||
// when option "--failed" is provided
|
||||
// execute test only if log file is present
|
||||
// (which means it failed before)
|
||||
if (!FileManager.failed || (logFile.exists && logFile.canRead)) {
|
||||
if (!fileManager.failed || (logFile.exists && logFile.canRead)) {
|
||||
val swr = new StringWriter
|
||||
val wr = new PrintWriter(swr)
|
||||
success = true
|
||||
|
@ -213,7 +210,7 @@ class Worker extends Actor {
|
|||
success = false
|
||||
} else {
|
||||
// -------- run test --------
|
||||
|
||||
|
||||
//TODO: detect whether we have to use Runtime.exec
|
||||
val useRuntime = true
|
||||
|
||||
|
@ -247,8 +244,8 @@ class Worker extends Actor {
|
|||
wr.flush()
|
||||
swr.flush()
|
||||
NestUI.normal(swr.toString)
|
||||
if (!success && FileManager.showDiff) NestUI.normal(diff)
|
||||
if (!success && FileManager.showLog) NestUI.normal(log)
|
||||
if (!success && fileManager.showDiff) NestUI.normal(diff)
|
||||
if (!success && fileManager.showLog) NestUI.normal(log)
|
||||
}
|
||||
} // for each file
|
||||
NestUI.verbose("finished testing "+kind+" with "+errors+" errors")
|
||||
|
@ -271,7 +268,7 @@ class Worker extends Actor {
|
|||
* @param files The list of test files
|
||||
*/
|
||||
def runTests(kind: String, files: List[File]): (Int, Int) = {
|
||||
val compileMgr = new CompileManager
|
||||
val compileMgr = new CompileManager(fileManager)
|
||||
var errors = 0
|
||||
var succeeded = true
|
||||
var diff = ""
|
||||
|
@ -327,7 +324,7 @@ class Worker extends Actor {
|
|||
// execute test only if log file is present
|
||||
// (which means it failed before)
|
||||
val logFile = createLogFile(file, kind)
|
||||
if (!FileManager.failed || (logFile.exists && logFile.canRead)) {
|
||||
if (!fileManager.failed || (logFile.exists && logFile.canRead)) {
|
||||
val swr = new StringWriter
|
||||
val wr = new PrintWriter(swr)
|
||||
succeeded = true; diff = ""; log = ""
|
||||
|
@ -366,8 +363,8 @@ class Worker extends Actor {
|
|||
swr.flush()
|
||||
NestUI.normal(swr.toString)
|
||||
|
||||
if (!succeeded && FileManager.showDiff) NestUI.normal(diff)
|
||||
if (!succeeded && FileManager.showLog) {
|
||||
if (!succeeded && fileManager.showDiff) NestUI.normal(diff)
|
||||
if (!succeeded && fileManager.showLog) {
|
||||
// output log file
|
||||
val logReader = new BufferedReader(new FileReader(logFile))
|
||||
val logWriter = new PrintWriter(new StringWriter, true)
|
||||
|
@ -410,7 +407,7 @@ class Worker extends Actor {
|
|||
// $SCALAC -d "$os_dstbase".obj -Xresident -sourcepath . "$@"
|
||||
val cmd =
|
||||
JAVACMD+
|
||||
" -classpath "+outDir+PATH_SEP+CLASSPATH+PATH_SEP+EXT_CLASSPATH+
|
||||
" -classpath "+outDir+File.pathSeparator+CLASSPATH+
|
||||
" -Djavacmd="+JAVACMD+
|
||||
" scala.tools.nsc.Main"+
|
||||
" -d "+outDir.getCanonicalFile.getAbsolutePath+
|
||||
|
@ -457,8 +454,8 @@ class Worker extends Actor {
|
|||
errors += 1
|
||||
}
|
||||
|
||||
if (!succeeded && FileManager.showDiff) NestUI.normal(diff)
|
||||
if (!succeeded && FileManager.showLog) {
|
||||
if (!succeeded && fileManager.showDiff) NestUI.normal(diff)
|
||||
if (!succeeded && fileManager.showLog) {
|
||||
// output log file
|
||||
val logReader = new BufferedReader(new FileReader(logFile))
|
||||
val logWriter = new PrintWriter(new StringWriter, true)
|
||||
|
|
Loading…
Reference in New Issue