Skip to content

It’s a small Python testing framework to run a tool (compiler/analyzer) and validate its output. Each test defines input sources and options, then checks the exit code, the presence of the produced binary and its format (ELF/Mach-O), and/or specific content in stdout/stderr. Tests run in a temporary workspace and use a simple reporter.

License

Notifications You must be signed in to change notification settings

CoreTrace/coretrace-testkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

coretrace-testkit

Minimal Python test framework used across CoreTrace repos.

Install (editable)

python3 -m pip install -e .

Install (from git)

python3 -m pip install "git+https://github.com/CoreTrace/coretrace-testkit.git"
# or using SSH
python3 -m pip install "git+ssh://git@github.com/CoreTrace/coretrace-testkit.git"

Import

from ctestfw.runner import CompilerRunner, RunnerConfig

Example (minimal)

from pathlib import Path

from ctestfw.runner import CompilerRunner, RunnerConfig
from ctestfw.plan import CompilePlan
from ctestfw.framework.testcase import TestCase
from ctestfw.framework.suite import TestSuite
from ctestfw.assertions.compiler import (
    assert_exit_code,
    assert_output_exists,
    assert_native_binary_kind,
)

# Runner (your compiler/driver)
runner = CompilerRunner(
    RunnerConfig(
        executable=Path("/usr/bin/clang"),  # adjust to your tool
        default_timeout_s=20.0,
        default_env=None,
    )
)

# Compile plan
plan = CompilePlan(
    name="hello",
    sources=[Path("/absolute/path/to/hello.c")],
    out=Path("hello"),
    extra_args=["-O2"],
)

# Test case + assertions
case = TestCase(
    name="hello_builds",
    plan=plan,
    assertions=[
        assert_exit_code(0),
        assert_output_exists(),
        assert_native_binary_kind(),
    ],
)

# Suite + run
suite = TestSuite(name="smoke", cases=[case])
report = suite.run(runner, root_workspace=Path("tmp/ctestfw"))

print(report.ok())
for r in report.reports:
    print(r.name, r.ok, r.errors)

About

It’s a small Python testing framework to run a tool (compiler/analyzer) and validate its output. Each test defines input sources and options, then checks the exit code, the presence of the produced binary and its format (ELF/Mach-O), and/or specific content in stdout/stderr. Tests run in a temporary workspace and use a simple reporter.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages