microsoft / PowerApps-TestEngine

MIT License
93 stars 28 forks source link

Rewriting logic to compute formulas separated by chaining operator and consider nested formula separation. #268

Closed akshar2401 closed 1 year ago

akshar2401 commented 1 year ago

Pull Request Template

Description

Rewriting the logic to extract formulas separated by semicolon (chaining operator). Takes the nested formula separation into account. When parse tree has syntax errors (not the binding errors, which are resolved by going step by step), a best effort is made to extract the test steps as accurately as possible. Firstly, an expression is tokenized if there's a need to go step by step and the spans for formulas between tokens that represent semicolons or chaining operators are computed. These spans are the formulas separated by semicolon. Some of these spans represent formulas that are separated somewhere down the tree (depth > 1, nested separation). Parse tree is used to merge these nested spans into spans that represent formulas separated at the top most level. This logic relies on a property of these spans that they are sorted by their start indices and since they are ordered, the nested spans appear on the same path and consecutively in the spans list created after tokenization. For each span, nearest node that represents formula separation (VariadicOpNode) is found. If this nearest node is not the root then we are looking at nested formula separation. This span is then merged to the root formula separation node based on the non root nearest formula separation node. If the parse tree has syntactic error nodes then the best attempt is made to extract the formulas as correctly as possible. However a lot depends on PowerFx and which parsing algorithm it uses. This is better than what we had previously but it is not 100% correct when there are syntax errors. This is fine as syntax errors would fail the test run even if we go step by step. I've added good amount of tests

Checklist

github-actions[bot] commented 1 year ago

Code Coverage

Package Line Rate Branch Rate Complexity Health
Microsoft.PowerApps.TestEngine 90% 88% 912
Summary 90% (2377 / 2630) 88% (556 / 630) 912

Minimum allowed line rate is 85%