dlang-community / libdparse

Library for lexing and parsing D source code
https://libdparse.dlang.io
Boost Software License 1.0
114 stars 56 forks source link

Add an XPath-based testing system for the AST generated by the parser #425

Closed Hackerpilot closed 3 years ago

Hackerpilot commented 3 years ago

As discussed in https://github.com/dlang-community/libdparse/issues/143, this adds an XPath-based testing system for checking that the AST generated by the parser is what we expect. Right now there's just one test, which resembles some code that triggered a soon-to-be-fixed DCD issue.

This is only designed to allow tests for expressions that match, i.e. you cannot use this system to check that an XPath expression does not match the AST, but I don't think that we'll need that.

I think this should be enough to finally close https://github.com/dlang-community/libdparse/issues/143

codecov[bot] commented 3 years ago

Codecov Report

Merging #425 into master will increase coverage by 2.01%. The diff coverage is 94.68%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #425      +/-   ##
==========================================
+ Coverage   79.79%   81.80%   +2.01%     
==========================================
  Files          10       11       +1     
  Lines        7818     8418     +600     
==========================================
+ Hits         6238     6886     +648     
+ Misses       1580     1532      -48     
Impacted Files Coverage Δ
test/tester.d 99.65% <88.88%> (-0.35%) :arrow_down:
src/dparse/astprinter.d 94.77% <94.77%> (ø)
src/dparse/formatter.d 41.57% <0.00%> (+3.63%) :arrow_up:
src/dparse/ast.d 70.73% <0.00%> (+4.87%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 1393ee4...cefbdd0. Read the comment docs.

Hackerpilot commented 3 years ago

Irony: Adding the AST checks causes the code coverage to drop, and thus our systems tell us that the library is less well tested.

Hackerpilot commented 3 years ago

All right. --DRT-testmode=run-main was missing from the coverage tests, which has caused the coverage to be wrong for a while. Adding this gets back the behavior that we used to have with older versions of DMD.