Skip to content

Commit

Permalink
trying new approach with CUnit testing framework
Browse files Browse the repository at this point in the history
  • Loading branch information
umeneses committed May 10, 2024
1 parent 015894e commit d3e74d5
Show file tree
Hide file tree
Showing 6 changed files with 535 additions and 43 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/ci.yml → .github/workflows/build_program.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# #
# **************************************************************************** #

name: CI
name: build_program

on:
push:
Expand All @@ -20,15 +20,13 @@ on:

jobs:
build:

runs-on: ubuntu-latest

defaults:
run:
working-directory: src
steps:
- name: Starting github actions
uses: actions/checkout@v4.1.4

- name: Running Push_Swap Makefile
- name: Building Program with Push_Swap Makefile
run: make

- name: Running Tester
run: ./tester
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# ci.yml :+: :+: :+: #
# +:+ +:+ +:+ #
# By: umeneses <umeneses@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/05/09 19:12:18 by umeneses #+# #+# #
# Updated: 2024/05/09 19:17:48 by umeneses ### ########.fr #
# #
# **************************************************************************** #

name: test

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: _ci_tdd/test_files
steps:
- name: Starting github actions
uses: actions/checkout@v4.1.4

- name: Set up CUnit
run: sudo apt-get update && sudo apt-get install -y libcunit1 libcunit1-doc libcunit1-dev

- name: Running Tester Makefile
run: make
47 changes: 24 additions & 23 deletions _ci_tdd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# By: umeneses <umeneses@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/05/10 10:09:44 by umeneses #+# #+# #
# Updated: 2024/05/10 13:01:01 by umeneses ### ########.fr #
# Updated: 2024/05/10 17:56:12 by umeneses ### ########.fr #
# #
# **************************************************************************** #

Expand All @@ -26,26 +26,26 @@ RESET := \033[0m
# PATHS #
# **************************************************************************** #

TEST_D = ./test_files/
BUILD_D = ./test_build/
PUSH_SWAP_D = ../
HEADERS_ADDED = ../headers/
HEADERS = $(TEST_D) $(HEADERS_ADDED)
TEST_D = ./test_files/
BUILD_D = ./test_build/
PUSH_SWAP_D = ../program_to_test/
HEADERS_ADDED = $(PUSH_SWAP_D)headers/
HEADERS = $(TEST_D) $(HEADERS_ADDED)

# **************************************************************************** #
# FILES #
# **************************************************************************** #

PUSH_SWAP = $(addprefix $(PUSH_SWAP_D), push_swap)
LIBS = $(PUSH_SWAP_D)
PUSH_SWAP = $(addprefix $(PUSH_SWAP_D), push_swap)
LIBS = $(PUSH_SWAP_D)

NAME = tester
NAME = push_swap.tests

SRC_FILES = test_main.c
SRC_FILES = test_main.c

SRC_FILES_ALL = $(addprefix $(TEST_D), $(SRC_FILES))
SRC_FILES_ALL = $(addprefix $(TEST_D), $(SRC_FILES))

OBJ_FILES = $(addprefix $(BUILD_D), $(SRC_FILES_ALL:%.c=%.o))
OBJ_FILES = $(addprefix $(BUILD_D), $(SRC_FILES_ALL:%.c=%.o))

# **************************************************************************** #
# COMMANDS #
Expand All @@ -59,31 +59,32 @@ MV_OBJS = find . -type f \( -name '.o' -o -name '.a'\) -exec mv {} \
# COMPILATION #
# **************************************************************************** #

AUTHOR = umeneses
CC = cc
CFLAGS = -I.
CPPFLAGS = $(addprefix -I, $(HEADERS)) -MMD -MP
LDFLAGS = $(addprefix -L, $(dir $(LIBS)))
LDLIBS = -lpush_swap
COMP_OBJS = $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
COMP_EXE = $(CC) $(CFLAGS) -o $(NAME) $(OBJ_FILES) $(LDFLAGS) $(LDLIBS)
AUTHOR = umeneses
CC = cc
CFLAGS = -I .
CPPFLAGS = $(addprefix -I, $(SRC_FILES))
LDFLAGS = $(addprefix -L, $(dir $(LIBS)))
LDLIBS = -lft
COMP_OBJS = $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
COMP_EXE = $(CC) -o $(NAME) $(OBJ_FILES) -I . -I $(PUSH_SWAP_D) $(SRC_FILES_ALL) -L$(PUSH_SWAP_D) $(LDLIBS)

# **************************************************************************** #
# TARGETS #
# **************************************************************************** #

all: push_swap $(NAME)
all: fclean push_swap

$(BUILD_D)%.o: %.c
@$(MKDIR) $(dir $@)
@$(COMP_OBJS)
$(COMP_OBJS)
@echo "Compiling: $(notdir $<)"

$(NAME): $(OBJ_FILES)
@$(COMP_EXE)
$(COMP_EXE)
@printf "$(GREEN)"
@echo "$(NAME) Ready!"
@printf "$(RESET)"
@./$(NAME)

push_swap:
@printf "$(YELLOW)"
Expand Down
Loading

0 comments on commit d3e74d5

Please sign in to comment.