diff --git a/importer/src/test/scala/org/scalablytyped/converter/internal/importer/ImporterHarness.scala b/importer/src/test/scala/org/scalablytyped/converter/internal/importer/ImporterHarness.scala
index 5e0de98084..7628fae22d 100644
--- a/importer/src/test/scala/org/scalablytyped/converter/internal/importer/ImporterHarness.scala
+++ b/importer/src/test/scala/org/scalablytyped/converter/internal/importer/ImporterHarness.scala
@@ -196,11 +196,16 @@ trait ImporterHarness extends AnyFunSuite {
GitLock.synchronized(%("git", "add", checkFolder))
}
- Try(%%("diff", "-Naur", checkFolder, targetFolder)) match {
+ Try(%%("diff", "-NaurwB", checkFolder, targetFolder)) match {
case Success(_) => if (run.update) pending else succeed
case Failure(th: ShelloutException) =>
- val diff = %%("diff", "-r", checkFolder, targetFolder).out.string
- fail(s"Output for test $testFolder was not as expected : $diff", th)
+ try {
+ val diff = %%("diff", "-rwB", checkFolder, targetFolder).out.string
+ fail(s"Output for test $testFolder was not as expected : $diff", th)
+ } catch {
+ // not serializable
+ case th: ShelloutException => sys.error(th.getMessage)
+ }
case Failure(th) => throw th
}
diff --git a/importer/src/test/scala/org/scalablytyped/converter/internal/importer/build/ContentForPublishTest.scala b/importer/src/test/scala/org/scalablytyped/converter/internal/importer/build/ContentForPublishTest.scala
index 7bd8aac3e0..87c46d64bf 100644
--- a/importer/src/test/scala/org/scalablytyped/converter/internal/importer/build/ContentForPublishTest.scala
+++ b/importer/src/test/scala/org/scalablytyped/converter/internal/importer/build/ContentForPublishTest.scala
@@ -75,7 +75,7 @@ class ContentForPublishTest extends AnyFunSuite with Matchers {
- """,
+ """.replace("\r\n", "\n"),
)
}
@@ -126,7 +126,7 @@ class ContentForPublishTest extends AnyFunSuite with Matchers {
externaldepversion
- """,
+ """.replace("\r\n", "\n"),
)
}
}
diff --git a/importer/src/test/scala/org/scalablytyped/converter/internal/ts/parser/CommentTests.scala b/importer/src/test/scala/org/scalablytyped/converter/internal/ts/parser/CommentTests.scala
index da0add3d6d..4344184f85 100644
--- a/importer/src/test/scala/org/scalablytyped/converter/internal/ts/parser/CommentTests.scala
+++ b/importer/src/test/scala/org/scalablytyped/converter/internal/ts/parser/CommentTests.scala
@@ -2,10 +2,11 @@ package org.scalablytyped.converter.internal
package ts
package parser
-import org.scalablytyped.converter.internal.ts.parser.TsLexer.{CommentLineToken, DirectiveToken}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
+import java.io.File
+
final class CommentTests extends AnyFunSuite with Matchers {
import ParserHarness._
@@ -15,7 +16,9 @@ final class CommentTests extends AnyFunSuite with Matchers {
| * Width of the tangible instance, length on the X-axis in 3D.
| */""".stripMargin
shouldParseAs(content, TsParser.lexical.comment)(
- TsParser.lexical.CommentBlockToken(content),
+ TsParser.lexical.CommentBlockToken(
+ content.replace("\r\n", "\n"),
+ ),
)
}
@@ -67,7 +70,7 @@ final class CommentTests extends AnyFunSuite with Matchers {
"""/**
| * A react component that renders a row of the grid
| */
- |""".stripMargin,
+ |""".stripMargin.replace("\r\n", "\n"),
)
value.comments.cs.zip(expecteds.cs).foreach {
@@ -86,35 +89,35 @@ final class CommentTests extends AnyFunSuite with Matchers {
shouldParseAs(
"/// ",
TsParser.lexical.directive,
- )(DirectiveToken("reference", "path", "../bluebird/bluebird-2.0.d.ts"))
+ )(TsLexer.DirectiveToken("reference", "path", "../bluebird/bluebird-2.0.d.ts"))
}
test("directive three") {
shouldParseAs(
"/// ",
TsParser.lexical.directive,
- )(DirectiveToken("reference", "path", "../bluebird/bluebird-2.0.d.ts"))
+ )(TsLexer.DirectiveToken("reference", "path", "../bluebird/bluebird-2.0.d.ts"))
}
test("directive lib") {
shouldParseAs(
"""/// """,
TsParser.lexical.directive,
- )(DirectiveToken("reference", "lib", "dom.iterable"))
+ )(TsLexer.DirectiveToken("reference", "lib", "dom.iterable"))
}
test("directive no-default-lib") {
shouldParseAs(
"""/// """,
TsParser.lexical.directive,
- )(DirectiveToken("reference", "no-default-lib", "true"))
+ )(TsLexer.DirectiveToken("reference", "no-default-lib", "true"))
}
test("amd-module") {
shouldParseAs(
"""/// """,
TsParser.lexical.directive,
- )(DirectiveToken("amd-module", "name", "angular/packages/zone.js/lib/zone"))
+ )(TsLexer.DirectiveToken("amd-module", "name", "angular/packages/zone.js/lib/zone"))
}
test("parameter comments") {
@@ -264,19 +267,19 @@ final class CommentTests extends AnyFunSuite with Matchers {
}
test("handle stray references") {
- withTsFile("parsertests/graphql.d.ts") { content =>
+ withTsFile(s"parsertests${File.separator}graphql.d.ts") { content =>
parseAs(content, TsParser.tsContainerOrDecls)
}
}
test("trailing comments") {
- withTsFile("parsertests/egg.d.ts") { content =>
+ withTsFile(s"parsertests${File.separator}egg.d.ts") { content =>
parseAs(content, TsParser.tsContainerOrDecls)
}
}
test("trailing comments (2)") {
- withTsFile("parsertests/emissary.d.ts") { content =>
+ withTsFile(s"parsertests${File.separator}emissary.d.ts") { content =>
parseAs(content, TsParser.parsedTsFile)
}
}
@@ -295,7 +298,7 @@ final class CommentTests extends AnyFunSuite with Matchers {
}
test("handle trailing comments in block") {
- withTsFile("parsertests/knockout.d.ts") { content =>
+ withTsFile(s"parsertests${File.separator}knockout.d.ts") { content =>
parseAs(content, TsParser.tsContainerOrDecls)
}
}
diff --git a/importer/src/test/scala/org/scalablytyped/converter/internal/ts/parser/ImportExportParseTests.scala b/importer/src/test/scala/org/scalablytyped/converter/internal/ts/parser/ImportExportParseTests.scala
index 6aa364e5ab..1a7e088cef 100644
--- a/importer/src/test/scala/org/scalablytyped/converter/internal/ts/parser/ImportExportParseTests.scala
+++ b/importer/src/test/scala/org/scalablytyped/converter/internal/ts/parser/ImportExportParseTests.scala
@@ -6,6 +6,8 @@ import org.scalablytyped.converter.internal.ts.JsLocation.Zero
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
+import java.io.File
+
final class ImportExportParseTests extends AnyFunSuite with Matchers {
import ParserHarness._
@@ -270,7 +272,7 @@ final class ImportExportParseTests extends AnyFunSuite with Matchers {
}
test("history") {
- withTsFile("parsertests/history.d.ts") { contents: String =>
+ withTsFile(s"parsertests${File.separator}history.d.ts") { contents: String =>
parseAs(contents, TsParser.parsedTsFile)
}
}
diff --git a/importer/src/test/scala/org/scalablytyped/converter/internal/ts/parser/ParserHarness.scala b/importer/src/test/scala/org/scalablytyped/converter/internal/ts/parser/ParserHarness.scala
index b1b86efd48..8bb2b217bf 100644
--- a/importer/src/test/scala/org/scalablytyped/converter/internal/ts/parser/ParserHarness.scala
+++ b/importer/src/test/scala/org/scalablytyped/converter/internal/ts/parser/ParserHarness.scala
@@ -1,9 +1,9 @@
package org.scalablytyped.converter.internal.ts.parser
-import org.scalablytyped.converter.internal.{files, InFile}
import org.scalatest.Assertion
import org.scalatest.matchers.should.Matchers._
+import java.nio.file.{Files, Paths}
import scala.util.parsing.combinator.Parsers
import scala.util.parsing.input.CharSequenceReader
@@ -33,7 +33,7 @@ object ParserHarness {
}
def withTsFile[T](resourceName: String)(f: String => T): T =
- f(files.content(InFile(os.Path(getClass.getResource(s"/$resourceName").getFile))))
+ f(Files.readString(Paths.get(getClass.getResource(s"/$resourceName").toURI)))
def parseAs[T](input: String, parser: String => Parsers#ParseResult[T]): T =
parser(input).force
diff --git a/importer/src/test/scala/org/scalablytyped/converter/internal/ts/parser/ParserTests.scala b/importer/src/test/scala/org/scalablytyped/converter/internal/ts/parser/ParserTests.scala
index f20b53bf4a..1bd26f5ace 100644
--- a/importer/src/test/scala/org/scalablytyped/converter/internal/ts/parser/ParserTests.scala
+++ b/importer/src/test/scala/org/scalablytyped/converter/internal/ts/parser/ParserTests.scala
@@ -7,13 +7,15 @@ import org.scalablytyped.converter.internal.ts.OptionalModifier.Noop
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers._
+import java.io.File
+
final class ParserTests extends AnyFunSuite {
private val T = TsTypeRef(NoComments, TsQIdent(IArray(TsIdentSimple("T"))), Empty)
import ParserHarness._
test("whole file") {
- withTsFile("parsertests/path-case.d.ts") { content =>
+ withTsFile(s"parsertests${File.separator}path-case.d.ts") { content =>
val expected =
TsParsedFile(
NoComments,
@@ -67,13 +69,13 @@ final class ParserTests extends AnyFunSuite {
}
test("handle byte order mark") {
- withTsFile("parsertests/adm-zip.d.ts") { content =>
+ withTsFile(s"parsertests${File.separator}adm-zip.d.ts") { content =>
parseAs(content, TsParser.tsContainerOrDecls)
}
}
test("CR line endings") {
- withTsFile("parsertests/mathfield.d.ts") { content =>
+ withTsFile(s"parsertests${File.separator}mathfield.d.ts") { content =>
parseAs(content, TsParser.parsedTsFile)
}
}
@@ -96,7 +98,7 @@ final class ParserTests extends AnyFunSuite {
}
test("windows line separators and mixed newlines/whitespace") {
- withTsFile("parsertests/adal.d.ts") { content =>
+ withTsFile(s"parsertests${File.separator}adal.d.ts") { content =>
parseAs(content, TsParser.parsedTsFile)
}
}