stevedlawrence commented on code in PR #1389:
URL: https://github.com/apache/daffodil/pull/1389#discussion_r1890771393


##########
daffodil-tdml-junit/src/main/scala/org/apache/daffodil/junit/tdml/TdmlSuite.scala:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.
+ */
+
+package org.apache.daffodil.junit.tdml
+
+import java.io.File
+
+import org.apache.daffodil.tdml.Runner
+import org.apache.daffodil.tdml.TDMLTestNotCompatibleException
+
+import org.junit.AfterClass
+import org.junit.AssumptionViolatedException
+import org.junit.Rule
+import org.junit.rules.TestName
+
+/**
+ * Mixin for a JUnit test suite companion object
+ */
+trait TdmlSuite {
+
+  /**
+   * Resource path to the TDML file to use for this JUnit suite
+   */
+  val tdmlResource: String
+
+  /**
+   * Function to get the directory containing tdmlResource. Useful if 
createRunner is overridden
+   * to use the Runner(dir, file, ...) factory method
+   */
+  def tdmlDir: String = new File(tdmlResource).getParent()
+
+  /**
+   * Function to get basename of tdmlResource. Useful if createRunner is 
overridden to use the
+   * Runner(dir, file, ...) factory method
+   */
+  def tdmlFile: String = new File(tdmlResource).getName()
+
+  /**
+   * Default implementation to create a Runner using the tdmlResource. This 
function can be
+   * overridden if additional options need to be passed to the Runner factory 
object, for
+   * example to disable TDML validation. In most cases this should not be 
needed, since most
+   * parameters should not be changed by normal schema tests, or can be 
defined in the TDML
+   * file.
+   */
+  def createRunner(): Runner = Runner(tdmlResource)
+
+  /**
+   * Lazily build the runner when needed
+   */
+  final lazy val runner = createRunner()
+
+  /**
+   * Ensure all resources associated with the Runner (e.g. cached compiled 
schemas, parsed TDML
+   * XML) to be freed once the test suite has completed
+   */
+  @AfterClass
+  final def shutDown(): Unit = runner.reset
+}
+
+/**
+ * Mixin for a JUnit test suite companion class
+ */
+trait TdmlTests {

Review Comment:
   So far knownToFail is pretty straightforward to implement. I did find an 
another drackback with it--you can't use it with older versions of the TDML 
runner since it errors if it sees an attribute it doesn't understand. So if we 
do add support for this you can't use it if you want to maintain compatibility 
with older daffodil versions. 
   
   This is probably okay? We can still use it internally for Daffodil tests and 
most DFDL schema projects can probably either be update to the latest version 
of Daffodil, or if they do need to maintain compatibility with older versions 
they can just stick to commenting out tests (or using `@Ignore`).
   
   Though, my biggest concern is still that testing Daffodil with this change 
shows 100+ red "assumption violated" messages, making it look like a lot of 
things are broken, even though we have 4000+ working tests. I imagine that 
noise will also make it hard to more difficult to see actual errors among the 
sea of red messages.
   
   Makes me consider that using @Ignore or just keeping with commenting out is 
the best method.



-- 
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]

Reply via email to