This is an archive of the discontinued LLVM Phabricator instance.

[lit] Support custom parsers in parseIntegratedTestScript
ClosedPublic

Authored by EricWF on Nov 22 2016, 3:24 PM.

Details

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()

Diff Detail

Event Timeline

EricWF updated this revision to Diff 78956.Nov 22 2016, 3:24 PM
EricWF retitled this revision from to [lit] Support custom parsers in parseIntegratedTestScript.
EricWF updated this object.
EricWF added subscribers: cfe-commits, llvm-commits.
mgrang added a subscriber: mgrang.Nov 22 2016, 4:22 PM

I ran pep8 on this script:

line 742: E302 expected 2 blank lines, found 1
line 757: E302 expected 2 blank lines, found 1
line 819: E301 expected 1 blank line, found 0

Can you pep-ify this script?

EricWF updated this revision to Diff 78988.Nov 22 2016, 4:50 PM

Pepify the changed lines.

jroelofs edited edge metadata.Nov 22 2016, 5:02 PM

Should probably add a testcase in lit/tests that exercises the new CUSTOM parser stuff, so people working on LIT don't have to build/test libc++ in order to know whether they've broken its testsuite.

Should probably add a testcase in lit/tests that exercises the new CUSTOM parser stuff, so people working on LIT don't have to build/test libc++ in order to know whether they've broken its testsuite.

I plan to implement tests. I just wanted to ensure the approach was agreeable first.

Should probably add a testcase in lit/tests that exercises the new CUSTOM parser stuff, so people working on LIT don't have to build/test libc++ in order to know whether they've broken its testsuite.

I plan to implement tests. I just wanted to ensure the approach was agreeable first.

Looks like a good approach to me.

EricWF updated this revision to Diff 80168.EditedDec 2 2016, 9:31 PM
EricWF edited edge metadata.
  • Add unit tests.

This patch is ready to go. If there are no objections in the next day or two I'll commit it.

jroelofs accepted this revision.Dec 5 2016, 7:31 AM
jroelofs edited edge metadata.
This revision is now accepted and ready to land.Dec 5 2016, 7:31 AM
EricWF closed this revision.Dec 5 2016, 12:31 PM
MatzeB added a subscriber: MatzeB.EditedDec 6 2016, 2:55 PM

This breaks the test-suite lit scripts:

Exception during script execution:
Traceback (most recent call last):
  File "/Users/mbraun/dev/public_llvm/utils/lit/lit/run.py", line 183, in execute_test
    result = test.config.test_format.execute(test, self.lit_config)
  File "/Users/mbraun/dev/test-suite/litsupport/test.py", line 73, in execute
    testfile.parse(context, test.getSourcePath())
  File "/Users/mbraun/dev/test-suite/litsupport/testfile.py", line 45, in parse
    command_type,))
ValueError: unknown script command type: 'RUN:'