Skip to content
This repository was archived by the owner on Sep 14, 2025. It is now read-only.

lurkydismal/test

test

A lightweight, configurable C test‑runner with colored output and folder‑based grouping.

Table of Contents

General Information

"test" is a minimal test‑runner framework for C projects. It automates building your code and running folders of tests, printing colored pass/ fail output and a summary at the end. You can configure compiler flags, include paths, and test groups simply by editing "config.sh" file — no hard‑coding required.

Technologies Used

  • C99 ( with GNU extensions )
  • Bash scripting
  • fd ( file finder )
  • ccache ( compiler cache )

Features

  • Colored output
  • Folder‑based test grouping — each subdirectory under "tests/" is its own suite, but not named in run
  • Customizable via shell‑exported variables in "config.sh"
  • Summary of total passed and failed tests
  • Clean build directories before build; removes old ".o" files automatically

Screenshots

Example screenshot

Setup

Requirements:

  • "gcc" ( or any C99‑compatible compiler )
  • "bash"
  • "fd" ( a modern alternative to "find" )
  • "ccache" ( optional, for faster rebuilds )

Clone or download this repo, then ensure "build.sh" is executable:

chmod +x build.sh

Usage

  1. Define your code parts in the top‑level config.sh ( e.g. folder names in partsToBuild ).
  2. Under "tests/", create a subdirectory ( e.g. tests/stdfunc/ ) with its own config.sh that sets FILES_TO_COMPILE="...".
  3. Write tests using the TEST(name) { … } and ASSERT\_TRUE / ASSERT\_FALSE, other macros in C/ C++ files specified by FILES_TO_COMPILE.

Example test:

TEST(stringToBool) {
    ASSERT_TRUE( stringToBool("true") );
    ASSERT_FALSE( stringToBool("false") );
    ASSERT_EQ( "%u", 1 + 1, 2 );
    ASSERT_NOT_EQ( "%u", 2 + 2, 5 );
    ASSERT_STRING_EQ( "String1", "String1" );
    ASSERT_STRING_NOT_EQ( "String1", "String2" );
}

Run the full suite:

./build.sh

The script will compile your parts, build each test suite, and then link and execute main.out_test, printing colored results.

Project Status

Project is: complete. It reliably builds and runs grouped tests with colored output and a summary.

Room for Improvement

Room for improvement:

  • Parallel test execution

To do:

  • Add code coverage reporting
  • Integrate with CI

Acknowledgements

No external tutorials were used — this is a ground‑up implementation.

Contact

Created by @lurkydismal - feel free to contact me!

License

This project is open source and available under the GNU Affero General Public License v3.0.