Merge pull request #1512 from sbt/wip/fix-1506

Fix unknown host exception in junit xml listener.
This commit is contained in:
eugene yokota 2014-08-12 14:55:20 -04:00
commit 52fb91844f
1 changed files with 7 additions and 3 deletions

View File

@ -1,7 +1,7 @@
package sbt
import java.io.{ StringWriter, PrintWriter, File }
import java.net.InetAddress
import java.io.{IOException, StringWriter, PrintWriter, File}
import java.net.{InetAddress}
import scala.collection.mutable.ListBuffer
import scala.util.DynamicVariable
@ -15,7 +15,11 @@ import testing.{ Event => TEvent, Status => TStatus, OptionalThrowable, TestSele
*/
class JUnitXmlTestsListener(val outputDir: String) extends TestsListener {
/**Current hostname so we know which machine executed the tests*/
val hostname = InetAddress.getLocalHost.getHostName
val hostname =
try InetAddress.getLocalHost.getHostName
catch {
case x: IOException => "localhost"
}
/**The dir in which we put all result files. Is equal to the given dir + "/test-reports"*/
val targetDir = new File(outputDir + "/test-reports/")