Introduce a comprehensive unit test framework covering the core modules, including new test cases for data validation, error handling, and edge scenarios. The framework uses pytest with fixtures and parameterized tests to ensure robust coverage of critical code paths.
169 lines
5.5 KiB
Makefile
169 lines
5.5 KiB
Makefile
CC = gcc
|
|
CFLAGS = -Wall -Wextra -O2 -Isrc
|
|
LDFLAGS = -lm -lpthread
|
|
|
|
SRC_DIR = src
|
|
TEST_DIR = tests
|
|
EXAMPLE_DIR = examples
|
|
BUILD_DIR = build
|
|
BIN_DIR = bin
|
|
|
|
TARGET = $(BIN_DIR)/rc
|
|
|
|
SOURCES = $(SRC_DIR)/main.c \
|
|
$(SRC_DIR)/globals.c \
|
|
$(SRC_DIR)/tokenizer.c \
|
|
$(SRC_DIR)/parser.c \
|
|
$(SRC_DIR)/interpreter.c \
|
|
$(SRC_DIR)/native_functions.c \
|
|
$(SRC_DIR)/string_utils.c \
|
|
$(SRC_DIR)/preprocessor.c \
|
|
$(SRC_DIR)/oop.c \
|
|
$(SRC_DIR)/stdlib/stdlib.c \
|
|
$(SRC_DIR)/stdlib/string/string_stdlib.c \
|
|
$(SRC_DIR)/stdlib/math/math_stdlib.c \
|
|
$(SRC_DIR)/stdlib/io/file_stdlib.c \
|
|
$(SRC_DIR)/stdlib/io/socket_stdlib.c \
|
|
$(SRC_DIR)/stdlib/async/async_stdlib.c \
|
|
$(SRC_DIR)/stdlib/constants/constants_stdlib.c
|
|
|
|
OBJECTS = $(SOURCES:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.o)
|
|
|
|
TESTS = $(TEST_DIR)/unittest.rc \
|
|
$(TEST_DIR)/test_language_features.rc \
|
|
$(TEST_DIR)/test_stdlib_string.rc \
|
|
$(TEST_DIR)/test_stdlib_math.rc \
|
|
$(TEST_DIR)/test_stdlib_io.rc \
|
|
$(TEST_DIR)/test_stdlib_async.rc \
|
|
$(TEST_DIR)/test_oop.rc \
|
|
$(TEST_DIR)/test_preprocessor.rc \
|
|
$(TEST_DIR)/run_all_tests.rc
|
|
|
|
EXAMPLES = $(EXAMPLE_DIR)/http_simple.rc \
|
|
$(EXAMPLE_DIR)/http_persistent.rc \
|
|
$(EXAMPLE_DIR)/http_multi.rc \
|
|
$(EXAMPLE_DIR)/async_demo.rc
|
|
|
|
.PHONY: all clean test run-tests run-examples help
|
|
|
|
all: dirs $(TARGET)
|
|
|
|
dirs:
|
|
@mkdir -p $(BUILD_DIR) $(BIN_DIR)
|
|
@mkdir -p $(BUILD_DIR)/stdlib/string
|
|
@mkdir -p $(BUILD_DIR)/stdlib/math
|
|
@mkdir -p $(BUILD_DIR)/stdlib/io
|
|
@mkdir -p $(BUILD_DIR)/stdlib/async
|
|
@mkdir -p $(BUILD_DIR)/stdlib/constants
|
|
|
|
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
|
|
@mkdir -p $(dir $@)
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
$(TARGET): dirs $(OBJECTS)
|
|
$(CC) $(OBJECTS) -o $(TARGET) $(LDFLAGS)
|
|
|
|
clean:
|
|
rm -rf $(BUILD_DIR) $(BIN_DIR)
|
|
|
|
test: $(TARGET)
|
|
@echo "================================================================"
|
|
@echo " RC LANGUAGE - COMPREHENSIVE TEST SUITE"
|
|
@echo "================================================================"
|
|
@echo ""
|
|
@echo "[1/7] Running Language Features Tests..."
|
|
@$(TARGET) $(TEST_DIR)/test_language_features.rc
|
|
@echo ""
|
|
@echo "[2/7] Running String Standard Library Tests..."
|
|
@$(TARGET) $(TEST_DIR)/test_stdlib_string.rc
|
|
@echo ""
|
|
@echo "[3/7] Running Math Standard Library Tests..."
|
|
@$(TARGET) $(TEST_DIR)/test_stdlib_math.rc
|
|
@echo ""
|
|
@echo "[4/7] Running I/O Standard Library Tests..."
|
|
@$(TARGET) $(TEST_DIR)/test_stdlib_io.rc
|
|
@echo ""
|
|
@echo "[5/7] Running Async Standard Library Tests..."
|
|
@$(TARGET) $(TEST_DIR)/test_stdlib_async.rc
|
|
@echo ""
|
|
@echo "[6/7] Running OOP Features Tests..."
|
|
@$(TARGET) $(TEST_DIR)/test_oop.rc
|
|
@echo ""
|
|
@echo "[7/7] Running Preprocessor Tests..."
|
|
@$(TARGET) $(TEST_DIR)/test_preprocessor.rc
|
|
@echo ""
|
|
@echo "================================================================"
|
|
@echo "All comprehensive tests completed!"
|
|
@echo "================================================================"
|
|
|
|
test-smoke: $(TARGET)
|
|
@$(TARGET) $(TEST_DIR)/run_all_tests.rc
|
|
|
|
test-language: $(TARGET)
|
|
$(TARGET) $(TEST_DIR)/test_language_features.rc
|
|
|
|
test-string: $(TARGET)
|
|
$(TARGET) $(TEST_DIR)/test_stdlib_string.rc
|
|
|
|
test-math: $(TARGET)
|
|
$(TARGET) $(TEST_DIR)/test_stdlib_math.rc
|
|
|
|
test-io: $(TARGET)
|
|
$(TARGET) $(TEST_DIR)/test_stdlib_io.rc
|
|
|
|
test-async: $(TARGET)
|
|
$(TARGET) $(TEST_DIR)/test_stdlib_async.rc
|
|
|
|
test-oop: $(TARGET)
|
|
$(TARGET) $(TEST_DIR)/test_oop.rc
|
|
|
|
test-preprocessor: $(TARGET)
|
|
$(TARGET) $(TEST_DIR)/test_preprocessor.rc
|
|
|
|
run-http-simple: $(TARGET)
|
|
$(TARGET) $(EXAMPLE_DIR)/http_simple.rc
|
|
|
|
run-http-persistent: $(TARGET)
|
|
$(TARGET) $(EXAMPLE_DIR)/http_persistent.rc
|
|
|
|
run-http-multi: $(TARGET)
|
|
$(TARGET) $(EXAMPLE_DIR)/http_multi.rc
|
|
|
|
run-async-demo: $(TARGET)
|
|
$(TARGET) $(EXAMPLE_DIR)/async_demo.rc
|
|
|
|
help:
|
|
@echo "RC - Retoor's C Interpreter"
|
|
@echo ""
|
|
@echo "Usage:"
|
|
@echo " make - Build the interpreter"
|
|
@echo " make test - Run ALL comprehensive tests (178+ tests)"
|
|
@echo " make test-smoke - Run quick smoke test (31 tests)"
|
|
@echo " make clean - Remove all build artifacts"
|
|
@echo ""
|
|
@echo "Test Categories (organized by src/ structure):"
|
|
@echo " make test-language - Language features (63 tests)"
|
|
@echo " make test-string - String stdlib (31 tests)"
|
|
@echo " make test-math - Math stdlib (26 tests)"
|
|
@echo " make test-io - I/O stdlib (comprehensive)"
|
|
@echo " make test-async - Async stdlib (20+ tests)"
|
|
@echo " make test-oop - OOP features (31 tests)"
|
|
@echo " make test-preprocessor - Preprocessor (2 tests)"
|
|
@echo ""
|
|
@echo "Examples:"
|
|
@echo " make run-http-simple - Run http_simple.rc (single connection HTTP server)"
|
|
@echo " make run-http-persistent - Run http_persistent.rc (persistent HTTP server)"
|
|
@echo " make run-http-multi - Run http_multi.rc (HTTP server, 100 connections)"
|
|
@echo " make run-async-demo - Run async_demo.rc (comprehensive async I/O demo)"
|
|
@echo ""
|
|
@echo "Directory Structure:"
|
|
@echo " src/ - Source code files"
|
|
@echo " stdlib/string/ - String functions"
|
|
@echo " stdlib/math/ - Math functions"
|
|
@echo " stdlib/io/ - I/O functions"
|
|
@echo " stdlib/async/ - Async functions"
|
|
@echo " tests/ - Test programs (unittest framework)"
|
|
@echo " examples/ - Example programs (.rc files)"
|
|
@echo " build/ - Compiled object files"
|
|
@echo " bin/ - Final executable (rc)"
|