def run()

in daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala [910:996]


  def run(): Unit = {
    val suppliedSchema = getSuppliedSchema()

    var impl: AbstractTDMLDFDLProcessorFactory = parent.tdmlDFDLProcessorFactory
    val implString = Some(impl.implementationName)
    //
    // Should we run the test?
    //
    val implName = impl.implementationName
    val istrings = implementationStrings
    val useThisImpl = istrings.contains(implName)
    if (!useThisImpl) {
      // throws an exception marking a test as not compatible
      testNotCompatible(this.tcName, implString)
    } else {
      // run the test.

      impl = impl
        .withValidateDFDLSchemas(parent.validateDFDLSchemas)
        .withTunables(tunables)
        .withCheckAllTopLevel(parent.checkAllTopLevel)

      val optInputOrExpectedData = document.map {
        _.data
      }
      val nBits: Option[Long] = document.map {
        _.nBits
      }

      val useSerializedProcessor =
        if (validationMode == ValidationMode.Full) false
        else if (defaultValidationMode == ValidationMode.Full) false
        else if (optExpectedWarnings.isDefined) false
        else true

      val rootNamespaceString = getRootNamespaceString()

      val compileResult: TDML.CompileResult = parent.getCompileResult(
        impl,
        suppliedSchema,
        useSerializedProcessor,
        Option(rootName),
        Option(rootNamespaceString),
        tunables
      )

      val newCompileResult: TDML.CompileResult = compileResult.map {
        case (diags, proc: TDMLDFDLProcessor) =>
          // warnings are checked elsewhere for expected ones.
          val newProc: TDMLDFDLProcessor =
            proc.withDebugging(parent.areDebugging).withTracing(parent.areTracing)
          val newNewProc =
            if (
              parent.areDebugging &&
              (parent.daffodilDebugger ne null)
            ) {
              newProc.withDebugger(parent.daffodilDebugger)
            } else {
              newProc
            }
          (diags, newNewProc)
      }
      try {
        runProcessor(
          newCompileResult,
          optInputOrExpectedData,
          nBits,
          optExpectedErrors,
          optExpectedWarnings,
          optExpectedValidationErrors,
          validationMode,
          roundTrip,
          implString
        )
      } finally {
        // runProcessor may have set the "processor" variable to the DataProcessor used for the
        // test. This variable only exists as an easy way to avoid having to pass the
        // DataProcessor around to a bunch of functions. At this point this TestCase is done
        // with the DataProcessor, so we set it to null so it can be garbage collected if
        // nothing else uses it. This is common if a test case calls withXYZ to create a
        // temporary copy of a cached DataProcessor but with different variables, tunables,
        // validation mode, etc. used only for this specific test. This is especially important
        // if a DataProcessor stores any large information like a Xerces validator.
        processor = null
      }
    }
  }