mbeckerle commented on code in PR #1375:
URL: https://github.com/apache/daffodil/pull/1375#discussion_r1847224392


##########
daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/RunnerFactory.scala:
##########
@@ -196,6 +196,15 @@ class Runner private (
   def this(elem: scala.xml.Elem) =
     this(Left(elem))
 
+  /**
+   * Uses sourcecode library to capture method name
+   * and use it as the test name.
+   *
+   * @param methodName implicitly computed name of method calling this method.
+   */
+  def doTest(implicit methodName: sourcecode.Enclosing): Unit =
+    runOneTest(methodName.value.split("#").last)

Review Comment:
   Compilation time: no change detectable. I got 1:13 to compile on main, and 
1:12 to compile on my daf-2758 branch. 
   
   This sourcecode library already has scala ports to 2.12, 2.13, and 3.x. 
   
   Re: create our own: It's not remotely close to being a one-liner.  A 
recursive outward walk of scala compiler objects happens until it finds a 
method. Implicit argument types are involved.  There's subtlety to getting this 
to work properly. 
   
   In other words, this is exactly the kind of library I want to use as a 
dependency and not try to reinvent or work around. 
   
   So the primary reason I want this is *not* for use in Daffodil, but for use 
in DFDL schema projects that use the daffodil-tdml-processor library. This is 
where we create hundreds to thousands of test driver lines. Those projects will 
end up with a test-time dependency on Daffodil's macro-lib, as well as on 
Haoyi's sourcecode lib, but these are transitive dependencies so no change to 
build.sbt required. 
   
   The alternative is to force Daffodil users to do this themselves in every 
DFDL schema project, which seems silly since I've been missing this feature in 
*every* DFDL schema project we've been working on since we first built it for 
the VMF/MIL-STD-6017 schema project. 
   
   It's a very nice improvement to TDML to have this. 
   
   
   
   



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