diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-10-26 16:19:35 +0200 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2016-11-22 01:35:06 +0100 |
commit | 06a3d47ea9fd1b67b3acba9d115a16d18549e377 (patch) | |
tree | 36311873f40e1410154c50d00abb03715619e8cc | |
parent | 0da788c52121e44de6be0cdc7a0c4c6e1b125ff9 (diff) | |
download | dotty-06a3d47ea9fd1b67b3acba9d115a16d18549e377.tar.gz dotty-06a3d47ea9fd1b67b3acba9d115a16d18549e377.tar.bz2 dotty-06a3d47ea9fd1b67b3acba9d115a16d18549e377.zip |
Move sjs, make sure that partest compiles everything in dirs
-rw-r--r-- | library/src/scalaShadowing/language.scala (renamed from src/scalaShadowing/language.scala) | 14 | ||||
-rw-r--r-- | project/Build.scala | 86 | ||||
-rw-r--r-- | sjs/backend/sjs/GenSJSIR.scala (renamed from src/dotty/tools/backend/sjs/GenSJSIR.scala) | 0 | ||||
-rw-r--r-- | sjs/backend/sjs/JSCodeGen.scala (renamed from src/dotty/tools/backend/sjs/JSCodeGen.scala) | 0 | ||||
-rw-r--r-- | sjs/backend/sjs/JSDefinitions.scala (renamed from src/dotty/tools/backend/sjs/JSDefinitions.scala) | 0 | ||||
-rw-r--r-- | sjs/backend/sjs/JSEncoding.scala (renamed from src/dotty/tools/backend/sjs/JSEncoding.scala) | 0 | ||||
-rw-r--r-- | sjs/backend/sjs/JSInterop.scala (renamed from src/dotty/tools/backend/sjs/JSInterop.scala) | 0 | ||||
-rw-r--r-- | sjs/backend/sjs/JSPositions.scala (renamed from src/dotty/tools/backend/sjs/JSPositions.scala) | 0 | ||||
-rw-r--r-- | sjs/backend/sjs/JSPrimitives.scala (renamed from src/dotty/tools/backend/sjs/JSPrimitives.scala) | 0 | ||||
-rw-r--r-- | sjs/backend/sjs/ScopedVar.scala (renamed from src/dotty/tools/backend/sjs/ScopedVar.scala) | 0 | ||||
-rw-r--r-- | sjs/tools/dotc/config/SJSPlatform.scala (renamed from src/dotty/tools/dotc/config/SJSPlatform.scala) | 0 | ||||
-rw-r--r-- | src/dotty/tools/dotc/Compiler.scala | 17 | ||||
-rw-r--r-- | src/dotty/tools/dotc/config/PathResolver.scala | 24 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Contexts.scala | 5 | ||||
-rw-r--r-- | test/dotc/tests.scala | 55 | ||||
-rw-r--r-- | test/dotty/partest/DPConsoleRunner.scala | 102 | ||||
-rw-r--r-- | test/test/CompilerTest.scala | 27 | ||||
-rw-r--r-- | tests/repl/imports.check | 6 |
18 files changed, 149 insertions, 187 deletions
diff --git a/src/scalaShadowing/language.scala b/library/src/scalaShadowing/language.scala index a74c9c671..e2fc5ec61 100644 --- a/src/scalaShadowing/language.scala +++ b/library/src/scalaShadowing/language.scala @@ -25,18 +25,18 @@ package scalaShadowing * - [[higherKinds `higherKinds`]] enables writing higher-kinded types * - [[existentials `existentials`]] enables writing existential types * - [[experimental `experimental`]] contains newer features that have not yet been tested in production - * + * * and, for dotty: - * + * * - [[Scala2 `Scala2`] backwards compatibility mode for Scala2 - * - [[noAtoTupling `noAutoTupling`]] disable auto-tupling + * - [[noAtoTupling `noAutoTupling`]] disable auto-tupling * * @groupname production Language Features * @groupname experimental Experimental Language Features * @groupprio experimental 10 - * + * * Dotty-specific features come at the end. - * + * * Note: Due to the more restricted language import mechanism in dotty (only * imports count, implicits are disregarded) we don't need the constructions * of the inherited language features. A simple object for each feature is @@ -189,10 +189,10 @@ object language { */ @volatile implicit lazy val macros: macros = languageFeature.experimental.macros } - + /** Where imported, a backwards compatibility mode for Scala2 is enabled */ object Scala2 - + /** Where imported, auto-tupling is disabled */ object noAutoTupling } diff --git a/project/Build.scala b/project/Build.scala index e7fab03eb..6341f08c4 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -135,9 +135,13 @@ object DottyBuild extends Build { // command line arguments get passed to the last task in an aliased // sequence (see partest alias below), so this works. val args = Def.spaceDelimited("<arg>").parsed - val jars = Seq((packageBin in Compile).value.getAbsolutePath) ++ - getJarPaths(partestDeps.value, ivyPaths.value.ivyHome) - val dottyJars = "-dottyJars " + (jars.length + 1) + " dotty-lib.jar" + " " + jars.mkString(" ") + val jars = List( + (packageBin in Compile).value.getAbsolutePath, + (packageBin in (`dotty-library`, Compile)).value.getAbsolutePath, + (packageBin in (`dotty-interfaces`, Compile)).value.getAbsolutePath + ) ++ getJarPaths(partestDeps.value, ivyPaths.value.ivyHome) + val dottyJars = + s"""-dottyJars ${jars.length + 2} dotty.jar dotty-lib.jar ${jars.mkString(" ")}""" // Provide the jars required on the classpath of run tests runTask(Test, "dotty.partest.DPConsoleRunner", dottyJars + " " + args.mkString(" ")) }, @@ -147,32 +151,33 @@ object DottyBuild extends Build { * of scalajs-ir built with a different Scala compiler, we add its * sources instead of depending on the binaries. */ - ivyConfigurations += config("sourcedeps").hide, - libraryDependencies += - "org.scala-js" %% "scalajs-ir" % scalaJSVersion % "sourcedeps", - sourceGenerators in Compile += Def.task { - val s = streams.value - val cacheDir = s.cacheDirectory - val trgDir = (sourceManaged in Compile).value / "scalajs-ir-src" - - val report = updateClassifiers.value - val scalaJSIRSourcesJar = report.select( - configuration = Set("sourcedeps"), - module = (_: ModuleID).name.startsWith("scalajs-ir_"), - artifact = artifactFilter(`type` = "src")).headOption.getOrElse { - sys.error(s"Could not fetch scalajs-ir sources") - } - - FileFunction.cached(cacheDir / s"fetchScalaJSIRSource", - FilesInfo.lastModified, FilesInfo.exists) { dependencies => - s.log.info(s"Unpacking scalajs-ir sources to $trgDir...") - if (trgDir.exists) - IO.delete(trgDir) - IO.createDirectory(trgDir) - IO.unzip(scalaJSIRSourcesJar, trgDir) - (trgDir ** "*.scala").get.toSet - } (Set(scalaJSIRSourcesJar)).toSeq - }.taskValue, + //TODO: disabling until moved to separate project + //ivyConfigurations += config("sourcedeps").hide, + //libraryDependencies += + // "org.scala-js" %% "scalajs-ir" % scalaJSVersion % "sourcedeps", + //sourceGenerators in Compile += Def.task { + // val s = streams.value + // val cacheDir = s.cacheDirectory + // val trgDir = (sourceManaged in Compile).value / "scalajs-ir-src" + + // val report = updateClassifiers.value + // val scalaJSIRSourcesJar = report.select( + // configuration = Set("sourcedeps"), + // module = (_: ModuleID).name.startsWith("scalajs-ir_"), + // artifact = artifactFilter(`type` = "src")).headOption.getOrElse { + // sys.error(s"Could not fetch scalajs-ir sources") + // } + + // FileFunction.cached(cacheDir / s"fetchScalaJSIRSource", + // FilesInfo.lastModified, FilesInfo.exists) { dependencies => + // s.log.info(s"Unpacking scalajs-ir sources to $trgDir...") + // if (trgDir.exists) + // IO.delete(trgDir) + // IO.createDirectory(trgDir) + // IO.unzip(scalaJSIRSourcesJar, trgDir) + // (trgDir ** "*.scala").get.toSet + // } (Set(scalaJSIRSourcesJar)).toSeq + //}.taskValue, // Adjust classpath for running dotty mainClass in (Compile, run) := Some("dotty.tools.dotc.Main"), @@ -185,29 +190,34 @@ object DottyBuild extends Build { // http://grokbase.com/t/gg/simple-build-tool/135ke5y90p/sbt-setting-jvm-boot-paramaters-for-scala javaOptions <++= (dependencyClasspath in Runtime, packageBin in Compile) map { (attList, bin) => - // put the Scala {library, reflect} in the classpath + // put needed dependencies on classpath: val path = for { file <- attList.map(_.data) path = file.getAbsolutePath + // FIXME: when we snip the cord, this should go bye-bye + if path.contains("scala-library") || + // FIXME: currently needed for tests referencing scalac internals + path.contains("scala-reflect") || + // FIXME: currently needed for tests referencing scalac internals + path.contains("scala-compile") || + // FIXME: should go away when xml literal parsing is removed + path.contains("scala-xml") || + // needed for the xsbti interface + path.contains("sbt-interface") } yield "-Xbootclasspath/p:" + path - // dotty itself needs to be in the bootclasspath - val fullpath = /*("-Xbootclasspath/p:" + "dotty.jar") ::*/ ("-Xbootclasspath/a:" + bin) :: path.toList - // System.err.println("BOOTPATH: " + fullpath) val travis_build = // propagate if this is a travis build if (sys.props.isDefinedAt(JENKINS_BUILD)) List(s"-D$JENKINS_BUILD=${sys.props(JENKINS_BUILD)}") ::: jenkinsMemLimit - else - List() + else List() val tuning = if (sys.props.isDefinedAt("Oshort")) // Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222 List("-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1") - else - List() + else List() - ("-DpartestParentID=" + pid) :: tuning ::: agentOptions ::: travis_build ::: fullpath + ("-DpartestParentID=" + pid) :: tuning ::: agentOptions ::: travis_build ::: path.toList } ). settings( diff --git a/src/dotty/tools/backend/sjs/GenSJSIR.scala b/sjs/backend/sjs/GenSJSIR.scala index 819a8f0e3..819a8f0e3 100644 --- a/src/dotty/tools/backend/sjs/GenSJSIR.scala +++ b/sjs/backend/sjs/GenSJSIR.scala diff --git a/src/dotty/tools/backend/sjs/JSCodeGen.scala b/sjs/backend/sjs/JSCodeGen.scala index 401e01784..401e01784 100644 --- a/src/dotty/tools/backend/sjs/JSCodeGen.scala +++ b/sjs/backend/sjs/JSCodeGen.scala diff --git a/src/dotty/tools/backend/sjs/JSDefinitions.scala b/sjs/backend/sjs/JSDefinitions.scala index bd0b74031..bd0b74031 100644 --- a/src/dotty/tools/backend/sjs/JSDefinitions.scala +++ b/sjs/backend/sjs/JSDefinitions.scala diff --git a/src/dotty/tools/backend/sjs/JSEncoding.scala b/sjs/backend/sjs/JSEncoding.scala index e8ea3258b..e8ea3258b 100644 --- a/src/dotty/tools/backend/sjs/JSEncoding.scala +++ b/sjs/backend/sjs/JSEncoding.scala diff --git a/src/dotty/tools/backend/sjs/JSInterop.scala b/sjs/backend/sjs/JSInterop.scala index 6d66c3206..6d66c3206 100644 --- a/src/dotty/tools/backend/sjs/JSInterop.scala +++ b/sjs/backend/sjs/JSInterop.scala diff --git a/src/dotty/tools/backend/sjs/JSPositions.scala b/sjs/backend/sjs/JSPositions.scala index 10570da00..10570da00 100644 --- a/src/dotty/tools/backend/sjs/JSPositions.scala +++ b/sjs/backend/sjs/JSPositions.scala diff --git a/src/dotty/tools/backend/sjs/JSPrimitives.scala b/sjs/backend/sjs/JSPrimitives.scala index 6c3c5715c..6c3c5715c 100644 --- a/src/dotty/tools/backend/sjs/JSPrimitives.scala +++ b/sjs/backend/sjs/JSPrimitives.scala diff --git a/src/dotty/tools/backend/sjs/ScopedVar.scala b/sjs/backend/sjs/ScopedVar.scala index 0e47f7b79..0e47f7b79 100644 --- a/src/dotty/tools/backend/sjs/ScopedVar.scala +++ b/sjs/backend/sjs/ScopedVar.scala diff --git a/src/dotty/tools/dotc/config/SJSPlatform.scala b/sjs/tools/dotc/config/SJSPlatform.scala index 3ec8049ae..3ec8049ae 100644 --- a/src/dotty/tools/dotc/config/SJSPlatform.scala +++ b/sjs/tools/dotc/config/SJSPlatform.scala diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala index 4bc5263e9..ad3249be2 100644 --- a/src/dotty/tools/dotc/Compiler.scala +++ b/src/dotty/tools/dotc/Compiler.scala @@ -17,7 +17,6 @@ import core.DenotTransformers.DenotTransformer import core.Denotations.SingleDenotation import dotty.tools.backend.jvm.{LabelDefs, GenBCode, CollectSuperCalls} -import dotty.tools.backend.sjs.GenSJSIR /** The central class of the dotc compiler. The job of a compiler is to create * runs, which process given `phases` in a given `rootContext`. @@ -98,7 +97,6 @@ class Compiler { new DropInlined, // Drop Inlined nodes, since backend has no use for them new MoveStatics, // Move static methods to companion classes new LabelDefs), // Converts calls to labels to jumps - List(new GenSJSIR), // Generate .js code List(new GenBCode) // Generate JVM bytecode ) @@ -117,20 +115,7 @@ class Compiler { */ def rootContext(implicit ctx: Context): Context = { ctx.initialize()(ctx) - val actualPhases = if (ctx.settings.scalajs.value) { - // Remove phases that Scala.js does not want - phases.mapConserve(_.filter { - case _: FunctionalInterfaces => false - case _ => true - }).filter(_.nonEmpty) - } else { - // Remove Scala.js-related phases - phases.mapConserve(_.filter { - case _: GenSJSIR => false - case _ => true - }).filter(_.nonEmpty) - } - ctx.setPhasePlan(actualPhases) + ctx.setPhasePlan(phases) val rootScope = new MutableScope val bootstrap = ctx.fresh .setPeriod(Period(nextRunId, FirstPhaseId)) diff --git a/src/dotty/tools/dotc/config/PathResolver.scala b/src/dotty/tools/dotc/config/PathResolver.scala index 1f9ee7eec..14a44531a 100644 --- a/src/dotty/tools/dotc/config/PathResolver.scala +++ b/src/dotty/tools/dotc/config/PathResolver.scala @@ -46,18 +46,7 @@ object PathResolver { def classPathEnv = envOrElse("CLASSPATH", "") def sourcePathEnv = envOrElse("SOURCEPATH", "") - def javaBootClassPath = - propOrElse("sun.boot.class.path", searchForBootClasspath) - .split(":") - .filterNot { jar => - // let's blacklist locally compiled classes: - jar.contains("/dotty/library/target/classes") || - jar.contains("/dotty/library/target/scala-2.11/classes") || - jar.contains("/dotty/interfaces/target/classes") || - jar.contains("/dotty/target/scala-2.11/classes") || - jar.contains("/dotty/target/classes") - } - .mkString(":") + def javaBootClassPath = propOrElse("sun.boot.class.path", searchForBootClasspath) def javaExtDirs = propOrEmpty("java.ext.dirs") def scalaHome = propOrEmpty("scala.home") @@ -266,8 +255,15 @@ class PathResolver(implicit ctx: Context) { def containers = Calculated.containers lazy val result: JavaClassPath = { - val (dottyJars, others) = containers.partition(_.name.contains("dotty")) - val cp = new JavaClassPath((dottyJars ++ others).toIndexedSeq, context) + // Prioritize `dotty.jar` and `dotty-lib.jar` to shadow others + val (dottyJars, others) = + containers.partition(x => x.name.contains("dotty-lib.jar") || x.name.contains("dotty.jar")) + // Then any jars with `dotty` in the name - putting them before scala-library + val (dottyCp, remaining) = + others.partition(_.name.contains("dotty-")) + + val cp = new JavaClassPath((dottyJars ++ dottyCp ++ remaining).toIndexedSeq, context) + if (settings.Ylogcp.value) { Console.println("Classpath built from " + settings.toConciseString(ctx.sstate)) Console.println("Defaults: " + PathResolver.Defaults) diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala index edc68588d..639c4d111 100644 --- a/src/dotty/tools/dotc/core/Contexts.scala +++ b/src/dotty/tools/dotc/core/Contexts.scala @@ -27,7 +27,7 @@ import reporting._ import collection.mutable import collection.immutable.BitSet import printing._ -import config.{Settings, ScalaSettings, Platform, JavaPlatform, SJSPlatform} +import config.{Settings, ScalaSettings, Platform, JavaPlatform} import language.implicitConversions import DenotTransformers.DenotTransformer import util.Property.Key @@ -550,8 +550,7 @@ object Contexts { } protected def newPlatform(implicit ctx: Context): Platform = - if (settings.scalajs.value) new SJSPlatform - else new JavaPlatform + new JavaPlatform /** The loader that loads the members of _root_ */ def rootLoader(root: TermSymbol)(implicit ctx: Context): SymbolLoader = platform.rootLoader(root) diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala index 747396c73..d96111dee 100644 --- a/test/dotc/tests.scala +++ b/test/dotc/tests.scala @@ -3,6 +3,7 @@ package dotc import test._ import org.junit.{Before, Test} +import java.io.{ File => JFile } import scala.reflect.io.Directory import scala.io.Source @@ -23,20 +24,34 @@ class tests extends CompilerTest { "-d", defaultOutputDir ) - val classPath = List( + val checkOptions = List( "-Yno-deep-subtypes", "-Yno-double-bindings", "-Yforce-sbt-phases", - "-color:never", - "-classpath", - "./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar" + - ":./interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar" + "-color:never" ) + val classPath = { + val paths = List( + "./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar", + "./target/scala-2.11/dotty-compiler_2.11-0.1-SNAPSHOT.jar", + "./interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar" + ).map { p => + val file = new JFile(p) + assert( + file.exists, + s"""File "$p" couldn't be found. Run `packageAll` from build tool before testing""" + ) + file.getAbsolutePath + }.mkString(":") + + List("-classpath", paths) + } + implicit val defaultOptions = noCheckOptions ++ { if (isRunByJenkins) List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") // should be Ycheck:all, but #725 else List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") - } ++ classPath + } ++ checkOptions ++ classPath val testPickling = List("-Xprint-types", "-Ytest-pickler", "-Ystop-after:pickler", "-Yprintpos") @@ -189,32 +204,10 @@ class tests extends CompilerTest { @Test def compileIndexedSeq = compileLine("./scala-scala/src/library/scala/collection/immutable/IndexedSeq.scala") // Not a junit test anymore since it is order dependent - def dottyBootedLib = compileDir( - libDir, - ".", - List( - "-deep", "-Ycheck-reentrant", "-strict", "-classpath", defaultOutputDir + - ":./target/scala-2.11/dotty-compiler_2.11-0.1-SNAPSHOT.jar" + - ":./interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar" + - ":./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar" - ) - )(allowDeepSubtypes) // note the -deep argument + def dottyBootedLib = compileDir(libDir, ".")(allowDeepSubtypes) // note the -deep argument // Not a junit test anymore since it is order dependent - def dottyDependsOnBootedLib = compileDir( - dottyDir, - ".", - List( - "-deep", "-Ycheck-reentrant", "-strict", "-classpath", defaultOutputDir + - ":./dotty-lib.jar" + - ":./interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar" + - // this needs to get compiled together with the compiler: - //":./target/scala-2.11/src_managed/main/scalajs-ir-src/" - // but falling back to: - ":/home/fixel/.ivy2/cache/org.scala-js/scalajs-ir_2.11/jars/scalajs-ir_2.11-0.6.8.jar" - // for the time being. - ) - )(allowDeepSubtypes) // note the -deep argument + @Test def dottyDependsOnBootedLib = compileDir(dottyDir, ".")(allowDeepSubtypes) // note the -deep argument @Test def dotc_ast = compileDir(dotcDir, "ast") @Test def dotc_config = compileDir(dotcDir, "config") @@ -279,7 +272,7 @@ class tests extends CompilerTest { "scalaPrimitives.scala" ) map (s"${backendDir}jvm/" + _), testPickling) - @Test def tasty_backend_sjs = compileDir(s"${backendDir}", "sjs", testPickling) + //@Test def tasty_backend_sjs = compileDir(s"${backendDir}", "sjs", testPickling) @Test def tasty_dotc = compileDir(toolsDir, "dotc", testPickling) @Test def tasty_dotc_ast = compileDir(dotcDir, "ast", testPickling) diff --git a/test/dotty/partest/DPConsoleRunner.scala b/test/dotty/partest/DPConsoleRunner.scala index 27d53159b..4552d1137 100644 --- a/test/dotty/partest/DPConsoleRunner.scala +++ b/test/dotty/partest/DPConsoleRunner.scala @@ -30,10 +30,6 @@ object DPConsoleRunner { case Nil => sys.error("Error: DPConsoleRunner needs \"-dottyJars <jarCount> <jars>*\".") case jarFinder(nr, jarString) :: Nil => val jars = jarString.split(" ").toList - println("------------------------------------------------------------") - println("jars:") - jars.foreach(println) - println("------------------------------------------------------------") val count = nr.toInt if (jars.length < count) sys.error("Error: DPConsoleRunner found wrong number of dottyJars: " + jars + ", expected: " + nr) @@ -155,11 +151,7 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn "-d", outDir.getAbsolutePath, "-classpath", - joinPaths(outDir :: extraClasspath.filter { fp => - fp.endsWith("dotty-lib.jar") || - fp.endsWith("scala-library-2.11.5.jar") || - fp.endsWith("scala-reflect-2.11.5.jar") - }) + joinPaths(outDir :: extraClasspath ++ testClassPath) ) ++ files.map(_.getAbsolutePath) pushTranscript(args mkString " ") @@ -172,58 +164,35 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn } } - override def run(): TestState = { - if (kind == "run") { - // javac runner, for one, would merely append to an existing log file, so - // just delete it before we start - logFile.delete() - runTestCommon(execTest(outDir, logFile) && diffIsOk) - lastState - } else super.run() - } - - // Re-implemented for running tests - def execTest(outDir: File, logFile: File): Boolean = { - val argsFile = testFile changeExtension "javaopts" - val argString = file2String(argsFile) - if (argString != "") NestUI.verbose( - "Found javaopts file '%s', using options: '%s'".format(argsFile, argString) - ) - - val classpath = joinPaths { - val sep = sys.props("path.separator") - val fps = extraClasspath.filter { fp => - fp.endsWith("dotty-lib.jar") || - fp.endsWith("scala-library-2.11.5.jar") || - fp.endsWith("scala-reflect-2.11.5.jar") + // Overriden in order to recursively get all sources that should be handed to + // the compiler. Otherwise only sources in the top dir is compiled - works + // because the compiler is on the classpath. + override def sources(file: File): List[File] = + if (file.isDirectory) + file.listFiles.toList.flatMap { f => + if (f.isDirectory) sources(f) + else if (f.isJavaOrScala) List(f) + else Nil } - - fps ++ fileManager.testClassPath - } - - val javaOpts: List[String] = ( - suiteRunner.javaOpts.split(' ') ++ - extraJavaOptions ++ - argString.split(' ') - ).map(_.trim).filter(_ != "").toList - - val cmd: List[String] = (suiteRunner.javaCmdPath :: javaOpts) ++ ( - "-classpath" :: join(outDir.toString, classpath) :: - "Test" :: "jvm" :: // default argument to Test class in super is "jvm" - Nil - ) - - pushTranscript((cmd mkString s" \\$EOL ") + " > " + logFile.getName) - nextTestAction(runCommand(cmd, logFile)) { - case false => - //_transcript append EOL + logFile.fileContents - // think this is equivalent: - val contents = logFile.fileContents - println(contents) - pushTranscript(contents) - genFail("non-zero exit code") - } - } + else List(file) + + // Enable me to "fix" the depth issue - remove once completed + //override def compilationRounds(file: File): List[CompileRound] = { + // val srcs = sources(file) match { + // case Nil => + // System.err.println { + // s"""|================================================================================ + // |Warning! You attempted to compile sources from: + // | $file + // |but partest was unable to find any sources - uncomment DPConsoleRunner#sources + // |================================================================================""".stripMargin + // } + // List(new File("./examples/hello.scala")) // "just compile some crap" - Guillaume + // case xs => + // xs + // } + // (groupedFiles(srcs) map mixedCompileGroup).flatten + //} // FIXME: This is copy-pasted from nest.Runner where it is private // Remove this once https://github.com/scala/scala-partest/pull/61 is merged @@ -371,16 +340,17 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn } // override to add dotty and scala jars to classpath - override def extraClasspath = { - val cp = suiteRunner.fileManager.asInstanceOf[DottyFileManager].extraJarList ::: super.extraClasspath - //println(s"extraClasspath: $cp") - cp - } + override def extraClasspath = + suiteRunner.fileManager.asInstanceOf[DottyFileManager].extraJarList ::: super.extraClasspath // override to keep class files if failed and delete clog if ok - override def cleanup = if (lastState.isOk) { + override def cleanup = if (lastState.isOk) try { logFile.delete cLogFile.delete Directory(outDir).deleteRecursively + } catch { + case t: Throwable => + println("whhhhhhhhhhhhhhhhhhhhhhhhhhhaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaat") + throw t } } diff --git a/test/test/CompilerTest.scala b/test/test/CompilerTest.scala index 5a4a9830a..05a7d62b8 100644 --- a/test/test/CompilerTest.scala +++ b/test/test/CompilerTest.scala @@ -442,8 +442,14 @@ abstract class CompilerTest { nr: Int = 0, oldOutput: String = defaultOutputDir): Unit = { val partestOutput = dest.jfile.getParentFile + JFile.separator + dest.stripExtension + "-" + kind + ".obj" - val flags = oldFlags.map(f => if (f == oldOutput) partestOutput else f) ++ - List(s"-classpath $partestOutput") // Required for separate compilation tests + + val altOutput = + source.getParentFile.getAbsolutePath.map(x => if (x == JFile.separatorChar) '_' else x) + + val (beforeCp, remaining) = oldFlags + .map(f => if (f == oldOutput) partestOutput else f) + .span(_ != "-classpath") + val flags = beforeCp ++ List("-classpath", (partestOutput :: remaining.drop(1)).mkString(":")) val difference = getExisting(dest).isDifferent(source, flags, nerr) difference match { @@ -451,8 +457,12 @@ abstract class CompilerTest { case ExistsSame => // nothing else to do case ExistsDifferent => val nextDest = dest.parent / (dest match { - case d: Directory => Directory(replaceVersion(d.name, nr)) - case f => SFile(replaceVersion(f.stripExtension, nr)).addExtension(f.extension) + case d: Directory => + val newVersion = replaceVersion(d.name, nr).getOrElse(altOutput) + Directory(newVersion) + case f => + val newVersion = replaceVersion(f.stripExtension, nr).getOrElse(altOutput) + SFile(newVersion).addExtension(f.extension) }) computeDestAndCopyFiles(source, nextDest, kind, flags, nerr, nr + 1, partestOutput) } @@ -555,13 +565,12 @@ abstract class CompilerTest { import scala.util.matching.Regex val nrFinder = """(.*_v)(\d+)""".r /** Changes the version number suffix in the name (without extension). */ - private def replaceVersion(name: String, nr: Int): String = { + private def replaceVersion(name: String, nr: Int): Option[String] = { val nrString = nr.toString name match { - case nrFinder(prefix, `nrString`) => prefix + (nr + 1) - case _ => - assert(nr == 0, "DPCompilerTest couldn't create new version of files, match error") - name + "_v1" + case nrFinder(prefix, `nrString`) => Some(prefix + (nr + 1)) + case _ if nr != 0 => None + case _ => Some(name + "_v1") } } diff --git a/tests/repl/imports.check b/tests/repl/imports.check index 4ca59e4ee..7e078fe00 100644 --- a/tests/repl/imports.check +++ b/tests/repl/imports.check @@ -16,13 +16,13 @@ scala> buf += xs scala> buf ++= xs res1: scala.collection.mutable.ListBuffer[Int] = ListBuffer(1, 2, 3) scala> import util.foo --- Error: <console> ---------------------------------------------------------------------------------------------------- +-- Error: <console> ------------------------------------------------------------ 8 |import util.foo | ^^^ | foo is not a member of util scala> import util.foo.bar --- [E008] Member Not Found Error: <console> ---------------------------------------------------------------------------- +-- [E008] Member Not Found Error: <console> ------------------------------------ 8 |import util.foo.bar | ^^^^^^^^ - | value `foo` is not a member of util.type - did you mean `util.Left`? + | value `foo` is not a member of util.type - did you mean `util.Left`? scala> :quit |