This is an automated email from the ASF dual-hosted git repository.
olabusayo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil.git
The following commit(s) were added to refs/heads/main by this push:
new 4fe36eb30 Throw TDMLException if Test has neither tdml:infoset nor
tdml:errors
4fe36eb30 is described below
commit 4fe36eb30a1d57c02edd973e199378051a32d6e7
Author: olabusayoT <[email protected]>
AuthorDate: Tue Apr 2 15:38:26 2024 -0400
Throw TDMLException if Test has neither tdml:infoset nor tdml:errors
- change Some None, None Some message to something more clear
- attempts to change the tdml.xsd proved tricky since the error produced
wasn't specific to only infoset/errors
DAFFODIL-2104
---
.../org/apache/daffodil/tdml/TDMLRunner.scala | 7 ++++--
.../daffodil/processor/tdml/TestTDMLRunner.scala | 27 ++++++++++++++++++++++
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git
a/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
b/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
index 5a6c2a1a0..33b4b11e2 100644
--- a/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
+++ b/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
@@ -1043,8 +1043,11 @@ case class ParserTestCase(ptc: NodeSeq, parentArg:
DFDLTestSuite)
}
}
}
-
- case _ => Assert.invariantFailed("Should be Some None, or None Some
only.")
+ case _ =>
+ throw TDMLException(
+ "Either tdml:infoset or tdml:errors must be present in the test.",
+ implString,
+ )
}
}
diff --git
a/daffodil-tdml-processor/src/test/scala/org/apache/daffodil/processor/tdml/TestTDMLRunner.scala
b/daffodil-tdml-processor/src/test/scala/org/apache/daffodil/processor/tdml/TestTDMLRunner.scala
index 293bf80d3..a21854785 100644
---
a/daffodil-tdml-processor/src/test/scala/org/apache/daffodil/processor/tdml/TestTDMLRunner.scala
+++
b/daffodil-tdml-processor/src/test/scala/org/apache/daffodil/processor/tdml/TestTDMLRunner.scala
@@ -1034,4 +1034,31 @@ f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff
runner.reset()
assertTrue(exc.getMessage.contains("only compatible with Daffodil
300.400.500"))
}
+
+ @Test def testMissingErrorAndInfosetForParserTestCase(): Unit = {
+ val testSuite =
+ <tdml:testSuite suiteName="theSuiteName"
+ xmlns:tns={tns}
+ xmlns:tdml={tdml}
+ xmlns:dfdl={dfdl}
+ xmlns:xsd={xsd}
+ xmlns:xs={xsd}
+ xmlns:xsi={xsi}>
+ <tdml:defineSchema name="mySchema">
+ <xs:include
schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
+ <dfdl:format ref="tns:GeneralFormat"/>
+ <xsd:element name="data" type="xs:int" dfdl:lengthKind="explicit"
dfdl:length="2"/>
+ </tdml:defineSchema>
+ <parserTestCase xmlns={tdml} name="testCase" root="data"
model="mySchema">
+ <document>25</document>
+ </parserTestCase>
+ </tdml:testSuite>
+ val runner = new Runner(testSuite)
+ val exc = intercept[TDMLException] {
+ runner.runOneTest("testCase")
+ }
+ runner.reset()
+ assertTrue(exc.getMessage.contains("Either tdml:infoset or tdml:error"))
+ assertTrue(exc.getMessage.contains("must be present in the test"))
+ }
}