-
Notifications
You must be signed in to change notification settings - Fork 360
Fix intermittent test failure re: destroyed tree-view #1288
Conversation
|
Well, this change didn't resolve the problem after all. 🙀Even with this change in place, we still sometimes see the failure: https://ci.appveyor.com/project/Atom/tree-view/builds/20474724/job/i99d26hupv8oh6lr#L124 Back to the drawing board. 🤔 |
|
I'm thinking you might need two useSyncFS calls: one after this line, where we re-assign |
|
Thanks, @50Wliu. 🙇 I was hoping that suggestion might do the trick, but even with that change, we still sometimes see the failure: https://ci.appveyor.com/project/Atom/tree-view/builds/20476994/job/sfejnd0vu9ajhd6h#L134 I think the key difference is that the other tests call tree-view/spec/tree-view-package-spec.coffee Lines 3243 to 3244 in bcbf991
We could update this test to also call |
I've updated the implementation to be less fragile while still exercising the core functionality under test. Instead of asserting a character-by-character match of the original tree-view HTML and the re-created tree-view HTML (which is dependent on asynchronous Git status operations), the updated implementation ensures that the number of entries in the original tree-view matches the number of entries in the re-created tree-view. To me, this feels like it strikes a nice balance:
I ran the build five times on AppVeyor, and it passed every time...
😅 |
winstliu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose my only concern with this approach is that the entries are added correctly - that is, they have the correct nesting, directories and files are separated, etc. On the other hand, it looks like that's tested in
tree-view/spec/tree-view-spec.js
Line 5 in 1b731e3
| it('restores the expanded directories and selected files', () => { |
|
Thanks for the review, @50Wliu. 🙇 |
|
FYI: I've updated the pull request body to reflect the updated implementation. |
Description of the Change
We've been seeing this assertion fail intermittently on AppVeyor recently:
tree-view/spec/tree-view-package-spec.coffee
Line 320 in 1b731e3
Example failing build: https://ci.appveyor.com/project/Atom/tree-view/builds/20338242/job/v7t0rvbkmv8ih0mq
What specifically is failing?
We can see the output of the failing assertion here in the build log here. Let's look at a diff between the expected value and the actual value in that assertion:
The only difference is that the actual content is missing the
status-addedclass.Why is the the
status-addedclass missing?From what I can tell, the
status-*classes get added asynchronously as a side effect of creating or altering aDirectory. Interestingly, we have a set of tests that cover the handling of these status classes. For example:tree-view/spec/tree-view-package-spec.coffee
Lines 3276 to 3278 in cadf5c6
And even more interestingly, those tests explicitly configure the tree view to use synchronous file system calls before asserting the state of the
status-*classes:tree-view/spec/tree-view-package-spec.coffee
Line 3243 in cadf5c6
Given that the failure we're seeing has to do with a missing
status-addedclass, it seems like the intermittent test failure is the result of a nondeterministic behavior due to asynchronous file system calls.Proposed solution
1b731e3...bcbf991 explored the possibility of updating the test to use synchronous file system calls, but that approach is insufficient/problematic for the reasons described in #1288 (comment).
Instead, as described in #1288 (comment), this pull request updates the test to be less fragile while still exercising the core functionality under test. Instead of asserting a character-by-character match of the original tree-view HTML and the re-created tree-view HTML (which is dependent on asynchronous Git status operations), the updated implementation ensures that the number of entries in the original tree-view matches the number of entries in the re-created tree-view. To me, this feels like it strikes a nice balance:
Alternate Designs
See #1288 (comment), which discusses an alternative based on the use of
useSyncFSandupdateRoots.Benefits
Assuming this works, the test will consistently pass 🙏
Possible Drawbacks
None that I'm aware of
Applicable Issues
Refs #789 (which introduced the use of synchronous file system calls for the set of tests referenced above)
Closes #1276