tuxji commented on code in PR #19: URL: https://github.com/apache/daffodil-sbt/pull/19#discussion_r1559339465
########## src/sbt-test/sbt-daffodil/tdml-saved-parser-01/test.script: ########## @@ -0,0 +1,29 @@ +## Licensed to the Apache Software Foundation (ASF) under one +## or more contributor license agreements. See the NOTICE file +## distributed with this work for additional information +## regarding copyright ownership. The ASF licenses this file +## to you under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in compliance +## with the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, +## software distributed under the License is distributed on an +## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +## KIND, either express or implied. See the License for the +## specific language governing permissions and limitations +## under the License. +## + +> packageDaffodilBin +$ exists target/test-0.1-daffodil350.bin +$ exists target/test-0.1-daffodil360.bin +$ exists target/test-0.1-two-daffodil350.bin +$ exists target/test-0.1-two-daffodil360.bin + +> Test/dependencyClasspath +$ must-mirror target/tdmlparsers/test.bin target/test-0.1-daffodil360.bin +$ must-mirror target/tdmlparsers/test-two.bin target/test-0.1-two-daffodil360.bin + +> test Review Comment: I was puzzled by this file, then I noticed daffodil-sbt has other test.script files, I looked at them, and I realized these files help test the daffodil-sbt plugin using a scripted test framework built into sbtPlugin itself. ########## README.md: ########## @@ -94,6 +94,32 @@ If used, one may want to use the first value of this setting to configure daffodilVersion := daffodilPackageBinVersions.value.head ``` +### Saved Parsers in TDML Tests + +For schemas that take a long time to compile, it is often convenient to use a +saved parser created by the `packageDaffodilBin` task in TDML tests. If this +is the case, set the following: + +```scala +daffodilTdmlUsesPackageBin := true +``` + +When set to `true` , running `sbt test` automatically triggers +`packageDaffodilBin` and puts the resulting saved parsers on the classpath so +that TDML files can reference them. Note that when referencing saved parsers +from a TDML file, version numbers and `daffodilXYZ` are excluded--this way TDML +files do not need to be updated when a version is changed. For example, a TDML +file using a saved parser created at `target/format-1.0-file-daffodil350.bin` +is referenced like this: + +```xml +<parserTestCase ... model="/format-file.bin"> +``` + +Note that only saved parsers for `daffodilVersion` can be referenced. For this +reason, `daffodilVersion` must also be defined in `daffodilPackageBinVersions` +if `daffodilTdmlUsesPackageBin` is `true`. + ## Layers and User Defined Functions If your schema project builds a Daffodil layer or user defined function, then Review Comment: I wasn't aware of the scripted test framework provided by sbtPlugin before I saw this PR. I had to google to find the documentation describing it here: <https://www.scala-sbt.org/release/docs/Testing-sbt-plugins.html>. Can we add a "Tests" section to the end of this README which briefly mentions this plugin has several scripted tests, mentions what command ("sbt test", right?) runs these script tests, and points programmers to that documentation page for further details? -- 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]
