A Python-native clone of LLVMs FileCheck tool
Project description
filecheck - A Python-native clone of LLVMs FileCheck tool
This tries to be as close a clone of LLVMs FileCheck as possible, without going crazy.
There are some features that are left out for now (e.g. 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.
Features:
Here's an overview of all FileCheck features and their implementation status.
- Checks:
-
CHECK
-
CHECK-NEXT
-
CHECK-NOT
-
CHECK-LABEL
#1 -
CHECK-EMPTY
-
CHECK-SAME
-
CHECK-DAG
-
CHECK-COUNT
-
- Flags:
-
--check-prefix
-
--check-prefixes
-
--comment-prefixes
-
--allow-unused-prefixes
-
--input-file
-
--match-full-lines
-
--strict-whitespace
(Kinda? Seems to be working.) -
--ignore-case
-
--implicit-check-not
-
--dump-input
-
--dump-input-context
-
--dump-input-filter
-
--enable-var-scope
-
-D<VAR=VALUE>
-
-D#<FMT>,<NUMVAR>=<NUMERIC EXPRESSION>
-
-version
-
-v
-
-vv
-
--allow-deprecated-dag-overlap
Not sure what this means yet. -
--allow-empty
(I think I allow empty input rn?) -
--color
No color support yet
-
- Base Features:
- Regex patterns
- Captures and Capture Matches
- Numeric Captures
- Numeric Substitutions (jesus christ, wtf man)
- Literal matching (
CHECK{LITERAL}
) - Weird regex features (
[:xdigits:]
and friends) - Correct(?) handling of matching check lines
- Testing:
- Base cases
- Negative tests
- Error messages (started)
- Lots of edge cases
- MLIR/xDSL integration tests
- UX:
- Good error messages: I have some error messages, but could be a lot better
- Parse errors
- Matching errors
- Malformed regexes
- Good error messages: I have some error messages, but could be a lot better
- 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 falvour.
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 Matchings:
We relax some of the matching rules, like:
- Allow a file to start with
CHECK-NEXT
No Numerical Substitution
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 (without the%
)
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_ng-0.1.1.tar.gz
.
File metadata
- Download URL: filecheck_ng-0.1.1.tar.gz
- Upload date:
- Size: 27.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edbee0d060693d65b9f0e6d1c7cbc1bd95b5e114d59a6863b43928990be2d5ba |
|
MD5 | 8ccea0cab078f7d89061807ab1ce0d74 |
|
BLAKE2b-256 | 7af675d9c4267162dc5240e873144ff193581a2f35317a47c362d8ea0dac1c4a |
File details
Details for the file filecheck_ng-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: filecheck_ng-0.1.1-py3-none-any.whl
- Upload date:
- Size: 30.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7edc151398cb32e9c263a3f2daf70adbe826f80d31072d21a5e356e4c9ae179 |
|
MD5 | 34b72b47939419e6111d00600237d12c |
|
BLAKE2b-256 | 9f0e9d2189393fdf6a8b5c868deddf5f671a1a86abe70c585a97dfc3eacf0b6b |