From 96f925078fdcf764e84f4691e6589004f09ca709 Mon Sep 17 00:00:00 2001 From: michelou Date: Tue, 13 Nov 2007 17:49:56 +0000 Subject: fixed partest, removed mergeLines (useless) --- build.xml | 21 +++++ .../scala/tools/nsc/ast/TreePrinters.scala | 6 +- src/compiler/scala/tools/nsc/util/Position.scala | 2 +- src/library/scala/runtime/RichString.scala | 33 +++---- src/partest/scala/tools/partest/MasterActor.scala | 2 +- src/partest/scala/tools/partest/TestRunner.scala | 17 ++-- src/partest/scala/tools/partest/WorkerActor.scala | 30 +++++-- .../scala/tools/partest/utils/PrintMgr.scala | 2 +- .../scala/tools/partest/utils/Properties.scala | 57 ++++++++++++ test/files/run/json.check | 2 + test/files/run/json.scala | 100 ++++++++++++++++++++- test/partest | 4 +- 12 files changed, 232 insertions(+), 44 deletions(-) create mode 100644 src/partest/scala/tools/partest/utils/Properties.scala diff --git a/build.xml b/build.xml index 63afa92c6d..a4937e48a8 100644 --- a/build.xml +++ b/build.xml @@ -73,6 +73,7 @@ PROPERTIES + @@ -984,6 +995,16 @@ TEST + + diff --git a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala index 2fa44c2dc8..7f1816c7a2 100644 --- a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala +++ b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala @@ -229,7 +229,7 @@ abstract class TreePrinters { selectorType = selectorType1 case CaseDef(pat, guard, body) => - print("case "); + print("case ") def patConstr(pat: Tree): Tree = pat match { case Apply(fn, args) => patConstr(fn) case _ => pat @@ -362,7 +362,9 @@ abstract class TreePrinters { print(tpt); printColumn(whereClauses, " forSome { ", ";", "}") - case tree : StubTree => print(tree.toString) + case tree: StubTree => + print(tree.toString) + case tree => print("") } diff --git a/src/compiler/scala/tools/nsc/util/Position.scala b/src/compiler/scala/tools/nsc/util/Position.scala index a895780d1c..91c437ee8a 100644 --- a/src/compiler/scala/tools/nsc/util/Position.scala +++ b/src/compiler/scala/tools/nsc/util/Position.scala @@ -68,7 +68,7 @@ trait Position { } -object NoPosition extends Position +case object NoPosition extends Position case class FakePos(msg: String) extends Position case class LinePosition(source0: SourceFile, line0: Int) extends Position { diff --git a/src/library/scala/runtime/RichString.scala b/src/library/scala/runtime/RichString.scala index 187f77e5d3..40fccab5ba 100644 --- a/src/library/scala/runtime/RichString.scala +++ b/src/library/scala/runtime/RichString.scala @@ -22,10 +22,16 @@ final class RichString(val self: String) extends Proxy with RandomAccessSeq[Char override def mkString = self override def slice(from: Int, until: Int): RichString = { - val from0 = if (from < 0) 0 else from - val until0 = if (from >= until || from >= self.length) return new RichString("") - else if (until > self.length) self.length else until - new RichString(self.substring(from0, until0)) + val len = self.length + new RichString( + if (from >= until || from >= len) + "" + else { + val from0 = if (from < 0) 0 else from + val until0 = if (until > len) len else until + self.substring(from0, until0) + } + ) } //override def ++ [B >: A](that: Iterable[B]): Seq[B] = { @@ -159,25 +165,6 @@ final class RichString(val self: String) extends Proxy with RandomAccessSeq[Char */ def stripMargin: String = stripMargin('|') - /**

- * Remove white space from both ends of each line and add - * a blank (" ") between lines before merging them. - *

- *

- * Equivalent to: mergeLines(_.trim, " "). - *

- */ - def mergeLines: String = mergeLines(_.trim, " ") - - /**

- * Apply function f to each line and add - * the string eol between lines before - * merging them. - *

- */ - def mergeLines(f: String => String, eol: String): String = - lines map f mkString eol - private def escape(ch: Char): String = ch match { case '.' | '$' | '^' | '\\' => "\\" + ch case _ => "" + ch diff --git a/src/partest/scala/tools/partest/MasterActor.scala b/src/partest/scala/tools/partest/MasterActor.scala index 90c081418f..8ead5e5ea8 100644 --- a/src/partest/scala/tools/partest/MasterActor.scala +++ b/src/partest/scala/tools/partest/MasterActor.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ -// $Id: $ +// $Id$ package scala.tools.partest diff --git a/src/partest/scala/tools/partest/TestRunner.scala b/src/partest/scala/tools/partest/TestRunner.scala index 623b0ae28a..36c1d13722 100644 --- a/src/partest/scala/tools/partest/TestRunner.scala +++ b/src/partest/scala/tools/partest/TestRunner.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ -// $Id: $ +// $Id$ package scala.tools.partest @@ -134,18 +134,24 @@ object TestRunner { private def printUsage { println("Usage: TestRunner [] []") - println(" --pos ...") - println(" --neg ...") - println(" --jvm ...") - println(" --run ...") + println(" --pos next files test a compilation success") + println(" --neg next files test a compilation failure") + println(" --jvm next files test the JVM backend") + println(" --run next files test the interpreter and all backends") println(" --shootout ...") println(" --conservative ...") println(" --verbose display progress information") + println(" --version output version information and exit") println println("Send bugs to ") exit(1) } + private def printVersion { + println(util.Properties.versionMsg) + exit(0) + } + final def printVerbose(msg: String) { if (verbose) { printOutline("debug : ") @@ -166,6 +172,7 @@ object TestRunner { case "--shootout" => shootoutCheck = true case "--conservative" => conservative = true case "--verbose" => verbose = true + case "--version" => printVersion case _ => if (testDir eq null) { val dir = new File(arg) diff --git a/src/partest/scala/tools/partest/WorkerActor.scala b/src/partest/scala/tools/partest/WorkerActor.scala index d0cf133c82..a76a728f56 100644 --- a/src/partest/scala/tools/partest/WorkerActor.scala +++ b/src/partest/scala/tools/partest/WorkerActor.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ -// $Id: $ +// $Id$ package scala.tools.partest @@ -53,6 +53,10 @@ class WorkerActor(val master: MasterActor, val settings: Settings, var reporter: dir.delete } + private val PATH_SEP = java.io.File.pathSeparatorChar + private val CLASSPATH = System.getProperty("CLASSPATH", "") + private val EXT_CLASSPATH = System.getProperty("JVMEXTCP", "") + def act() { var compiler = newGlobal val bufferSize = 1024 @@ -175,7 +179,11 @@ class WorkerActor(val master: MasterActor, val settings: Settings, var reporter: case _ => {} } - var classpath: List[URL] = outDir.toURL :: List((new File(test.dir)).toURL) ::: List.fromString(System.getProperty("CLASSPATH"), ':').map(x => (new File(x)).toURL) ::: List.fromString(System.getProperty("JVMEXTCP"), ':').map(x => (new File(x)).toURL) + var classpath: List[URL] = + outDir.toURL :: + List((new File(test.dir)).toURL) ::: + (List.fromString(CLASSPATH, PATH_SEP) map { x => (new File(x)).toURL }) ::: + (List.fromString(EXT_CLASSPATH, PATH_SEP) map { x => (new File(x)).toURL }) try { //println(this.toString + " " + "Launching test " + test.fileBase) @@ -230,13 +238,21 @@ class WorkerActor(val master: MasterActor, val settings: Settings, var reporter: case (_, NegTest(_)) => case (true, _) => result = true - var javaoptsFile = new File(test.dir, test.fileBase + ".javaopts") + //var javaoptsFile = new File(test.dir, test.fileBase + ".javaopts") //var javaNewOpts = (new BufferedFileReader(javaoptsFile)).readLine //if (javaoptsFile.exists && javaNewOpts != null) {} - //Use Runtime.exec to execute the compiled file and pipe the standard system out and the console out to the logfile - var cmd = "env JAVACMD=java JAVA_OPTS=-Djava.library.path="+test.dir+" "+System.getProperty("SCALA")+" -Dscalatest.lib="+System.getProperty("scalatest.lib")+" -Dscalatest.cwd="+test.dir+" -Dscalatest.output="+outDir+" -classpath "+outDir+":"+System.getProperty("CLASSPATH")+":"+System.getProperty("JVMEXTCP")+" Test jvm" - - //println(cmd) + //Use Runtime.exec to execute the compiled file and pipe the standard system + //out and the console out to the logfile + var cmd = + "env JAVACMD=java JAVA_OPTS=-Djava.library.path=\"" + test.dir + "\" " + + System.getProperty("SCALA")+ + " -Dscalatest.lib=\"" + System.getProperty("scalatest.lib") + "\" " + + "-Dscalatest.cwd=\"" + test.dir + "\" " + + "-Dscalatest.output=" + outDir + + " -classpath " + outDir + PATH_SEP + CLASSPATH + PATH_SEP + EXT_CLASSPATH + + " Test jvm" + + TestRunner.printVerbose("Worker command: " + cmd) var execution = Runtime.getRuntime.exec(cmd) diff --git a/src/partest/scala/tools/partest/utils/PrintMgr.scala b/src/partest/scala/tools/partest/utils/PrintMgr.scala index a47657d611..96ab7823ae 100644 --- a/src/partest/scala/tools/partest/utils/PrintMgr.scala +++ b/src/partest/scala/tools/partest/utils/PrintMgr.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ -// $Id: $ +// $Id$ package scala.tools.partest.utils diff --git a/src/partest/scala/tools/partest/utils/Properties.scala b/src/partest/scala/tools/partest/utils/Properties.scala new file mode 100644 index 0000000000..3fd2a29575 --- /dev/null +++ b/src/partest/scala/tools/partest/utils/Properties.scala @@ -0,0 +1,57 @@ +/* __ *\ +** ________ ___ / / ___ Scala Parallel Testing ** +** / __/ __// _ | / / / _ | (c) 2007-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +package scala.tools.partest.util + +/** A utility to load the library properties from a Java properties file + * included in the jar. + * + * @author Stephane Micheloud + */ +object Properties { + + /** The name of the properties file */ + private val propFilename = "/partest.properties" + + /** The loaded properties */ + private val props = { + val props = new java.util.Properties + val stream = classOf[Application].getResourceAsStream(propFilename) + if (stream != null) + props.load(stream) + props + } + + /** The version number of the jar this was loaded from, or + * "(unknown)" if it cannot be determined. + */ + val versionString: String = { + val defaultString = "(unknown)" + "version " + props.getProperty("version.number") + } + + val copyrightString: String = { + val defaultString = "(c) 2002-2007 LAMP/EPFL" + props.getProperty("copyright.string", defaultString) + } + + val encodingString: String = { + val defaultString = "ISO-8859-1" + props.getProperty("file.encoding", defaultString) + } + + private val writer = new java.io.PrintWriter(Console.err, true) + + val versionMsg = "Scala partest " + versionString + " -- " + copyrightString + + def main(args: Array[String]) { + writer.println(versionMsg) + } +} diff --git a/test/files/run/json.check b/test/files/run/json.check index 2a3f25166a..a6495477ac 100644 --- a/test/files/run/json.check +++ b/test/files/run/json.check @@ -7,3 +7,5 @@ Some(List((firstName,John), (lastName,Smith), (address,List((streetAddress,21 2n Some(List((fullname,Sean Kelly), (org,SK Consulting), (emailaddrs,List(List((type,work), (value,kelly@seankelly.biz)), List((type,home), (pref,1.0), (value,kelly@seankelly.tv)))), (telephones,List(List((type,work), (pref,1.0), (value,+1 214 555 1212)), List((type,fax), (value,+1 214 555 1213)), List((type,mobile), (value,+1 214 555 1214)))), (addresses,List(List((type,work), (format,us), (value,1234 Main StnSpringfield, TX 78080-1216)), List((type,home), (format,us), (value,5678 Main StnSpringfield, TX 78080-1316)))), (urls,List(List((type,work), (value,http://seankelly.biz/)), List((type,home), (value,http://seankelly.tv/)))))) +Some(List((web-app,List((servlet,List(List((servlet-name,cofaxCDS), (servlet-class,org.cofax.cds.CDSServlet), (init-param,List((configGlossary:installationAt,Philadelphia, PA), (configGlossary:adminEmail,ksm@pobox.com), (configGlossary:poweredBy,Cofax), (configGlossary:poweredByIcon,/images/cofax.gif), (configGlossary:staticPath,/content/static), (templateProcessorClass,org.cofax.WysiwygTemplate), (templateLoaderClass,org.cofax.FilesTemplateLoader), (templatePath,templates), (templateOverridePath,), (defaultListTemplate,listTemplate.htm), (defaultFileTemplate,articleTemplate.htm), (useJSP,false), (jspListTemplate,listTemplate.jsp), (jspFileTemplate,articleTemplate.jsp), (cachePackageTagsTrack,200.0), (cachePackageTagsStore,200.0), (cachePackageTagsRefresh,60.0), (cacheTemplatesTrack,100.0), (cacheTemplatesStore,50.0), (cacheTemplatesRefresh,15.0), (cachePagesTrack,200.0), (cachePagesStore,100.0), (cachePagesRefresh,10.0), (cachePagesDirtyRead,10.0), (searchEngineListTemplate,forSearchEnginesList.htm), (searchEngineFileTemplate,forSearchEngines.htm), (searchEngineRobotsDb,WEB-INF/robots.db), (useDataStore,true), (dataStoreClass,org.cofax.SqlDataStore), (redirectionClass,org.cofax.SqlRedirection), (dataStoreName,cofax), (dataStoreDriver,com.microsoft.jdbc.sqlserver.SQLServerDriver), (dataStoreUrl,jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon), (dataStoreUser,sa), (dataStorePassword,dataStoreTestQuery), (dataStoreTestQuery,SET NOCOUNT ON;select test='test';), (dataStoreLogFile,/usr/local/tomcat/logs/datastore.log), (dataStoreInitConns,10.0), (dataStoreMaxConns,100.0), (dataStoreConnUsageLimit,100.0), (dataStoreLogLevel,debug), (maxUrlLength,500.0)))), List((servlet-name,cofaxEmail), (servlet-class,org.cofax.cds.EmailServlet), (init-param,List((mailHost,mail1), (mailHostOverride,mail2)))), List((servlet-name,cofaxAdmin), (servlet-class,org.cofax.cds.AdminServlet)), List((servlet-name,fileServlet), (servlet-class,org.cofax.cds.FileServlet)), List((servlet-name,cofaxTools), (servlet-class,org.cofax.cms.CofaxToolsServlet), (init-param,List((templatePath,toolstemplates/), (log,1.0), (logLocation,/usr/local/tomcat/logs/CofaxTools.log), (logMaxSize,), (dataLog,1.0), (dataLogLocation,/usr/local/tomcat/logs/dataLog.log), (dataLogMaxSize,), (removePageCache,/content/admin/remove?cache=pages&id=), (removeTemplateCache,/content/admin/remove?cache=templates&id=), (fileTransferFolder,/usr/local/tomcat/webapps/content/fileTransferFolder), (lookInContext,1.0), (adminGroupID,4.0), (betaServer,true)))))), (servlet-mapping,List((cofaxCDS,/), (cofaxEmail,/cofaxutil/aemail/*), (cofaxAdmin,/admin/*), (fileServlet,/static/*), (cofaxTools,/tools/*))), (taglib,List((taglib-uri,cofax.tld), (taglib-location,/WEB-INF/tlds/cofax.tld))))))) + diff --git a/test/files/run/json.scala b/test/files/run/json.scala index 3cb8e3963b..f528eaf5fe 100644 --- a/test/files/run/json.scala +++ b/test/files/run/json.scala @@ -25,7 +25,7 @@ object Test extends Application { "212 732-1234", "646 123-4567" ] -}""".mergeLines +}""" //println(sample1) printJSON(sample1) println @@ -54,8 +54,104 @@ object Test extends Application { {"type": "work", "value": "http://seankelly.biz/"}, {"type": "home", "value": "http://seankelly.tv/"} ] -}""".mergeLines +}""" //println(sample2) printJSON(sample2) println + + // from http://json.org/example.html + val sample3 = """ +{"web-app": { + "servlet": [ + { + "servlet-name": "cofaxCDS", + "servlet-class": "org.cofax.cds.CDSServlet", + "init-param": { + "configGlossary:installationAt": "Philadelphia, PA", + "configGlossary:adminEmail": "ksm@pobox.com", + "configGlossary:poweredBy": "Cofax", + "configGlossary:poweredByIcon": "/images/cofax.gif", + "configGlossary:staticPath": "/content/static", + "templateProcessorClass": "org.cofax.WysiwygTemplate", + "templateLoaderClass": "org.cofax.FilesTemplateLoader", + "templatePath": "templates", + "templateOverridePath": "", + "defaultListTemplate": "listTemplate.htm", + "defaultFileTemplate": "articleTemplate.htm", + "useJSP": false, + "jspListTemplate": "listTemplate.jsp", + "jspFileTemplate": "articleTemplate.jsp", + "cachePackageTagsTrack": 200, + "cachePackageTagsStore": 200, + "cachePackageTagsRefresh": 60, + "cacheTemplatesTrack": 100, + "cacheTemplatesStore": 50, + "cacheTemplatesRefresh": 15, + "cachePagesTrack": 200, + "cachePagesStore": 100, + "cachePagesRefresh": 10, + "cachePagesDirtyRead": 10, + "searchEngineListTemplate": "forSearchEnginesList.htm", + "searchEngineFileTemplate": "forSearchEngines.htm", + "searchEngineRobotsDb": "WEB-INF/robots.db", + "useDataStore": true, + "dataStoreClass": "org.cofax.SqlDataStore", + "redirectionClass": "org.cofax.SqlRedirection", + "dataStoreName": "cofax", + "dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver", + "dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon", + "dataStoreUser": "sa", + "dataStorePassword": "dataStoreTestQuery", + "dataStoreTestQuery": "SET NOCOUNT ON;select test='test';", + "dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log", + "dataStoreInitConns": 10, + "dataStoreMaxConns": 100, + "dataStoreConnUsageLimit": 100, + "dataStoreLogLevel": "debug", + "maxUrlLength": 500}}, + { + "servlet-name": "cofaxEmail", + "servlet-class": "org.cofax.cds.EmailServlet", + "init-param": { + "mailHost": "mail1", + "mailHostOverride": "mail2"}}, + { + "servlet-name": "cofaxAdmin", + "servlet-class": "org.cofax.cds.AdminServlet"}, + + { + "servlet-name": "fileServlet", + "servlet-class": "org.cofax.cds.FileServlet"}, + { + "servlet-name": "cofaxTools", + "servlet-class": "org.cofax.cms.CofaxToolsServlet", + "init-param": { + "templatePath": "toolstemplates/", + "log": 1, + "logLocation": "/usr/local/tomcat/logs/CofaxTools.log", + "logMaxSize": "", + "dataLog": 1, + "dataLogLocation": "/usr/local/tomcat/logs/dataLog.log", + "dataLogMaxSize": "", + "removePageCache": "/content/admin/remove?cache=pages&id=", + "removeTemplateCache": "/content/admin/remove?cache=templates&id=", + "fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder", + "lookInContext": 1, + "adminGroupID": 4, + "betaServer": true}}], + "servlet-mapping": { + "cofaxCDS": "/", + "cofaxEmail": "/cofaxutil/aemail/*", + "cofaxAdmin": "/admin/*", + "fileServlet": "/static/*", + "cofaxTools": "/tools/*"}, + + "taglib": { + "taglib-uri": "cofax.tld", + "taglib-location": "/WEB-INF/tlds/cofax.tld"} + } +}""" + //println(sample3) + printJSON(sample3) + println } diff --git a/test/partest b/test/partest index 31e3680b32..bcc1c8a84b 100755 --- a/test/partest +++ b/test/partest @@ -449,10 +449,10 @@ test_check_kind() { fi; scala_lib=`get_os_filename "$SCALA_LIB"` && classpath=`get_os_pathlist $CLASSPATH` && - # -Djava.library.path $SCALA -DSCALA=$SCALA -DJAVA_OPTS="$java_opts -Xss16M" \ - -DJVMEXTCP=$JVM_EXT_CLASSPATH -Dscalatest.lib=$scala_lib -DCLASSPATH=$classpath \ + -DJVMEXTCP=$JVM_EXT_CLASSPATH -DCLASSPATH=$classpath \ -Dactors.corePoolsize=7 -Dactors.maxPoolSize=8 \ + -Dscalatest.lib=$scala_lib -classpath $classpath \ scala.tools.partest.TestRunner --"$kind" $testdir $resfile 2> /dev/null; load_results; elif [ "$kind" = "shootout" ]; then -- cgit v1.2.3