skillfed

filecheck

A Python-native clone of LLVMs FileCheck tool

filecheck v1.0.3 395.0K downloads/30d#6,985 on PyPI24
Permissive license Apache-2.0 AGING released

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 filecheck

uv

uv add filecheck

poetry

poetry add filecheck

Installing 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

License :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13

Tags

llvm filecheck pythontext output pattern matching testsfilecheck clonevalidate compiler outputcheck directives testing
compiler-testingpattern-matchingllvm

More Testing packages