mirror of
https://github.com/lightbend/config.git
synced 2025-01-15 23:01:05 +08:00
Fix test failure on Windows
This commit is contained in:
parent
a4cd479c7f
commit
8b1ee8a8f2
@ -5,15 +5,12 @@ package com.typesafe.config.impl
|
|||||||
|
|
||||||
import org.junit.Assert._
|
import org.junit.Assert._
|
||||||
import org.junit._
|
import org.junit._
|
||||||
import java.io.Reader
|
|
||||||
import java.io.StringReader
|
import java.io.StringReader
|
||||||
import com.typesafe.config._
|
import com.typesafe.config._
|
||||||
import java.util.HashMap
|
|
||||||
import scala.collection.JavaConverters._
|
import scala.collection.JavaConverters._
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.util.Properties
|
import java.util.Properties
|
||||||
import java.io.ByteArrayInputStream
|
|
||||||
|
|
||||||
class ConfParserTest extends TestUtils {
|
class ConfParserTest extends TestUtils {
|
||||||
|
|
||||||
@ -714,7 +711,7 @@ class ConfParserTest extends TestUtils {
|
|||||||
def includeFileNotQuoted() {
|
def includeFileNotQuoted() {
|
||||||
// this test cannot work on Windows
|
// this test cannot work on Windows
|
||||||
val f = resourceFile("test01")
|
val f = resourceFile("test01")
|
||||||
if (f.toString.contains("\\")) {
|
if (isWindows) {
|
||||||
System.err.println("includeFileNotQuoted test skipped on Windows")
|
System.err.println("includeFileNotQuoted test skipped on Windows")
|
||||||
} else {
|
} else {
|
||||||
val e = intercept[ConfigException.Parse] {
|
val e = intercept[ConfigException.Parse] {
|
||||||
@ -727,7 +724,7 @@ class ConfParserTest extends TestUtils {
|
|||||||
@Test
|
@Test
|
||||||
def includeFileNotQuotedAndSpecialChar() {
|
def includeFileNotQuotedAndSpecialChar() {
|
||||||
val f = resourceFile("test01")
|
val f = resourceFile("test01")
|
||||||
if (f.toString.contains("\\")) {
|
if (isWindows) {
|
||||||
System.err.println("includeFileNotQuoted test skipped on Windows")
|
System.err.println("includeFileNotQuoted test skipped on Windows")
|
||||||
} else {
|
} else {
|
||||||
val e = intercept[ConfigException.Parse] {
|
val e = intercept[ConfigException.Parse] {
|
||||||
|
@ -13,7 +13,6 @@ import com.typesafe.config.ConfigObject
|
|||||||
import com.typesafe.config.ConfigList
|
import com.typesafe.config.ConfigList
|
||||||
import com.typesafe.config.ConfigException
|
import com.typesafe.config.ConfigException
|
||||||
import com.typesafe.config.ConfigValueType
|
import com.typesafe.config.ConfigValueType
|
||||||
import com.typesafe.config.ConfigOrigin
|
|
||||||
import com.typesafe.config.ConfigRenderOptions
|
import com.typesafe.config.ConfigRenderOptions
|
||||||
import com.typesafe.config.ConfigValueFactory
|
import com.typesafe.config.ConfigValueFactory
|
||||||
import com.typesafe.config.ConfigFactory
|
import com.typesafe.config.ConfigFactory
|
||||||
@ -721,7 +720,9 @@ class ConfigValueTest extends TestUtils {
|
|||||||
// the filename is made absolute when converting to url
|
// the filename is made absolute when converting to url
|
||||||
assertTrue(hasFilename.url.toExternalForm.contains("foo"))
|
assertTrue(hasFilename.url.toExternalForm.contains("foo"))
|
||||||
assertNull(noFilename.url)
|
assertNull(noFilename.url)
|
||||||
assertEquals("file:/baz", SimpleConfigOrigin.newFile("/baz").url.toExternalForm)
|
val rootFile = SimpleConfigOrigin.newFile("/baz")
|
||||||
|
val rootFileURL = if (isWindows) s"file:/$userDrive/baz" else "file:/baz"
|
||||||
|
assertEquals(rootFileURL, rootFile.url.toExternalForm)
|
||||||
|
|
||||||
val urlOrigin = SimpleConfigOrigin.newURL(new URL("file:/foo"))
|
val urlOrigin = SimpleConfigOrigin.newURL(new URL("file:/foo"))
|
||||||
assertEquals("/foo", urlOrigin.filename)
|
assertEquals("/foo", urlOrigin.filename)
|
||||||
|
@ -4,12 +4,10 @@
|
|||||||
package com.typesafe.config.impl
|
package com.typesafe.config.impl
|
||||||
|
|
||||||
import org.junit.Assert._
|
import org.junit.Assert._
|
||||||
import org.junit._
|
|
||||||
import com.typesafe.config.ConfigOrigin
|
import com.typesafe.config.ConfigOrigin
|
||||||
import java.io.Reader
|
import java.io.Reader
|
||||||
import java.io.StringReader
|
import java.io.StringReader
|
||||||
import com.typesafe.config.ConfigParseOptions
|
import com.typesafe.config.ConfigParseOptions
|
||||||
import com.typesafe.config.Config
|
|
||||||
import com.typesafe.config.ConfigSyntax
|
import com.typesafe.config.ConfigSyntax
|
||||||
import com.typesafe.config.ConfigFactory
|
import com.typesafe.config.ConfigFactory
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@ -20,6 +18,7 @@ import java.io.ObjectInputStream
|
|||||||
import java.io.NotSerializableException
|
import java.io.NotSerializableException
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
import java.util.Locale
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
import java.util.concurrent.Callable
|
import java.util.concurrent.Callable
|
||||||
import com.typesafe.config._
|
import com.typesafe.config._
|
||||||
@ -712,6 +711,9 @@ abstract trait TestUtils {
|
|||||||
def nodeOptionalSubstitution(expression: Token*) = new ConfigNodeSimpleValue(tokenOptionalSubstitution(expression: _*))
|
def nodeOptionalSubstitution(expression: Token*) = new ConfigNodeSimpleValue(tokenOptionalSubstitution(expression: _*))
|
||||||
def nodeSubstitution(expression: Token*) = new ConfigNodeSimpleValue(tokenSubstitution(expression: _*))
|
def nodeSubstitution(expression: Token*) = new ConfigNodeSimpleValue(tokenSubstitution(expression: _*))
|
||||||
|
|
||||||
|
def isWindows: Boolean = sys.props.get("os.name").exists(_.toLowerCase(Locale.ROOT).contains("windows"))
|
||||||
|
def userDrive: String = if (isWindows) sys.props.get("user.dir").fold("")(_.takeWhile(_ != File.separatorChar)) else ""
|
||||||
|
|
||||||
// this is importantly NOT using Path.newPath, which relies on
|
// this is importantly NOT using Path.newPath, which relies on
|
||||||
// the parser; in the test suite we are often testing the parser,
|
// 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.
|
// so we don't want to use the parser to build the expected result.
|
||||||
|
Loading…
Reference in New Issue
Block a user