filecheck
A Python-native clone of LLVMs FileCheck tool
What it is and what it does
filecheck is a Python port of LLVM's FileCheck pattern-matching tool for validating text output in tests. It reads check directives (CHECK, CHECK-NEXT, CHECK-NOT, CHECK-LABEL, CHECK-DAG, etc.) from test files or comments and matches them against input text, reporting pass/fail with detailed diagnostics. The package passes 95.8% of LLVM's MLIR filecheck test suite and supports most core features including regex patterns, variable captures, and numeric captures, though numeric substitution (arithmetic on captured values) is not yet implemented.
The tool is fully type-checked with pyright and formatted with black, making it suitable for integration into compiler testing pipelines, MLIR/xDSL projects, and any workflow that needs pattern-based output validation. It requires Python 3.10 or later and has no external runtime dependencies, keeping installation and deployment simple.
Use it for:
- Validate compiler or interpreter output in test suites by embedding CHECK directives in expected-output files
- Test MLIR or LLVM IR generation by matching patterns against generated code
- Verify code generation correctness in language implementation projects using pattern matching and variable capture
- Check diagnostic or error message output from tools by matching against known patterns
- Automate regression testing for xDSL or similar domain-specific languages
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
filecheck is a Python implementation of LLVM's FileCheck tool, used to validate text output against patterns defined in check directives embedded in test files or comments.
Yes, if you need LLVM FileCheck semantics in Python for compiler or code-generation testing. The package is stable, dependency-free, and covers 95.8% of LLVM's test suite. Install with caution if your tests rely on numeric substitution (arithmetic on captures), which is not yet supported; otherwise, it's a straightforward drop-in replacement for the C++ FileCheck tool.
Install
filecheck on PyPI
pip
pip install filecheckuv
uv add filecheckpoetry
poetry add filecheckInstalling filecheck
Before you install
Low friction: pure Python wheel with no runtime dependencies. Maintenance is aging—last release 360 days ago, but the repository remains active with a recent commit on 2025-08-19 and full type checking via pyright.
License in practice
Apache-2.0 permissive license allows use in most projects without restriction, including proprietary software.
Quickstart
pip install filecheck
# In a test file or comment:
# CHECK: expected pattern
# CHECK-NEXT: next line pattern
# CHECK-NOT: should not appear
from filecheck import FileCheck
fc = FileCheck()
fc.run_filecheck('input.txt', 'test_file.py')
Requires Python 3.10 or later (3.10, 3.11, 3.12, or 3.13).
Verify before relying
- Whether numeric substitution (arithmetic on captured values) is a blocker for your test suite, given it covers only 2 out of 1645 MLIR tests
- Whether the 69 known test failures (4.2% of MLIR filecheck tests) affect your specific use case
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (<4.0,>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 360 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 395,000/month — #6,985 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: filecheck-1.0.3-py3-none-any.whl
Keywords: tests, filecheck, llvm
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
llvm-testing-toolsProvides LLVM testing utilities like FileCheck…
unclear · top 15,000 on PyPI
litlit is a portable test runner for executing…
permissive · top 5,000 on PyPI
re-assertProvides a helper class for regex assertions…
permissive · top 15,000 on PyPI
iregexp-checkValidates regular expressions against RFC 9485…
permissive · top 15,000 on PyPI
scripttestscripttest runs command-line applications in…
permissive · top 15,000 on PyPI
mkdocs-excludeA mkdocs plugin that excludes files and…
permissive · top 15,000 on PyPI
interegularInteregular checks whether pairs of Python…
permissive · top 5,000 on PyPI
LinkCheckerLinkChecker validates links across websites by…
copyleft · top 15,000 on PyPI
regexploitRegexploit analyzes regular expressions to…
permissive · top 15,000 on PyPI
shellcheck-pyProvides a pip-installable shellcheck binary…
permissive · top 5,000 on PyPI