stevedlawrence commented on a change in pull request #129: Cross Testing
Capability with IBM DFDL
URL: https://github.com/apache/incubator-daffodil/pull/129#discussion_r229685676
##########
File path:
daffodil-tdml/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
##########
@@ -682,87 +774,64 @@ case class ParserTestCase(ptc: NodeSeq, parentArg:
DFDLTestSuite)
lazy val optExpectedInfoset = this.optExpectedOrInputInfoset
- override def runProcessor(schemaSource: DaffodilSchemaSource,
+ override def runProcessor(compileResult: TDML.CompileResult,
optDataToParse: Option[InputStream],
optLengthLimitInBits: Option[Long],
- optErrors: Option[ExpectedErrors],
- optWarnings: Option[ExpectedWarnings],
- optValidationErrors: Option[ExpectedValidationErrors],
+ optExpectedErrors: Option[ExpectedErrors],
+ optExpectedWarnings: Option[ExpectedWarnings],
+ optExpectedValidationErrors: Option[ExpectedValidationErrors],
validationMode: ValidationMode.Type,
roundTrip: RoundTrip,
tracer: Option[Debugger]) = {
- val useSerializedProcessor =
- if (validationMode == ValidationMode.Full) false
- else if (optWarnings.isDefined) false
- else true
+
val nBits = optLengthLimitInBits.get
val dataToParse = optDataToParse.get
- val processor = getProcessor(schemaSource, useSerializedProcessor)
- processor.right.foreach {
- case (warnings, proc) =>
- //
- // Print out the warnings
- // (JIRA DFDL-1583 is implementation of expected warnings checking.)
- //
- warnings.foreach { System.err.println(_) }
-
- setupDebugOrTrace(proc)
- }
-
- (optExpectedInfoset, optErrors) match {
- case (Some(infoset), None) => {
- processor.left.foreach { diags => throw new TDMLException(diags) }
- processor.right.foreach {
- case (warnings, processor) =>
- runParseExpectSuccess(processor, dataToParse, nBits, optWarnings,
optValidationErrors, validationMode, roundTrip)
+ (optExpectedInfoset, optExpectedErrors) match {
+ case (Some(_), None) => {
+ compileResult.left.foreach { diags => throw new TDMLException(diags) }
+ compileResult.right.foreach {
+ case (_, processor) =>
+ runParseExpectSuccess(processor, dataToParse, nBits,
optExpectedWarnings, optExpectedValidationErrors, validationMode, roundTrip)
}
}
- case (None, Some(errors)) => {
- processor.left.foreach { diags =>
- VerifyTestCase.verifyAllDiagnosticsFound(diags, Some(errors))
+ case (None, Some(_)) => {
+ compileResult.left.foreach { diags =>
+ VerifyTestCase.verifyAllDiagnosticsFound(diags, optExpectedErrors)
}
- processor.right.foreach {
- case (warnings, processor) =>
- runParseExpectErrors(processor, dataToParse, nBits, errors,
optWarnings, optValidationErrors, validationMode)
+ compileResult.right.foreach {
+ case (_, processor) =>
+ runParseExpectErrors(processor, dataToParse, nBits,
optExpectedErrors.get, optExpectedWarnings, optExpectedValidationErrors,
validationMode)
}
}
case _ => Assert.invariantFailed("Should be Some None, or None Some
only.")
}
}
- def runParseExpectErrors(processor: DFDL.DataProcessor,
+ def runParseExpectErrors(processor: TDMLDFDLProcessor,
dataToParse: InputStream,
lengthLimitInBits: Long,
errors: ExpectedErrors,
optWarnings: Option[ExpectedWarnings],
optValidationErrors: Option[ExpectedValidationErrors],
- validationMode: ValidationMode.Type) {
- lazy val sw = new StringWriter()
- val (diagnostics, isError: Boolean) = {
- if (processor.isError) (processor.getDiagnostics, true)
+ validationMode: ValidationMode.Type): Unit = {
+
+ val (parseResult: TDMLParseResult, diagnostics, isError: Boolean) = {
+ if (processor.isError) (null, processor.getDiagnostics, true)
else {
- val out = new XMLTextInfosetOutputter(sw)
- val dis = InputSourceDataInputStream(dataToParse)
- if (lengthLimitInBits >= 0 && lengthLimitInBits % 8 != 0) {
- // Only set the bit limit if the length is not a multiple of 8. In
that
- // case, we aren't expected to consume all the data and need a
bitLimit
- // to prevent messages about left over bits.
- dis.setBitLimit0b(MaybeULong(lengthLimitInBits))
- }
- val actual = processor.parse(dis, out)
+ val actual = processor.parse(dataToParse, lengthLimitInBits)
val isErr: Boolean =
- if (actual.isError) true
+ if (actual.isProcessingError) true
Review comment:
Now ignoring validation errors? Why this change?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services