A Python-native clone of LLVMs FileCheck tool
Project description
filecheck - A Python-native clone of LLVMs FileCheck tool
Note: This project is the successor of mull-project/FileCheck.py.
This tries to be as close a clone of LLVMs FileCheck as possible, without going crazy. It currently passes 1576 out of 1645 (95.8%) of LLVMs MLIR filecheck tests. We are tracking all 69 remaining test failures in GitHub issues.
There are some features that are left out for now (e.g.a pseudo-numeric variables and parts of numeric substitution ).
The codebase is fully type checked by pyright
, and automatically formatted using black
. We aim to have tests
covering everything from normal matching down to error messages.
Install by running pip install filecheck
.
Features:
Here's an overview of all FileCheck features and their implementation status.
- Checks:
- Flags:
-
--check-prefix
-
--check-prefixes
-
--comment-prefixes
-
--allow-unused-prefixes
-
--input-file
-
--match-full-lines
-
--strict-whitespace
(Bug: #6) -
--ignore-case
-
--implicit-check-not
(Tracked: #20) -
--dump-input
(onlyfail
andnever
supported) -
--dump-input-context
-
--dump-input-filter
-
--enable-var-scope
-
-D<VAR=VALUE>
-
-D#<FMT>,<NUMVAR>=<NUMERIC EXPRESSION>
-
-version
-
-v
-
-vv
-
--allow-deprecated-dag-overlap
-
--allow-empty
-
--color
Colored output is supported and automatically detected. No support for the flag.
-
- Base Features:
- Testing:
- Base cases
- Negative tests
- Error messages (started)
- Lots of edge cases
- MLIR/xDSL integration tests
- UX:
- Good error messages: Error messages are on an okay level, not great, but not terrible either.
- Parse errors
- Matching errors
- Print possible intended matches (could be better still)
- Malformed regexes
- Wrong/unkown command line arguments
- Print variables and their origin in error messages
- Good error messages: Error messages are on an okay level, not great, but not terrible either.
- Infrastructure:
- Formatting: black
- Pyright
-
pre-commit
- CI for everything
We are open to PRs for bugfixes or any features listed here.
Differences to LLVMs FileCheck:
We want to be as close as possible to the original FileCheck, and document our differences very clearly.
If you encounter a difference that is not documented here, feel free to file a bug report.
Better Regexes:
We use pythons regex library, which is a flavour of a Perl compatible regular expression (PCRE), instead of FileChecks POSIX regex flavour.
Example:
// LLVM filecheck:
// CHECK: %{{[[:alnum:]]+}}, %{{[[:digit:]]+}}
// our fileheck:
// CHECK: %{{[a-zA-Z0-9]+}}, %{{\d+}}
Some effort is made to translate character classes from POSIX to PCRE, although it might be wrong in edge cases.
Relaxed Matching:
We relax some of the matching rules, like:
- Allow a file to start with
CHECK-NEXT
No Numerical Substitution:
This is used in 2 out of 1645 tests in our benchmark (upstream MLIR tests).
While our filecheck supports numeric capture
([[#%.3x,VAR:]]
will capture a three-digit hex number), we don't support arithmetic expressions on these captured
values at the moment. We also don't support the "Pseudo Numeric Variable" @LINE
.
Special Feature Flags:
This version of filecheck implements some non-standard extensions to LLVMs filecheck. These are disabled by default but
can be enabled through the environment variable FILECHECK_FEATURE_ENABLE=...
. Avialable extensions are documented here:
MLIR_REGEX_CLS
: Add additional special regex matchers to match MLIR/LLVM constructs:\V
will match any SSA value name
Reject Empty Captures:
We introduce a new flag called reject-empty-vars
that throws an error when a capture expression captures an empty
string.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file filecheck-1.0.1.tar.gz
.
File metadata
- Download URL: filecheck-1.0.1.tar.gz
- Upload date:
- Size: 20.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbc3c49c190bd3af2445426a193ff0b54e1fad5a81ea7c2116c4dc36f36614f2 |
|
MD5 | cdd41d1bc31c5e97e37ac11441366cfe |
|
BLAKE2b-256 | 93d27e8bf9acf2ccb522fef4845d940b7db14782e6a36929da0ca5a4791bc2b6 |
File details
Details for the file filecheck-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: filecheck-1.0.1-py3-none-any.whl
- Upload date:
- Size: 23.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d1a0e8784b723a4b04a655cff3af09dd159a31f4e39d477186f5547553124ab |
|
MD5 | 4376a22275d3f409071979235e3e9c62 |
|
BLAKE2b-256 | c729827b9f240e03c2cc6a2fd534ac980a12b3c7e8d8aa71c2f1039a5f91e932 |