OSDN Git Service

[lit] Support custom parsers in parseIntegratedTestScript
authorEric Fiselier <eric@efcs.ca>
Mon, 5 Dec 2016 20:21:21 +0000 (20:21 +0000)
committerEric Fiselier <eric@efcs.ca>
Mon, 5 Dec 2016 20:21:21 +0000 (20:21 +0000)
commit5b9f351e179585e45a32c9241ba3941524a04c38
tree462ac0a1f877d458a673c2e071af939efb678077
parent9478556f8f3a415ac9edcbdfc26f613f041d48b1
[lit] Support custom parsers in parseIntegratedTestScript

Summary:
Libc++ frequently has the need to parse more than just the builtin *test keywords* (`RUN`, `REQUIRES`, `XFAIL`, ect). For example libc++ currently needs a new keyword `MODULES-DEFINES: macro list...`. Instead of re-implementing the script parsing in libc++ this patch allows `parseIntegratedTestScript` to take custom parsers.

This patch introduces a new class `IntegratedTestKeywordParser` which implements the logic to parse/process a test keyword. Parsing of various keyword "kinds" are supported out of the box, including 'TAG', 'COMMAND', and 'LIST', which parse keywords such as `END.`, `RUN:` and `XFAIL:` respectively.

As an example after this change libc++ can implement the `MODULES-DEFINES` simply using:
```
mparser = IntegratedTestKeywordParser('MODULES-DEFINES:', ParserKind.LIST)
parseIntegratedTestScript(test, additional_parsers=[mparser])
macro_list = mparser.getValue()
```

Reviewers: ddunbar, modocache, rnk, danalbert, jroelofs

Subscribers: mgrang, llvm-commits, cfe-commits

Differential Revision: https://reviews.llvm.org/D27005

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288694 91177308-0d34-0410-b5e6-96231b3b80d8
utils/lit/lit/TestRunner.py
utils/lit/tests/Inputs/testrunner-custom-parsers/lit.cfg [new file with mode: 0644]
utils/lit/tests/Inputs/testrunner-custom-parsers/test.txt [new file with mode: 0644]
utils/lit/tests/unit/TestRunner.py [new file with mode: 0644]