[PATCH] D63490: Script for generating AST JSON dump test cases

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 18 06:24:08 PDT 2019


aaron.ballman created this revision.
aaron.ballman added a reviewer: rsmith.

Trying to write or maintain test code for AST dumping of JSON information can be onerous due to small changes in the test requiring a large amount of line numbers or other information to be updated in the expected test output. To help with this, we devised a simple python script that automatically generates the expected output and appends it to the end of a test file.

The script allows you to specify the clang instance to run, clang command line options used within test file, the source file to generate the test output from, and a filter in case you wish to only generate test output for specific AST JSON nodes.

For instance, you can execute `python gen_ast_dump_json_test.py --clang D:\trunk_build\build\x64-Debug\bin\clang.exe --opts "-triple x86_64-unknown-unknown -std=gnu11" --source ast-dump-expr-json.c --filters FunctionDecl` to generate the test output seen in `ast-dump-expr-json.c`. The script also works when passing `-ast-dump-filter` in the options to generate the output.


https://reviews.llvm.org/D63490

Files:
  test/AST/gen_ast_dump_json_test.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63490.205314.patch
Type: text/x-patch
Size: 5095 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190618/a8137233/attachment-0001.bin>


More information about the cfe-commits mailing list