From dd01bfdf5f185c5ea8c1a81d662ef68489cf287d Mon Sep 17 00:00:00 2001 From: Neal King <50931322+knealking@users.noreply.github.com> Date: Sat, 31 May 2025 23:20:52 -0700 Subject: [PATCH 1/5] Create makefile.yml --- .github/workflows/makefile.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/makefile.yml diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml new file mode 100644 index 0000000..8789c17 --- /dev/null +++ b/.github/workflows/makefile.yml @@ -0,0 +1,27 @@ +name: Makefile CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: configure + run: ./configure + + - name: Install dependencies + run: make + + - name: Run check + run: make check + + - name: Run distcheck + run: make distcheck From 5de556648c550db8486a1e3fbedf6943a56c9bea Mon Sep 17 00:00:00 2001 From: knealking <50931322+knealking@users.noreply.github.com> Date: Sat, 31 May 2025 23:40:15 -0700 Subject: [PATCH 2/5] fix: remove failing test program and add check/distcheck targets --- Makefile | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index c180ea9..7c5f1c7 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,6 @@ LIB_SOURCES := assertc \ # Test programs to build from tests directory TEST_PROGRAMS := example_test_ok \ - example_test_fail \ example_test_all \ # Object files @@ -30,7 +29,7 @@ TEST_BINARIES := $(patsubst %,$(BIN_DIR)/%,$(TEST_PROGRAMS)) DEBUG_BINARIES := $(patsubst %,$(BUILD_DIR)/%,$(TEST_PROGRAMS)) # Default target -.PHONY: all clean debug release tests directories help +.PHONY: all clean debug release tests directories help check distcheck all: directories debug release @@ -67,9 +66,17 @@ release: directories $(TEST_BINARIES) tests: $(TEST_BINARIES) @for test in $(TEST_BINARIES); do \ echo "Running $$test..."; \ - ./$$test; \ + ./$$test || exit 1; \ done +# Check target - build and run tests +check: release tests + @echo "All tests passed successfully!" + +# Distcheck target - comprehensive testing with clean build +distcheck: clean all tests + @echo "All tests passed successfully!" + # Clean build artifacts clean: rm -rf $(OBJ_DIR) $(BIN_DIR) $(BUILD_DIR) @@ -81,6 +88,8 @@ help: @echo " debug - Build debug versions" @echo " release - Build release versions" @echo " tests - Run all tests" + @echo " check - Build and run tests" + @echo " distcheck - Clean build and comprehensive testing" @echo " clean - Remove all build artifacts" @echo " directories - Create build directories" @echo " help - Show this help message" From 1210cc784d50ee59e3863f65382d17e010a89d05 Mon Sep 17 00:00:00 2001 From: knealking <50931322+knealking@users.noreply.github.com> Date: Sat, 31 May 2025 23:40:58 -0700 Subject: [PATCH 3/5] refac: added notes for failed tests and example tests --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 475edbb..f79b56e 100644 --- a/README.md +++ b/README.md @@ -51,12 +51,16 @@ The framework provides three main assertion macros: running 3 tests test my_test_name ... ok test another_test ... ok -test failing_test ... ✗ assert_eq failed: expected 5, got 4 +test failing_test ... ✗ assert_eq failed: expected 5, got 4 FAILED test result: FAILED. 2 passed; 1 failed ``` +Look at the `tests/` directory for more examples. + +⚠️ **Important Note**: `example_test_fail.c` is excluded from Makefile, to pass build. + ### Building and Running Compile your test file with the framework: @@ -91,10 +95,6 @@ TEST_DEPS_your_test = $(SRCDIR)/your_module.c $(assertc) 5. **Keep tests independent** - Each test should be able to run in isolation 6. **Use consistent test data** - Define test arrays as static variables for reuse -## Example Test File - -See `tests/example_test.c` for a comprehensive example of how to structure unit tests using this framework. - ## Key Differences from Traditional C Testing ### Traditional Approach From c6112b754956bb8567041b8d7e6820e8cc41aeb3 Mon Sep 17 00:00:00 2001 From: knealking <50931322+knealking@users.noreply.github.com> Date: Sat, 31 May 2025 23:44:21 -0700 Subject: [PATCH 4/5] fix: update workflow triggers to include release events --- .github/workflows/makefile.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml index 8789c17..669ad93 100644 --- a/.github/workflows/makefile.yml +++ b/.github/workflows/makefile.yml @@ -1,10 +1,10 @@ name: Makefile CI on: - push: - branches: [ "main" ] pull_request: branches: [ "main" ] + release: + types: [published, created] jobs: build: From bfec9aff4db8fc407181ff6f377464cac43698fc Mon Sep 17 00:00:00 2001 From: knealking <50931322+knealking@users.noreply.github.com> Date: Sat, 31 May 2025 23:50:18 -0700 Subject: [PATCH 5/5] fix: remove configure step from CI workflow --- .github/workflows/makefile.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml index 669ad93..1551468 100644 --- a/.github/workflows/makefile.yml +++ b/.github/workflows/makefile.yml @@ -14,9 +14,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: configure - run: ./configure - - name: Install dependencies run: make