Skip to main content

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. parts of numeric substitution ).

The codebase is fully type checked by pyright, and automatically formatted using ruff format. 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:
    • CHECK
    • CHECK-NEXT
    • CHECK-NOT (Bug: #10)
    • CHECK-LABEL (Bug: #8)
    • 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 (Bug: #6)
    • --ignore-case
    • --implicit-check-not (Tracked: #20)
    • --dump-input (only fail and never 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:
    • Regex patterns
    • Captures and Capture Matches (Bug: #11)
    • Numeric Captures
    • Numeric Substitutions (jesus christ, wtf man) (Tracked: #45)
    • Literal matching (CHECK{LITERAL})
    • Weird regex features ([:xdigits:] and friends)
    • Correct(?) handling of matching check lines (Bug: #22)
  • 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
  • Infrastructure:
    • Formatting: ruff
    • 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.

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

filecheck-1.0.6.tar.gz (47.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

filecheck-1.0.6-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file filecheck-1.0.6.tar.gz.

File metadata

  • Download URL: filecheck-1.0.6.tar.gz
  • Upload date:
  • Size: 47.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for filecheck-1.0.6.tar.gz
Algorithm Hash digest
SHA256 c41c51f733b0bfdae6718dca4b94fb0bdf72fab70f35fc68d62bf8ac60d6442d
MD5 9d07332894f5e5324ec756c6b1ce3bdc
BLAKE2b-256 d0015ff29e252321dd7cd012d8473580ae53c2fb66e81000d99a7dd8426102d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for filecheck-1.0.6.tar.gz:

Publisher: pythonpublish.yml on AntonLydike/filecheck

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file filecheck-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: filecheck-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 24.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for filecheck-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 202b53d0b384016f6b150af8fa6f1b7f306d2213d31983d5a472135fce95baf9
MD5 ebc9eea7e21ed4e5be5e5112ecdcc760
BLAKE2b-256 962ed46ab13a690cfa257ebadddd36c4fcc6eb36218c198b3b48a74312a4cd65

See more details on using hashes here.

Provenance

The following attestation bundles were made for filecheck-1.0.6-py3-none-any.whl:

Publisher: pythonpublish.yml on AntonLydike/filecheck

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.6 This release

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.0.24

1 file

0.0.23

2 files

0.0.22

2 files

0.0.21

2 files

0.0.20

2 files

0.0.19

2 files

0.0.18

2 files

0.0.17

2 files

0.0.16

2 files

0.0.15

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page