[
https://issues.apache.org/jira/browse/DRILL-6249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16468424#comment-16468424
]
ASF GitHub Bot commented on DRILL-6249:
---------------------------------------
paul-rogers commented on a change in pull request #1251: DRILL-6249: Adding
more unit testing documentation.
URL: https://github.com/apache/drill/pull/1251#discussion_r186885108
##########
File path: docs/dev/GeneratedCode.md
##########
@@ -0,0 +1,42 @@
+# Testing Generated Code
+
+## Writing Unit Tests For Generated Code
+
+An example of unit testing generated code without running all of Drill is the
**priorityQueueOrderingTest()** test in
+[TopNBatchTest](../../exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TopN/TopNBatchTest.java).
That test tests the
+[PriorityQueueTemplate](../../exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/TopN/PriorityQueueTemplate.java)
class separately from the rest of Drill.
+
+The main accomplished by creating instances of the following classes:
+
+ *
[FunctionLookupContext](../../exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionLookupContext.java)
+ *
[CodeCompiler](../../exec/java-exec/src/main/java/org/apache/drill/exec/compile/CodeCompiler.java)
+
+## Creating A
[FunctionLookupContext](../../exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionLookupContext.java)
+
+```
+new FunctionImplementationRegistry(drillConfig)
+```
+
+## Creating A
[CodeCompiler](../../exec/java-exec/src/main/java/org/apache/drill/exec/compile/CodeCompiler.java)
+
+ 1. Create a
[DrillConfig](../../common/src/main/java/org/apache/drill/common/config/DrillConfig.java)
as shown in [MockingComponents.md](MockingComponents.md).
+ 1. Create a
[SystemOptionManager](../../exec/java-exec/src/main/java/org/apache/drill/exec/server/options/SystemOptionManager.java)
as shown in
+ [MockingComponents.md](MockingComponents.md).
+ 1. Create an instance of
[CodeCompiler](../../exec/java-exec/src/main/java/org/apache/drill/exec/compile/CodeCompiler.java).
+ ```
+ new CodeCompiler(drillConfig, optionManager)
+ ```
+
+## Debugging Generated Code
+
+It is possible to set break points in generated code.
+
+### Instructions For IntelliJ
+
+ 1. File→Project structure…→Modules→distribution→Sources → Add content root
+ 1. Chose /tmp/drill/codegen
+ 1. Mark it as Sources directory.
+ 1. Set saveCodeForDebugging(true) for the code generator of interest
+ 1. Run the unit test of interest
+ 1. Now some generated classes should appear in Intellij under the
distribution module
+ 1. Set a break point in a generated class and run the unit test in debug mode
Review comment:
To step into the generated code, set a breakpoint just before we call into
the setup method. Step into that method which will step into doSetup. This
opens the generated code file (at least in Eclipse.)
----------------------------------------------------------------
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]
> Add Markdown Docs for Unit Testing and Link to it in README.md
> --------------------------------------------------------------
>
> Key: DRILL-6249
> URL: https://issues.apache.org/jira/browse/DRILL-6249
> Project: Apache Drill
> Issue Type: Improvement
> Reporter: Timothy Farkas
> Assignee: Timothy Farkas
> Priority: Major
> Labels: ready-to-commit
> Fix For: 1.14.0
>
>
> I am working on a presentation about how to use the unit testing utilities in
> Drill. Instead of writing the doc and having it be lost in Google Drive
> somewhere I am going to add a Markdown doc to the drill repo and link to it
> in the README.md. This is appropriate since these docs will only be used by
> developers, and the way we unit test will change as the code changes. So the
> unit testing docs should be kept in the same repo as the code so it can be
> updated and kept in sync with the rest of Drill.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)