A lightweight, configurable C test‑runner with colored output and folder‑based grouping.
- General Information
- Technologies Used
- Features
- Screenshots
- Setup
- Usage
- Project Status
- Room for Improvement
- Acknowledgements
- Contact
- License
"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.
- C99 ( with GNU extensions )
- Bash scripting
- fd ( file finder )
- ccache ( compiler cache )
- 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
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- Define your code parts in the top‑level config.sh ( e.g. folder names in
partsToBuild). - Under "tests/", create a subdirectory ( e.g. tests/stdfunc/ ) with its own config.sh that sets FILES_TO_COMPILE="...".
- Write tests using the
TEST(name) { … }andASSERT\_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.shThe script will compile your parts, build each test suite, and then link and execute main.out_test, printing colored results.
Project is: complete. It reliably builds and runs grouped tests with colored output and a summary.
Room for improvement:
- Parallel test execution
To do:
- Add code coverage reporting
- Integrate with CI
No external tutorials were used — this is a ground‑up implementation.
Created by @lurkydismal - feel free to contact me!
This project is open source and available under the GNU Affero General Public License v3.0.
