Skip to content

Commit e29b862

Browse files
authored
chore: sync more tests and support ignoring (#614)
Motivation: Some tests are not suitable for sjsonnet, eg, error.std_parseYaml1.jsonnet in google/jsonnet#1292
1 parent bc67e65 commit e29b862

13 files changed

Lines changed: 196 additions & 69 deletions

File tree

build.mill

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ object sjsonnet extends VersionFileModule {
158158

159159
def mvnDeps = super.mvnDeps() ++
160160
Seq(
161-
mvn"org.virtuslab::scala-yaml::0.3.0"
161+
mvn"org.virtuslab::scala-yaml::0.3.1"
162162
)
163163

164164
def nodeJsArgs: List[String] = List("--stack-size=" + stackSizekBytes)
@@ -265,7 +265,7 @@ object sjsonnet extends VersionFileModule {
265265
def mvnDeps = super.mvnDeps() ++
266266
Seq(
267267
mvn"com.github.lolgab::scala-native-crypto::0.3.0",
268-
mvn"org.virtuslab::scala-yaml::0.3.0"
268+
mvn"org.virtuslab::scala-yaml::0.3.1"
269269
)
270270

271271
def releaseMode = ReleaseMode.ReleaseFull
@@ -301,7 +301,7 @@ object sjsonnet extends VersionFileModule {
301301
def mvnDeps = super.mvnDeps() ++ Seq(
302302
mvn"org.tukaani:xz::1.11",
303303
mvn"at.yawk.lz4:lz4-java::1.10.3",
304-
mvn"org.yaml:snakeyaml::2.4",
304+
mvn"org.yaml:snakeyaml::2.6",
305305
mvn"com.google.re2j:re2j:1.8"
306306
)
307307

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ lazy val main = (project in file("sjsonnet"))
2727
"at.yawk.lz4" % "lz4-java" % "1.10.3",
2828
"org.scala-lang.modules" %% "scala-collection-compat" % "2.14.0",
2929
"org.tukaani" % "xz" % "1.11",
30-
"org.yaml" % "snakeyaml" % "2.5",
30+
"org.yaml" % "snakeyaml" % "2.6",
3131
"com.google.re2j" % "re2j" % "1.8"
3232
),
3333
libraryDependencies ++= Seq(

sjsonnet/src-js/sjsonnet/Platform.scala

Lines changed: 55 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,69 @@ object Platform {
4242
Error.fail("Unsupported YAML node type: " + node.getClass.getSimpleName)
4343
}
4444

45-
private val docSplitPattern = Pattern.compile("(^|\n)---\\s*(\n|$)")
46-
4745
def yamlToJson(s: String): ujson.Value = {
48-
val docs = docSplitPattern.split(s, -1)
49-
docs.size match {
46+
// Split YAML multi-document stream manually, similar to SnakeYAML's loadAll
47+
// since parseManyYamls doesn't handle all cases correctly
48+
val documents = splitYamlDocuments(s)
49+
50+
documents.size match {
5051
case 0 => ujson.Null
51-
case 1 =>
52-
docs.head.asNode match {
53-
case Right(n) =>
54-
nodeToJson(n)
55-
case Left(e) if docs.head.trim.isEmpty =>
56-
ujson.Null
57-
case Left(e) =>
58-
Error.fail("Error converting YAML to JSON: " + e.getMessage)
59-
}
52+
case 1 => parseSingleDocument(documents.head)
6053
case _ =>
61-
val buf = new mutable.ArrayBuffer[ujson.Value](docs.size)
62-
for (doc <- docs) {
63-
doc.asNode match {
64-
case Right(n) => buf += nodeToJson(n)
65-
case Left(e) if docs.head.trim.isEmpty =>
66-
case Left(e) =>
67-
Error.fail("Error converting YAML to JSON: " + e.getMessage)
68-
}
54+
val buf = new mutable.ArrayBuffer[ujson.Value](documents.size)
55+
for (doc <- documents) {
56+
buf += parseSingleDocument(doc)
6957
}
7058
ujson.Arr(buf)
7159
}
7260
}
7361

62+
private def splitYamlDocuments(s: String): List[String] = {
63+
if (s.trim.isEmpty) return Nil
64+
65+
// Split on document separator "---" at line start
66+
// But only if it's followed by whitespace or end of line
67+
val lines = s.split("\n", -1).toList
68+
val documents = mutable.ArrayBuffer[String]()
69+
val currentDoc = mutable.ArrayBuffer[String]()
70+
var isFirstDoc = true
71+
72+
for (line <- lines) {
73+
val trimmed = line.trim
74+
// Check if this line starts with "---" and is followed by whitespace or end
75+
if (trimmed.startsWith("---") && (trimmed.length == 3 || trimmed.charAt(3).isWhitespace)) {
76+
// Save previous document if not empty
77+
if (currentDoc.nonEmpty || !isFirstDoc) {
78+
documents += currentDoc.mkString("\n")
79+
}
80+
currentDoc.clear()
81+
isFirstDoc = false
82+
} else {
83+
currentDoc += line
84+
}
85+
}
86+
87+
// Add last document
88+
if (currentDoc.nonEmpty || documents.nonEmpty) {
89+
documents += currentDoc.mkString("\n")
90+
}
91+
92+
documents.toList
93+
}
94+
95+
private def parseSingleDocument(doc: String): ujson.Value = {
96+
val trimmed = doc.trim
97+
if (trimmed.isEmpty) {
98+
ujson.Null
99+
} else {
100+
// Use parseYaml for single document
101+
parseYaml(trimmed) match {
102+
case Right(node) => nodeToJson(node)
103+
case Left(e) => Error.fail("Error converting YAML to JSON: " + e.getMessage)
104+
}
105+
}
106+
}
107+
74108
def md5(s: String): String = {
75109
throw new Exception("MD5 not implemented in Scala.js")
76110
}

sjsonnet/src-native/sjsonnet/Platform.scala

Lines changed: 55 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,35 +77,69 @@ object Platform {
7777
Error.fail("Unsupported YAML node type: " + node.getClass.getSimpleName)
7878
}
7979

80-
private val docSplitPattern = Pattern.compile("(?m)^---\\s*$")
81-
8280
def yamlToJson(s: String): ujson.Value = {
83-
val docs = docSplitPattern.split(s, -1)
84-
docs.length match {
81+
// Split YAML multi-document stream manually, similar to SnakeYAML's loadAll
82+
// since parseManyYamls doesn't handle all cases correctly
83+
val documents = splitYamlDocuments(s)
84+
85+
documents.size match {
8586
case 0 => ujson.Null
86-
case 1 =>
87-
docs.head.asNode match {
88-
case Right(n) =>
89-
nodeToJson(n)
90-
case Left(e) if docs.head.trim.isEmpty =>
91-
ujson.Null
92-
case Left(e) =>
93-
Error.fail("Error converting YAML to JSON: " + e.getMessage)
94-
}
87+
case 1 => parseSingleDocument(documents.head)
9588
case _ =>
96-
val buf = new mutable.ArrayBuffer[ujson.Value](docs.length)
97-
for (doc <- docs) {
98-
doc.asNode match {
99-
case Right(n) => buf += nodeToJson(n)
100-
case Left(e) if doc.isEmpty =>
101-
case Left(e) =>
102-
Error.fail("Error converting YAML to JSON: " + e.getMessage)
103-
}
89+
val buf = new mutable.ArrayBuffer[ujson.Value](documents.size)
90+
for (doc <- documents) {
91+
buf += parseSingleDocument(doc)
10492
}
10593
ujson.Arr(buf)
10694
}
10795
}
10896

97+
private def splitYamlDocuments(s: String): List[String] = {
98+
if (s.trim.isEmpty) return Nil
99+
100+
// Split on document separator "---" at line start
101+
// But only if it's followed by whitespace or end of line
102+
val lines = s.split("\n", -1).toList
103+
val documents = mutable.ArrayBuffer[String]()
104+
val currentDoc = mutable.ArrayBuffer[String]()
105+
var isFirstDoc = true
106+
107+
for (line <- lines) {
108+
val trimmed = line.trim
109+
// Check if this line starts with "---" and is followed by whitespace or end
110+
if (trimmed.startsWith("---") && (trimmed.length == 3 || trimmed.charAt(3).isWhitespace)) {
111+
// Save previous document if not empty
112+
if (currentDoc.nonEmpty || !isFirstDoc) {
113+
documents += currentDoc.mkString("\n")
114+
}
115+
currentDoc.clear()
116+
isFirstDoc = false
117+
} else {
118+
currentDoc += line
119+
}
120+
}
121+
122+
// Add last document
123+
if (currentDoc.nonEmpty || documents.nonEmpty) {
124+
documents += currentDoc.mkString("\n")
125+
}
126+
127+
documents.toList
128+
}
129+
130+
private def parseSingleDocument(doc: String): ujson.Value = {
131+
val trimmed = doc.trim
132+
if (trimmed.isEmpty) {
133+
ujson.Null
134+
} else {
135+
// Use parseYaml for single document
136+
parseYaml(trimmed) match {
137+
case Right(node) => nodeToJson(node)
138+
case Left(e) => Error.fail("Error converting YAML to JSON: " + e.getMessage)
139+
}
140+
}
141+
}
142+
109143
private def computeHash(algorithm: String, s: String) = {
110144
java.security.MessageDigest
111145
.getInstance(algorithm)

sjsonnet/src/sjsonnet/Importer.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ class CachedResolver(
225225
case e: ParseError if e.offset >= 0 =>
226226
val pos = new Position(new FileScope(path), e.offset)
227227
Left(new ParseError(e.getMessage).addFrame(pos))
228+
case e: ParseError =>
229+
Left(e)
228230
}
229231
parsed.flatMap { case (e, fs) => process(e, fs) }
230232
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Files to ignore when syncing from google/go-jsonnet (Go test suite).
2+
# One .jsonnet filename per line. Lines starting with '#' are comments.
3+
# Corresponding .golden files are also automatically ignored.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Files to ignore when syncing from google/jsonnet (C++ test suite).
2+
# One .jsonnet filename per line. Lines starting with '#' are comments.
3+
# Corresponding .golden files are also automatically ignored.
4+
#
5+
# error.std_parseYaml1.jsonnet: sjsonnet uses SnakeYAML/scala-yaml which
6+
# successfully parses 'a: b:' as {"a":"b:"}, unlike RapidYAML which errors.
7+
error.std_parseYaml1.jsonnet
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[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]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sjsonnet.ParseError: Parsing exceeded maximum recursion depth of 1000

sjsonnet/test/resources/test_suite/stdlib.jsonnet

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,8 @@ std.assertEqual(std.parseJson('{"a": {"b": ["c", 42]}}'), { a: { b: ['c', 42] }
14811481
// Empty input evaluates to `null`.
14821482
// Regression test for https://github.com/google/jsonnet/issues/1270
14831483
std.assertEqual(std.parseYaml(' \n'), null) &&
1484+
// Stream input, regression test for https://github.com/google/jsonnet/issues/1148
1485+
std.assertEqual(std.parseYaml('1\n---'), [1, null]) &&
14841486
std.assertEqual(std.parseYaml('{}'), {}) &&
14851487
std.assertEqual(std.parseYaml('[]'), []) &&
14861488
std.assertEqual(

0 commit comments

Comments
 (0)