Refactor ShaderRenderTester::validate() into focused helper methods#2825
Refactor ShaderRenderTester::validate() into focused helper methods#2825ashwinbhat wants to merge 5 commits intoAcademySoftwareFoundation:mainfrom
Conversation
Break up the monolithic validate() into initializeLogging(), collectTestFiles(), initializeGeneratorContext(), and loadAndValidateDocument() Refactoring was AI Assisted: Claude 4.6 Opus Verfied Render test run and log contents are consistent except for timestamps.
|
@jstone-lucasfilm @bernardkwok @ppenenko The ShaderRenderTester::validate was getting too long. Refactoring it for ease of read. |
There was a problem hiding this comment.
Pull request overview
Refactors ShaderRenderTester::validate() in the MaterialX render test utilities into smaller helper methods to improve readability and separation of concerns, while keeping test behavior/logging consistent.
Changes:
- Extracted logging setup into
initializeLogging()and introducedLogStreamsto manage file-backed streams. - Extracted test discovery into
collectTestFiles()and per-document work intoloadAndValidateDocument()with aDocumentInforeturn struct. - Extracted generator/context initialization into
initializeGeneratorContext().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
source/MaterialXTest/MaterialXRender/RenderUtil.h |
Adds LogStreams / DocumentInfo structs and declares new helper methods used to break up validate(). |
source/MaterialXTest/MaterialXRender/RenderUtil.cpp |
Implements the new helper methods and rewires validate() to use them. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ashwin Bhat <1727158+ashwinbhat@users.noreply.github.com>
jstone-lucasfilm
left a comment
There was a problem hiding this comment.
Thanks for putting this proposal together, @ashwinbhat, and I've written up two initial thoughts.
| std::unique_ptr<std::ofstream> docValidLogFile; | ||
| std::unique_ptr<std::ofstream> profilingLogFile; | ||
|
|
||
| std::ostream& log; |
There was a problem hiding this comment.
This seems like a very unusual pattern, where we're storing both unique pointers and direct references to the same objects.
Would it perhaps be better to provide accessors to these unique pointers, rather than storing them a second time?
| RenderProfileTimes& profileTimes); | ||
|
|
||
| // Load a single .mtlx document, validate it, and find its renderable elements. | ||
| DocumentInfo loadAndValidateDocument(const mx::FilePath& filename, |
There was a problem hiding this comment.
Although I like the idea of making each of these steps separable and focused, I feel that a helper method taking nine arguments is reducing the clarity of the separation, since it's so tightly coupled to the original monolithic design.
Could this perhaps be refactored further, either using a clearer split of the new helper methods, or context objects that wrap associated state variables in an intuitive way?
There was a problem hiding this comment.
Bit hard to follow all the changes, but I think it would be easier to store state on the class instance vs passing arguments around. It would also help to isolate the new perfecto code as utility methods.
Something like: instance::startLogging(), logResult(), endLogging(), startPerf(), logPerf(), endPerf(). You could make it scoped to avoid missing closing "ends".
|
I noticed "AI gen" code tends to remove comments in code. Would be good to set a rule to prioritize not do so, and restore any ones removed currently. |
Break up the monolithic validate() into
initializeLogging(),
collectTestFiles(),
initializeGeneratorContext(), and
loadAndValidateDocument()
Refactoring was AI Assisted: Claude 4.6 Opus
Verfied Render test run and log contents are consistent except for timestamps.
genglsl_render_log_BEFORE.txt
genglsl_render_profiling_log_BEFORE.txt
genglsl_render_log.txt
genglsl_render_profiling_log.txt