stevedlawrence commented on code in PR #1185: URL: https://github.com/apache/daffodil/pull/1185#discussion_r1526537891
########## daffodil-test/src/test/resources/org/apache/daffodil/section00/general/tunables.tdml: ########## @@ -811,4 +832,78 @@ </tdml:unparserTestCase> + <tdml:defineSchema name="intPatternRestriction"> + <xs:include schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd" /> + + <dfdl:format ref="ex:GeneralFormat" lengthKind="delimited" /> + + <xs:element name="int"> + <xs:simpleType> + <xs:restriction base="xs:int"> + <xs:pattern value=".*[05]" /> <!-- must be a multiple of 5 --> + </xs:restriction> + </xs:simpleType> + </xs:element> + + </tdml:defineSchema> + + <tdml:parserTestCase + name="invalidRestrictionPolicyError_01" root="int" + model="intPatternRestriction" + config="cfg_invalidRestrictionPolicyError" + validation="limited"> + <tdml:document>201</tdml:document> + <tdml:errors> + <tdml:error>Schema Definition Error</tdml:error> + <tdml:error>Pattern restriction</tdml:error> + <tdml:error>string</tdml:error> + </tdml:errors> + </tdml:parserTestCase> + + <tdml:parserTestCase + name="invalidRestrictionPolicyIgnore_01" root="int" + model="intPatternRestriction" + config="cfg_invalidRestrictionPolicyIgnore" + validation="limited"> + <tdml:document>201</tdml:document> + <tdml:infoset> + <tdml:dfdlInfoset> + <ex:int>201</ex:int> + </tdml:dfdlInfoset> + </tdml:infoset> + <tdml:validationErrors /> <!-- there should be no validation errors --> Review Comment: If a test case does not have a `<tdml:validationErrors>` element, then validation errors created by the test are ignored. Validation errors created by the test have no affect on the success/failure of the test. If a test case has a `<tdml:validationErrors>` element and that element has `<tdml:error>` children, then the test *must* create validation errors and each of the `<tdml:error>` strings *must* appear in those messages. If any do not, the test fails. If a test case has a `<tdml:validationErrors>` element but that element does not have children, then the test case *must not* create validation errors. If there are any validation errors the test fails. In each of these cases, the infoset must still match the expected infoset or the test is a failure, regardless of any validation errors. So this test technically doesn't need an empty `<tdml:validationErrors />` element to pass. But it does ensure that we are correctly ignoring the pattern restriction and not trying to validate anything. Without it, things could be broken and we could still be validating but not know it (in fact, my first change was broken and wasn't ignoring things and this test caught it). I'll update to the comment as suggested. > Also, if you changed the config to validate the pattern and removed line 874 checking there are no validation errors, would the "daffodil test" command print the validation errors in its test output, or would you never know that the test passed despite producing validation errors? I believe the behavior of "sbt test" and the CLI "daffodil test" is to hide all output unless something fails. So if there were validation errors but no `<tdml:validationErrors />` element in the test case, then the validation error woudl be ignored, the test would be considered a success, and you would never know. I think enabling verbose test output does output the validation errors even on success, so it's not completely hidden, but you do need to do something special to see it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
