diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml new file mode 100644 index 0000000..1551468 --- /dev/null +++ b/.github/workflows/makefile.yml @@ -0,0 +1,24 @@ +name: Makefile CI + +on: + pull_request: + branches: [ "main" ] + release: + types: [published, created] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: make + + - name: Run check + run: make check + + - name: Run distcheck + run: make distcheck 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" diff --git a/README.md b/README.md index 5509416..94da7eb 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,10 @@ 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