Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile/CodeMirror: Increase ensureSyntaxTree timeout in math tests #7403

Conversation

personalizedrefrigerator
Copy link
Collaborator

Addresses #7386 (comment).

Tests related to the syntax tree that were passing locally were observed to fail in CI. This can happen if ensureSyntaxTree is unable to finish parsing the syntax tree. Thus, syntaxTreeCreateTimeout is increased by several hundred milliseconds.

Tests related to the syntax tree that were passing locally were observed
to fail in CI. This can happen if ensureSyntaxTree is unable to finish
parsing the syntax tree. Thus, syntaxTreeCreateTimeout is increased by
several hundred milliseconds.
@laurent22
Copy link
Owner

Can't we force it to parse the whole tree, and only return when finished? It's fragile to rely on a timeout.

Also ensureSyntaxTree takes three arguments, and the second one is not the timeout, it's something called "upto". The third one if the timeout.

@personalizedrefrigerator
Copy link
Collaborator Author

personalizedrefrigerator commented Dec 4, 2022

Can't we force it to parse the whole tree, and only return when finished? It's fragile to rely on a timeout.

I don't see a way to do that in a single method call. The related methods are

  • forceParsing: Takes an EditorView (but the math parser tests only have an EditorState). Defaults to 100ms timeout.
  • ensureSyntaxTree: Takes an EditorState, where to parse upto (which should be state.doc.length), and a timeout.
  • syntaxTreeAvailable: Takes an EditorState, returns whether the syntax tree is parsed.

We could do something similar to

while (!syntaxTreeAvailable(editor)) {
  ensureSyntaxTree(editor, editor.doc.length, someTimeoutHere);
}

We could also try using ensureSyntaxTree(editor, editor.doc.length, Infinity). An argument of Infinity seems like something CodeMirror might not expect/be able to properly handle, however.

I'm in favor of the first solution.

Other CodeMirror-related test suites use forceParsing with the default timeout. We would want to make this change to that, too.

Also ensureSyntaxTree takes three arguments, and the second one is not the timeout, it's something called "upto". The third one if the timeout.

That's probably why it wasn't working! Thank you for checking! I'll update the PR.

@laurent22
Copy link
Owner

Your first solution indeed seems good. In that case I guess you can use a relatively short timeout, which means it would be fast on fast machine, and will wait as expected on slower ones.

@personalizedrefrigerator
Copy link
Collaborator Author

Closing in favor of #7405

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants