Skip to main content

A testing library for running language/compiler tests from YAML metadata.

Project description

Compiler Testing Lib

A flexible, multi-language testing framework for compiler and language feature validation. Designed to run language-specific tests defined in YAML files, with support for running tests via Python, Docker, or as a CI/CD step.

Features

  • Multi-language support: Organize tests for Python, JavaScript, and more.
  • YAML-based test definitions: Centralized, versioned test metadata.
  • Pluggable runners: Run tests using Python, Node.js, or any command-line tool.
  • Docker integration: Build and run tests in isolated containers, with support for auto-cloning test repos.
  • PyPI package: Installable as compiler-testing-lib.
  • Submodule example repo: See compiler-testing-example for a ready-to-use test suite.

Directory Structure

compiler-testing-lib/           # Main library package
  compiler_testing_lib/
    __init__.py
    runner.py
    languages/                  # Test definitions and source files (per language/version)
      python/
        v1.0/
          test001.py
          test002.py
          test.yaml
  setup.py
  MANIFEST.in
  ...
compiler-testing-example/       # Example repo (as a git submodule)
images/                        # Docker build and run scripts
  python/
    Dockerfile
    run_in_container.py
  run.sh
  mount.sh
  clean.sh

Installation

As a Python Library

pip install compiler-testing-lib

For Local Development

pip install -e .

Install Example Requirements

pip install -r compiler-testing-example/requirements.txt

Usage

1. Run Tests via Python

from compiler_testing_lib.runner import TestRunner
runner = TestRunner(language='python', version='v1.0', max_errors=3, timeout=10, file_extension='py')
result = runner.run_tests(command_template='python3 main.py')
print(result)

2. Run Tests via Example Scripts

python3 compiler-testing-example/test.sh           # Python runner (default)
python3 compiler-testing-example/test.sh js        # Node.js runner

3. Run in Docker

Build the image:

cd images
./mount.sh

Run the container (auto-clones the example repo and runs tests):

./run.sh

Docker Image Details

  • Installs the latest compiler-testing-lib from PyPI.
  • Accepts --git_username and --git_repository to auto-clone a test repo.
  • Runs all tests and prints results to the terminal.

Adding/Updating Tests

  • Place new test files and update test.yaml in the appropriate languages/<lang>/<version>/ directory inside compiler_testing_lib/.
  • Rebuild and upload the package to PyPI for distribution.

Contributing

  1. Fork the repo and create a feature branch.
  2. Add or update tests in compiler_testing_lib/languages/.
  3. Update test.yaml as needed.
  4. Run tests locally or in Docker.
  5. Submit a pull request.

License

MIT


For more examples, see the compiler-testing-example submodule.

Project details


Download files

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

Source Distribution

compiler_testing_lib-0.1.11.tar.gz (28.7 kB view details)

Uploaded Source

Built Distribution

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

compiler_testing_lib-0.1.11-py3-none-any.whl (110.0 kB view details)

Uploaded Python 3

File details

Details for the file compiler_testing_lib-0.1.11.tar.gz.

File metadata

  • Download URL: compiler_testing_lib-0.1.11.tar.gz
  • Upload date:
  • Size: 28.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for compiler_testing_lib-0.1.11.tar.gz
Algorithm Hash digest
SHA256 3a3c457a38bd165f5b751f4f598f568d8ff356b319579164671a8d1f3030d5db
MD5 545e1a2d8aa6db8dcec845eeed060598
BLAKE2b-256 e6f16511771595eb222c885ef6e8a4c7c1a13604bdf029c6968771c0086f8ec1

See more details on using hashes here.

File details

Details for the file compiler_testing_lib-0.1.11-py3-none-any.whl.

File metadata

File hashes

Hashes for compiler_testing_lib-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 f1e2ecbfee478c56905dfc6a30c3e97fc4f8e16bc0d6883a637a8b7ddeaeb7f0
MD5 6238f751d3458e9666511a60f805baf7
BLAKE2b-256 33a8948c757a7d01ee5159461b8a4b8c57f9648de78085f314d062a2809424d7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page