An example of unit testing generated code without running all of Drill is the priorityQueueOrderingTest() test in TopNBatchTest. That test tests the PriorityQueueTemplate class separately from the rest of Drill.
The testing of PriorityQueueTemplate is mainly accomplished by creating instances of the following classes:
Creating A FunctionLookupContext
new FunctionImplementationRegistry(drillConfig)
Creating A CodeCompiler
- Create an OperatorFixture.
- Retrieve the SystemOptionManager from the
OperatorFixture.
operatorFixture.getOptionManager();
- Create an instance of CodeCompiler.
new CodeCompiler(drillConfig, optionManager)
It is possible to set break points in generated code.
- File→Project structure…→Modules→distribution→Sources → Add content root
- Chose /tmp/drill/codegen
- Mark it as Sources directory.
- Set saveCodeForDebugging(true) for the code generator of interest
- Run the unit test of interest
- Now some generated classes should appear in Intellij under the distribution module
- Set a break point in a generated class and run the unit test in debug mode
- 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.