mirror of
https://github.com/lightbend/config.git
synced 2025-02-21 00:30:32 +08:00
factor out resourceDir and resourceFile (centralize assumption about test pwd)
This commit is contained in:
parent
0457e352fb
commit
907048fe2b
@ -17,9 +17,6 @@ import org.junit.runners.AllTests
|
||||
class EquivalentsTest extends TestUtils {
|
||||
|
||||
private def equivDirs() = {
|
||||
val resourceDir = new File("config/src/test/resources")
|
||||
if (!resourceDir.exists())
|
||||
throw new RuntimeException("This test can only be run from the project's root directory")
|
||||
val rawEquivs = resourceDir.listFiles()
|
||||
val equivs = rawEquivs.filter({ f => f.getName().startsWith("equiv") })
|
||||
equivs
|
||||
|
@ -220,13 +220,6 @@ class PublicApiTest extends TestUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private def resourceFile(filename: String) = {
|
||||
val resourceDir = new File("config/src/test/resources")
|
||||
if (!resourceDir.exists())
|
||||
throw new RuntimeException("This test can only be run from the project's root directory")
|
||||
new File(resourceDir, filename)
|
||||
}
|
||||
|
||||
@Test
|
||||
def defaultParseOptions() {
|
||||
val d = ConfigParseOptions.defaults()
|
||||
|
@ -12,6 +12,7 @@ import com.typesafe.config.ConfigParseOptions
|
||||
import com.typesafe.config.Config
|
||||
import com.typesafe.config.ConfigSyntax
|
||||
import com.typesafe.config.ConfigFactory
|
||||
import java.io.File
|
||||
|
||||
abstract trait TestUtils {
|
||||
protected def intercept[E <: Throwable: Manifest](block: => Unit): E = {
|
||||
@ -431,4 +432,15 @@ abstract trait TestUtils {
|
||||
// the parser; in the test suite we are often testing the parser,
|
||||
// so we don't want to use the parser to build the expected result.
|
||||
def path(elements: String*) = new Path(elements: _*)
|
||||
|
||||
val resourceDir = {
|
||||
val f = new File("config/src/test/resources")
|
||||
if (!f.exists())
|
||||
throw new Exception("Tests must be run from the root project directory containing " + f.getPath())
|
||||
f
|
||||
}
|
||||
|
||||
protected def resourceFile(filename: String) = {
|
||||
new File(resourceDir, filename)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user