mbeckerle commented on a change in pull request #140: TDML Runner and test
changes for Cross Validation with IBM.
URL: https://github.com/apache/incubator-daffodil/pull/140#discussion_r234714312
##########
File path:
daffodil-tdml/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
##########
@@ -437,69 +432,70 @@ abstract class TestCase(testCaseXML: NodeSeq, val
parent: DFDLTestSuite)
lazy val defaultRoundTrip: RoundTrip = parent.defaultRoundTrip
lazy val defaultValidation: String = parent.defaultValidation
- /**
- * This doesn't fetch a serialized processor, it runs whatever the processor
is
- * through a serialize then unserialize path to get a processor as if
- * it were being fetched from a file.
- */
- private def generateProcessor(pf: DFDL.ProcessorFactory,
useSerializedProcessor: Boolean): DFDLTestSuite.CompileResult = {
- val p = pf.onPath("/")
- val diags = p.getDiagnostics
- if (p.isError) Left(diags)
- else {
- val dp =
- if (useSerializedProcessor) {
- val os = new java.io.ByteArrayOutputStream()
- val output = Channels.newChannel(os)
- p.save(output)
-
- val is = new java.io.ByteArrayInputStream(os.toByteArray)
- val input = Channels.newChannel(is)
- val compiler_ = Compiler()
- compiler_.reload(input)
- } else p
+ private lazy val defaultImplementations: Seq[String] =
parent.defaultImplementations
+ private lazy val tcImplementations = (testCaseXML \ "@implementations").text
+ private lazy val implementationStrings =
+ if (tcImplementations == "") defaultImplementations
+ else tcImplementations.split("""\s+""").toSeq
- Right((diags, dp))
+ protected def toss(t: Throwable, implString: String) = {
+ t match {
+ case e: TDMLException => throw e
+ case e: UnsuppressableException => throw e
+ case s: scala.util.control.ControlThrowable => throw s
+ case _ => throw TDMLException(t, implString)
}
}
- private def compileProcessor(schemaSource: DaffodilSchemaSource,
useSerializedProcessor: Boolean): DFDLTestSuite.CompileResult = {
- val pf = compiler.compileSource(schemaSource)
- val diags = pf.getDiagnostics
- if (pf.isError) {
- Left(diags) // throw new TDMLException(diags)
- } else {
- val res = this.generateProcessor(pf, useSerializedProcessor)
- res
- }
- }
+ lazy val tdmlDFDLProcessorFactory: TDMLDFDLProcessorFactory = {
+ import scala.language.reflectiveCalls
+ import scala.language.existentials
- final protected def getProcessor(schemaSource: DaffodilSchemaSource,
useSerializedProcessor: Boolean): DFDLTestSuite.CompileResult = {
- val res: DFDLTestSuite.CompileResult = schemaSource match {
- case uss: URISchemaSource =>
- SchemaDataProcessorCache.compileAndCache(uss, useSerializedProcessor,
- parent.checkAllTopLevel,
- root,
- null) {
- compileProcessor(uss, useSerializedProcessor)
- }
- case _ => {
- compileProcessor(schemaSource, useSerializedProcessor)
- }
- }
+ val className =
"org.apache.daffodil.tdml.processor.DaffodilTDMLDFDLProcessorFactory"
Review comment:
So, I did look briefly into ServiceLoader. I think the basic API is ok.
However, this whole aspect of Java has been criticised for *not* solving the
module-version-collision issue - there is no isolation of modules. I.e., one
could, legitimately, consider it entirely pointless, and highly subject to
change in future SDKs. OTOH, it does seem simpler or more approachable than
the corresponding aspects of OSGI, which solves perhaps too many problems.
My preference is just to stay with the simplest possible thing for right
now. At least until an idiom for usage of this stuff appears... right now I
don't have an idiom for running tests against IBM DFDL, from sbt or the command
line, worked out as yet. I can run them from eclipse after tweeking classpaths
of the test projects.
I do think the class name should change here, as this one suggests this is
some Daffodil-specific class, when this is the class name ANY implementation
must have, in order for the class loader to find it. The IBM DFDL
implementation also implements this exact same class name. So I'm thinking the
trait/interface (or "service") definition name grows the prefix "Abstract..."
on its name, and the concrete implementation is just class
"TDMLDFDLProcessorFactory" which is shorter, cleaner, and admits multiple
implementations.
----------------------------------------------------------------
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