#5783 Only show axis planes when there are no errors#5799
Conversation
|
QA Wolf here! As you write new code it's important that your test coverage is keeping up. |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
src/machines/modelingMachine.ts
Outdated
| 'Has exportable geometry': () => false, | ||
| 'has valid selection for deletion': () => false, | ||
| 'no kcl errors': () => { | ||
| // Note: kclManager.hasErrors() seems always false! |
There was a problem hiding this comment.
kclManager.hasErrors() seemed to return with false here even if kclManager.errors had the kcl errors in it..
If that's a bug we could refactor hasErrors to return errors.lenght > 0 or if these refer to different things it could be worth making their names clearer.
There was a problem hiding this comment.
that's gotta be a bug in hasErrors so I'm happy to see a fix there too.
There was a problem hiding this comment.
We could just make hasErrors be a getter that does return !!this.errors.length that way there can't be a bug?
There was a problem hiding this comment.
@Irev-Dev Yes I was thinking of doing exactly that, I looked at it again today and I want to make sure I'm not causing regressions by removing _hasErrors.
So in executeCode it seems safeParse() is invoked first, which sets _hasErrors to true if the AST parse failed. If the parse is successful then _hasErrors may still be set to true if the parse result has errors.
After this executeAst() is only called if the parsing is successful and has no errors.
If the parsing is successful and there are no errors then executeAst() is called which can have a new set of errors that the errors array is set to.
executeAst() may also be called individually without safeParse()
So there are multiple levels of errors:
_hasErrors, which is set to true if parsing fails or there is a parsing result but it has errors_errorswhich is set from AST execution errors but is not updated when parsing has errors- to add a bit of confusion I found that some execution
errorscan be considered parse errors as per this line:
const parseErrors = kclManager.errors.filter((e) => e.kind !== 'engine')It's a bit unclear to me what is exactly the difference between the parse result errors in safeParse and the AST execution errors, I would love to learn more about that.
Regardless, it seems possible to me that the errors array is empty but _hasErrors is true.
With that in mind what I would do is:
- rename
_hasErrorsto something like_parseFailed - rename
errorstoexecutionErrors(or keep it errors but at least the flag should be renamed to avoid confusion I think) hasErrors()would be implemented like:this.parseFailed || this._executionErrors.length > 0
@franknoirot @nrc I see you worked on these parts previously, just want to make sure I'm not going in a wrong direction.
There was a problem hiding this comment.
So, for parsing and execution there are both fatal errors which immediately halt interpretation and are returned as the result of parsing or execution and there are non fatal errors (both errors and warnings) which do not cause an immediate halt (but except for warnings do halt proceeding to the next stage of interpretation). I think these are somewhat combined by the time the frontend sees them, but I don't recall exactly. There should really be no difference between a parsing and execution error.
There was a problem hiding this comment.
@nrc thanks, so it sounds like it's probably a good idea treat all of these similarly so hasErrors() returns true if there was either a parsing or an execution error, there shouldn't really be a difference in how they are handled in the frontend.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5799 +/- ##
=======================================
Coverage 85.77% 85.77%
=======================================
Files 113 113
Lines 44025 44025
=======================================
Hits 37762 37762
Misses 6263 6263
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Some snapshots have been modified by the github bot, @lee-at-zoo-corp @franknoirot is that something I should look at? They did seem to change visually. |
|
Thank you @andrewvarga, that worked well here! Hitting merge. |
…s" (#6007) * first pass at adding test for Only showing axis planes when there are no errors * fix test Only show axis planes when there are no errors * PR feedback
…e no errors" (#6007) * first pass at adding test for Only showing axis planes when there are no errors * fix test Only show axis planes when there are no errors * PR feedback
…e no errors" (#6007) * first pass at adding test for Only showing axis planes when there are no errors * fix test Only show axis planes when there are no errors * PR feedback
…e no errors" (#6007) * first pass at adding test for Only showing axis planes when there are no errors * fix test Only show axis planes when there are no errors * PR feedback
…e no errors" (#6007) * first pass at adding test for Only showing axis planes when there are no errors * fix test Only show axis planes when there are no errors * PR feedback
…e no errors" (#6007) * first pass at adding test for Only showing axis planes when there are no errors * fix test Only show axis planes when there are no errors * PR feedback
…e no errors" (#6007) * first pass at adding test for Only showing axis planes when there are no errors * fix test Only show axis planes when there are no errors * PR feedback
…e no errors" (#6007) * first pass at adding test for Only showing axis planes when there are no errors * fix test Only show axis planes when there are no errors * PR feedback
…e no errors" (#6007) * first pass at adding test for Only showing axis planes when there are no errors * fix test Only show axis planes when there are no errors * PR feedback
…e no errors" (#6007) * first pass at adding test for Only showing axis planes when there are no errors * fix test Only show axis planes when there are no errors * PR feedback
…e no errors" (#6007) * first pass at adding test for Only showing axis planes when there are no errors * fix test Only show axis planes when there are no errors * PR feedback
…e no errors" (#6007) * first pass at adding test for Only showing axis planes when there are no errors * fix test Only show axis planes when there are no errors * PR feedback
…e no errors" (#6007) * first pass at adding test for Only showing axis planes when there are no errors * fix test Only show axis planes when there are no errors * PR feedback
…e no errors" (#6007) * first pass at adding test for Only showing axis planes when there are no errors * fix test Only show axis planes when there are no errors * PR feedback
* origin/main: (26 commits) attempt to import win-ca on windows (#6136) Upgrade e2e-tests windows runner from 4 cores to 8 (#6166) Follow-up fixes after bearing sample rename (#6164) Add test for #5799: "Only showing axis planes when there are no errors" (#6007) Wait for export button to make test more reliable (#6143) sketching on a mirror2d thats been extruded fixed! (#6149) Bump vite from 5.4.16 to 5.4.17 in /packages/codemirror-lang-kcl in the security group (#6150) Bump vite from 5.4.16 to 5.4.17 in the security group (#6151) Update all KCL-Samples to be more ME friendly (#6132) Shorten feedback cycle for legitimate failures (#6146) Remove the camera projection toggle from the UI (#6077) Use all available CPUs to run tests on CI (#6138) [fix] Get rid of risky useEffect in restart onboarding flow (#6133) Feature: Traditional menu actions in desktop application part II (#6030) [Bug] fix some UI friction from imports (#6139) Use scene fixture to make test more reliable on macOS (#6140) Fix: function composition during playwright setup created a massive page.reload loop (#6137) Alternative way to make appMachine spawned children type safe (#5890) [BUG] mutate ast to keep comments for pipe split ast-mod (#6128) Rename the app to Zoo Design Studio (#5974) ...
As described in #5783 we were showing the axis planes when the artifactGraph was empty, which also happened when there were errors on the current kcl content. Added a guard to only show planes when there are no errors.
There was one weird thing I found that I'm commenting on inline.
I'm looking into how testing works, it's a small fix but maybe worth adding a test to cover it.
I wonder if the failed tests are unrelated? Seems other PRs are failing with similar cases.