LLVM Integrated Tester (lit)

18.1.8 · active · verified Sat Apr 11

lit (LLVM Integrated Tester) is a portable command-line tool for executing LLVM and Clang style test suites, summarizing their results, and providing indication of failures. It is designed to be lightweight and flexible, supporting parallel test execution and various test formats. The current version is 18.1.8 and is actively maintained as part of the LLVM project.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up a basic `lit` test suite. It involves creating a `lit.cfg.py` configuration file that `lit` uses to understand how to find and run tests, and a simple test file with `RUN` and `CHECK` directives. `lit` is then invoked from the command line against the test directory.

# 1. Create a test directory and a lit configuration file:
# my_project/
# ├── lit.cfg.py
# └── tests/
#     └── my_test.txt

# --- lit.cfg.py ---
# This file is executed by lit to configure the test suite.
# Define standard test formats.
import lit.formats

config.name = 'MyProject'
config.test_format = lit.formats.ShTest(not_tool='/usr/bin/not')
config.suffixes = ['.txt']

# Add an optional path to tools if they are not in PATH
# config.substitutions = [('%my_tool', '/path/to/my_tool')]

# --- tests/my_test.txt ---
# RUN: echo "Hello, lit!" | FileCheck %s
# CHECK: Hello, lit!

# --- Run lit from the project root ---
# In your terminal:
# cd my_project
# lit tests/

view raw JSON →