[PATCH] D154987: [lit] Implement PYTHON directive and config.prologue

Sam McCall via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 24 11:24:59 PDT 2023


sammccall added a comment.

I have to offer a dissenting voice here...

Lit shell tests are not written in Python or C++, but in a constrained language specifically for testing.
This has advantages and some disadvantages: e.g. it's easy to see concretely what a lit test does, but can be hard to understand its intent. Assertions are quite readable, but brittle. Output is not always easy to read but fits into a linear sequence of RUN lines.
Personally I think we should be less reliant on lit tests.

But mashing python into lit doesn't produce a coherent result.
Almost all lit features have a python equivalent: CHECK vs check(), DEFINEs vs variables, `%if` vs `if` etc. Now there are always several ways to do the same thing, it's unclear when each is best, and the inconsistency will make it hard to read & maintain tests across the repo in various dialects, which many people have to do.
It's possible to process lit shell tests with alternate implementations (without python!), I know of at least two...
Python is a serious general-purpose programming language with tools available, but none of these tools work with python embedded in lit tests (not even syntax highlighting!).

The lit test runner supports having multiple types of tests (this is how we run gtest + shell tests).
Could the tests you're targeting be written as actual python files, with an appropriate library of operations? (Some of this library could of course be shared with the shell test implementation).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154987/new/

https://reviews.llvm.org/D154987



More information about the llvm-commits mailing list