Skip to content

Commit e99b1d5

Browse files
committed
Merge pull request scala#31 from adriaanm/avoid-OrElse
Avoid or else...
2 parents ae6fe5f + afa3424 commit e99b1d5

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

src/partest/scala/tools/partest/PartestDefaults.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ package scala.tools
22
package partest
33

44
import scala.concurrent.duration.Duration
5-
import scala.tools.nsc.Properties.{ propOrElse, propOrNone, propOrEmpty }
5+
import scala.tools.nsc.Properties.{ propOrNone => prop }
66
import java.lang.Runtime.{ getRuntime => runtime }
77

88
object PartestDefaults {
9-
def sourcePath = propOrElse("partest.srcdir", "files")
10-
def javaCmd = propOrElse("partest.javacmd", "java")
11-
def javacCmd = propOrElse("partest.javac_cmd", "javac")
12-
def javaOpts = propOrElse("partest.java_opts", "") // opts when running java during tests
13-
def scalacOpts = propOrElse("partest.scalac_opts", "")
9+
def sourcePath = prop("partest.srcdir") getOrElse "files"
10+
def javaCmd = prop("partest.javacmd") getOrElse "java"
11+
def javacCmd = prop("partest.javac_cmd") getOrElse "javac"
12+
def javaOpts = prop("partest.java_opts") getOrElse "" // opts when running java during tests
13+
def scalacOpts = prop("partest.scalac_opts") getOrElse ""
1414

15-
def testBuild = propOrNone("partest.build")
16-
def errorCount = propOrElse("partest.errors", "0").toInt
17-
def numThreads = propOrNone("partest.threads") map (_.toInt) getOrElse runtime.availableProcessors
18-
def waitTime = propOrNone("partest.timeout") map (Duration.apply) getOrElse Duration("4 hours")
15+
def testBuild = prop("partest.build")
16+
def errorCount = prop("partest.errors") map (_.toInt) getOrElse 0
17+
def numThreads = prop("partest.threads") map (_.toInt) getOrElse runtime.availableProcessors
18+
def waitTime = Duration(prop("partest.timeout") getOrElse "4 hours")
1919

2020
//def timeout = "1200000" // per-test timeout
2121
}

src/partest/scala/tools/partest/nest/DirectCompiler.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ package nest
99
import scala.tools.nsc.{ Global, Settings, CompilerCommand, FatalError }
1010
import scala.tools.nsc.reporters.{ Reporter, ConsoleReporter }
1111
import scala.tools.nsc.util.{ FakePos, stackTraceString }
12-
import scala.tools.nsc.Properties.{ setProp, propOrEmpty }
1312
import scala.reflect.io.AbstractFile
1413
import scala.reflect.internal.util.Position
1514
import java.io.{ BufferedReader, PrintWriter, FileReader, Writer, FileWriter }

src/partest/scala/tools/partest/nest/PathSettings.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package nest
77

88
import scala.tools.nsc.util.ClassPath
99
import scala.tools.nsc.io.{ Path, File, Directory }
10-
import scala.tools.nsc.Properties.{ propOrElse, propOrNone }
10+
import scala.tools.nsc.Properties.{ propOrNone }
1111
import Path._
1212

1313
/** Get current value for path settings -- these depend on the mutable `testSourcePath`.

src/partest/scala/tools/partest/nest/Runner.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import scala.io.Codec
1616
import scala.reflect.internal.FatalError
1717
import scala.reflect.internal.util.ScalaClassLoader
1818
import scala.sys.process.{ Process, ProcessLogger }
19-
import scala.tools.nsc.Properties.{ envOrElse, isWin, jdkHome, javaHome, propOrElse, propOrEmpty, setProp, versionMsg, javaVmName, javaVmVersion, javaVmInfo }
19+
import scala.tools.nsc.Properties.{ envOrNone, isWin, jdkHome, javaHome, propOrEmpty, setProp, versionMsg, javaVmName, javaVmVersion, javaVmInfo }
2020
import scala.tools.nsc.{ Settings, CompilerCommand, Global }
2121
import scala.tools.nsc.io.{ AbstractFile }
2222
import scala.tools.nsc.reporters.ConsoleReporter
@@ -75,6 +75,9 @@ class Runner(val testFile: File, val suiteRunner: SuiteRunner) {
7575

7676
lazy val outDir = { outFile.mkdirs() ; outFile }
7777

78+
// oh boy...
79+
private lazy val antLauncher = SFile(Path(envOrNone("ANT_HOME") getOrElse "/opt/ant/") / "lib/ant-launcher.jar")
80+
7881
type RanOneTest = (Boolean, LogContext)
7982

8083
def showCrashInfo(t: Throwable) {
@@ -293,7 +296,7 @@ class Runner(val testFile: File, val suiteRunner: SuiteRunner) {
293296
def gitDiff(f1: File, f2: File): Option[String] = {
294297
try gitRunner map { git =>
295298
val cmd = s"$git diff $gitDiffOptions $f1 $f2"
296-
val diff = Process(cmd).lines_!.drop(4).map(_ + "\n").mkString
299+
val diff = Process(cmd).lineStream_!.drop(4).map(_ + "\n").mkString
297300

298301
"\n" + diff
299302
}
@@ -510,16 +513,13 @@ class Runner(val testFile: File, val suiteRunner: SuiteRunner) {
510513

511514
// Apache Ant 1.6 or newer
512515
def ant(args: Seq[String], output: File): Boolean = {
513-
val antDir = Directory(envOrElse("ANT_HOME", "/opt/ant/"))
514-
val antLibDir = Directory(antDir / "lib")
515-
val antLauncherPath = SFile(antLibDir / "ant-launcher.jar").path
516516
val antOptions =
517517
if (NestUI._verbose) List("-verbose", "-noinput")
518518
else List("-noinput")
519519
val cmd = javaCmdPath +: (
520520
PartestDefaults.javaOpts.split(' ').map(_.trim).filter(_ != "") ++ Seq(
521521
"-classpath",
522-
antLauncherPath,
522+
antLauncher.path,
523523
"org.apache.tools.ant.launch.Launcher"
524524
) ++ antOptions ++ args
525525
)

0 commit comments

Comments
 (0)