mbeckerle commented on a change in pull request #430:
URL: https://github.com/apache/incubator-daffodil/pull/430#discussion_r500584775



##########
File path: 
daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/RunnerFactory.scala
##########
@@ -21,69 +21,94 @@ import org.apache.daffodil.util.Misc
 import org.apache.daffodil.exceptions.Assert
 
 /**
- * Creates the DFDLTestSuite object lazily, so the file isn't read into memory
- * and parsed unless you actually try to run a test using it.
- *
- * Creates the DFDLTestSuite only once.
- *
- * Provides a reset method to be called from @AfterClass to drop
- * the test suite object (and avoid memory leak).
- *
- * Note: I have verified that this does get called after each test suite has 
been run.
- *
- * defaultRoundTripDefault if true the round trip default for the test suite 
will be
- * this value, if the test suite does not specify defaultRoundTrip attribute.
- *
- * defaultRoundTripDefaultDefault
+ * A wrapper to contain the optional parameters that can be used by the Runner
+ * class, so that they don't need to be redefined in multiple constructors,
+ * and can be easily defaulted by calling functions
  */
-object Runner {
-  def apply(dir: String, file: String,
-    validateTDMLFile: Boolean = true,
+
+object RunnerOpts {
+  def apply(validateTDMLFile: Boolean = true,
     validateDFDLSchemas: Boolean = true,
     compileAllTopLevel: Boolean = false,
-    defaultRoundTripDefault: RoundTrip = defaultRoundTripDefaultDefault,
-    defaultValidationDefault: String = defaultValidationDefaultDefault,
-    defaultImplementationsDefault: Seq[String] = 
defaultImplementationsDefaultDefault): Runner =
-    new Runner(elem = null, dir, file, validateTDMLFile, validateDFDLSchemas, 
compileAllTopLevel,
-      defaultRoundTripDefault, defaultValidationDefault, 
defaultImplementationsDefault)
-
-  def apply(elem: scala.xml.Elem): Runner =
-    new Runner(elem, dir = null, file = null)
-
-  def apply(elem: scala.xml.Elem, validateTDMLFile: Boolean): Runner =
-    new Runner(elem, dir = null, file = null, validateTDMLFile)
+    defaultRoundTripDefault: RoundTrip = 
RunnerOpts.defaultRoundTripDefaultDefault,
+    defaultValidationDefault: String = 
RunnerOpts.defaultValidationDefaultDefault,
+    defaultImplementationsDefault: Seq[String] = 
RunnerOpts.defaultImplementationsDefaultDefault,
+    shouldDoErrorComparisonOnCrossTests: Boolean = 
RunnerOpts.defaultShouldDoErrorComparisonOnCrossTests,
+    shouldDoWarningComparisonOnCrossTests: Boolean = 
RunnerOpts.defaultShouldDoWarningComparisonOnCrossTests): RunnerOpts = 
+      new RunnerOpts(validateTDMLFile, validateDFDLSchemas, 
compileAllTopLevel, 
+        defaultRoundTripDefault, defaultValidationDefault, 
defaultImplementationsDefault, 
+        shouldDoErrorComparisonOnCrossTests, 
shouldDoWarningComparisonOnCrossTests)
 
-  // Yes, that's a lot of defaults.....
-  // but really it is 3-tiers deep:
-  // roundTrip - on test case
-  // defaultRoundTrip - on test suite
-  // defaultRoundTripDefault - on runner aka test suite factory
-  // defaultRoundTripDefaultDefault - on runner factory
-  //
   def defaultRoundTripDefaultDefault: RoundTrip = NoRoundTrip
-  def defaultValidationDefaultDefault = "off"
+  def defaultValidationDefaultDefault: String = "off"
 
   /**
    * Default for what DFDL implementations to run tests against.
    *
    * A test or test suite can override this to specify more or different 
implementations
    * that the test should pass for.
    */
-  def defaultImplementationsDefaultDefault = Seq("daffodil", "ibm")
+  def defaultImplementationsDefaultDefault: Seq[String] = Seq("daffodil", 
"ibm")
 
   /**
    * By default we don't run Daffodil negative TDML tests against 
cross-testers.
    * The error messages are simply too varied.
    *
    * Negative tests must fail, but error messages aren't compared.
    */
-  def defaultShouldDoErrorComparisonOnCrossTests = false
+   def defaultShouldDoErrorComparisonOnCrossTests: Boolean = false
 
   /**
    * By default we don't cross test warning messages because they are too 
varied.
    */
-  def defaultShouldDoWarningComparisonOnCrossTests = false
+  val defaultShouldDoWarningComparisonOnCrossTests: Boolean = false
+}
 
+class RunnerOpts(
+  var validateTDMLFile: Boolean = true,
+  var validateDFDLSchemas: Boolean = true,
+  var compileAllTopLevel: Boolean = false,
+  var defaultRoundTripDefault: RoundTrip,
+  var defaultValidationDefault: String,
+  var defaultImplementationsDefault: Seq[String],
+  var shouldDoErrorComparisonOnCrossTests: Boolean,
+  var shouldDoWarningComparisonOnCrossTests: Boolean) {
+  // Yes, that's a lot of defaults.....
+  // but really it is 3-tiers deep:
+  // roundTrip - on test case
+  // defaultRoundTrip - on test suite
+  // defaultRoundTripDefault - on runner aka test suite factory
+  // defaultRoundTripDefaultDefault - on runner factory
+}
+
+/**
+ * Creates the DFDLTestSuite object lazily, so the file isn't read into memory
+ * and parsed unless you actually try to run a test using it.
+ *
+ * Creates the DFDLTestSuite only once.
+ *
+ * Provides a reset method to be called from @AfterClass to drop
+ * the test suite object (and avoid memory leak).
+ *
+ * Note: I have verified that this does get called after each test suite has 
been run.
+ *
+ * defaultRoundTripDefault if true the round trip default for the test suite 
will be
+ * this value, if the test suite does not specify defaultRoundTrip attribute.
+ *
+ * defaultRoundTripDefaultDefault
+ */
+object Runner {
+  def apply(dir: String, file: String): Runner =
+    new Runner(dir, file, RunnerOpts())
+
+  def apply(dir: String, file: String, options: RunnerOpts): Runner =
+    new Runner(dir, file, options)
+
+  def apply(elem: scala.xml.Elem): Runner =
+    new Runner(elem, RunnerOpts())
+
+  def apply(elem: scala.xml.Elem, options: RunnerOpts): Runner =
+    new Runner(elem, options)
 }

Review comment:
       I would second this. We need the original Runner factory method, as 
there are dozens of DFDL schemas we know of, and possibly others we don't know 
of or have access to, which are using the existing Runner factory. 




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to