tuxji commented on code in PR #1185: URL: https://github.com/apache/daffodil/pull/1185#discussion_r1526450719
########## 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" Review Comment: Just a note for reviewers that the `root` attribute is redundant (and can be omitted) if the `model` schema has only one root element or you want to use its first root element. ########## 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: Very interesting. I have a mental picture of how TDML tests work expecting that you have to match the exit status, tdml errors, and tdml validation errors correctly for the test to pass and the test would fail if it produced validation errors without a match expecting them. If my mental picture is wrong and we really need line 874, please change the comment to `make sure there are no validation errors` to be clear that the line is needed to complete the test. Otherwise, please leave the comment `there should be no validation errors` but strip out `<tdml:validationErrors \>` in the same line if it's not needed. 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? ########## 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 --> + </tdml:parserTestCase> + + <tdml:parserTestCase + name="invalidRestrictionPolicyValidate_01" root="int" + model="intPatternRestriction" + config="cfg_invalidRestrictionPolicyValidate" + validation="limited"> + <tdml:document>201</tdml:document> + <tdml:infoset> + <tdml:dfdlInfoset> + <ex:int>201</ex:int> + </tdml:dfdlInfoset> + </tdml:infoset> + <tdml:validationErrors> + <tdml:error>failed facet checks</tdml:error> + <tdml:error>pattern</tdml:error> + <tdml:error>.*[05]</tdml:error> + </tdml:validationErrors> + </tdml:parserTestCase> + + <tdml:parserTestCase + name="invalidRestrictionPolicyValidate_02" root="int" + model="intPatternRestriction" + config="cfg_invalidRestrictionPolicyValidate" + validation="limited"> + <tdml:document>200</tdml:document> + <tdml:infoset> + <tdml:dfdlInfoset> + <ex:int>200</ex:int> + </tdml:dfdlInfoset> + </tdml:infoset> + <tdml:validationErrors /> <!-- there should be no validation errors --> Review Comment: Same thoughts here. ########## 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 --> + </tdml:parserTestCase> + + <tdml:parserTestCase + name="invalidRestrictionPolicyValidate_01" root="int" + model="intPatternRestriction" + config="cfg_invalidRestrictionPolicyValidate" + validation="limited"> + <tdml:document>201</tdml:document> + <tdml:infoset> + <tdml:dfdlInfoset> + <ex:int>201</ex:int> + </tdml:dfdlInfoset> + </tdml:infoset> + <tdml:validationErrors> + <tdml:error>failed facet checks</tdml:error> + <tdml:error>pattern</tdml:error> + <tdml:error>.*[05]</tdml:error> + </tdml:validationErrors> Review Comment: Actually, if you need to double check whether it is necessary to match validation errors, this test is easier to edit than any of the other tests. The only change you need is to comment out lines 888 to 892 and check if the test still passes (and whether you see any of the validation messages in the test's output). -- 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]
