From b015318b77cd3ac3e46d76b1a8e6c9bc8472d6ca Mon Sep 17 00:00:00 2001 From: Jose Felipe Dalcin Stieven Date: Fri, 23 Feb 2024 17:12:17 -0300 Subject: [PATCH 01/12] Makefile: put sources codes explicit filenames. 09_push_swap.c : Fixed incorrect reference to stack A on push_dial. --- Makefile | 61 ++---------------------------------------- sources/09_push_swap.c | 4 +-- 2 files changed, 4 insertions(+), 61 deletions(-) diff --git a/Makefile b/Makefile index 976459d..747db20 100644 --- a/Makefile +++ b/Makefile @@ -18,8 +18,6 @@ DFLAGS = -g3 # Paths for libraries LIB_PATH = ./lib LIB_NAME = libft.a -# LIB_PRINTF_NAME = libftprintf.a -# LIB_PRINTF_PATH = ./lib/ft_printf # Colors Definition GREEN = "\033[32;1m" @@ -33,9 +31,8 @@ HEADER_PATH = ./includes/ HEADER = $(HEADER_PATH)push_swap.h OBJ_PATH = ./obj/ DEBUG_OBJ_PATH = ./obj_debug/ -TESTS_PATH = ./tests/ SOURCES_PATH = ./sources/ -SOURCES = $(shell find sources/ -name "*.c" | cut -d/ -f2) +SOURCES = 00_main.c 01_user_input_validation.c 02_indexing.c 03_do_moves.c 03_moves.c 04_pre_sort.c 05_target_position.c 06_comp_cost.c 07_cheapest_move.c 08_sort.c 09_push_swap.c 10_dial.c 93_utils.c 94_utils.c 95_utils.c 96_utils.c 97_utils.c 98_utils.c 99_2_utils.c 99_utils.c MANDATORY_SOURCES = $(addprefix $(SOURCES_PATH), $(SOURCES)) ifdef WITH_DEBUG @@ -44,41 +41,12 @@ ifdef WITH_DEBUG OBJ_PATH = ./obj_debug/ endif -ifdef DEBUG - ifeq ($(DEBUG),1) - CFLAGS += $(DFLAGS) -D DEBUG=1 - else ifeq ($(DEBUG),2) - CFLAGS += $(DFLAGS) -D DEBUG=2 - else ifeq ($(DEBUG),3) - CFLAGS += $(DFLAGS) -D DEBUG=3 - else ifeq ($(DEBUG),4) - CFLAGS += $(DFLAGS) -D DEBUG=4 - else ifeq ($(DEBUG),5) - CFLAGS += $(DFLAGS) -D DEBUG=5 - else ifeq ($(DEBUG),6) - CFLAGS += $(DFLAGS) -D DEBUG=6 - else ifeq ($(DEBUG),7) - CFLAGS += $(DFLAGS) -D DEBUG=7 - else ifeq ($(DEBUG),8) - CFLAGS += $(DFLAGS) -D DEBUG=8 - else ifeq ($(DEBUG),9) - CFLAGS += $(DFLAGS) -D DEBUG=9 - else ifeq ($(DEBUG),10) - CFLAGS += $(DFLAGS) -D DEBUG=10 - else ifeq ($(DEBUG),11) - CFLAGS += $(DFLAGS) -D DEBUG=11 - endif -endif - OBJECTS = $(addprefix $(OBJ_PATH), $(SOURCES:%.c=%.o)) all: libft $(OBJ_PATH) $(NAME) libft: @make --directory=$(LIB_PATH) --no-print-directory - -# libftprintf: -# @make --directory=$(LIB_PRINTF_PATH) --no-print-directory debug: @make WITH_DEBUG=TRUE --no-print-directory @@ -98,43 +66,18 @@ $(OBJ_PATH)%.o: $(SOURCES_PATH)%.c $(HEADER) $(CC) $(CFLAGS) -c $< -o $@ -I $(HEADER_PATH) @echo " " -valgrind: debug - @echo $(GREEN)[Running memory checks]$(COLOR_LIMITER) - @wget -nc https://raw.githubusercontent.com/jos-felipe/pipex/master/memory_checker.sh > /dev/null 2>&1 - @chmod +x memory_checker.sh - @./memory_checker.sh - -nor: - @echo $(GREEN)[Running Norminette]$(COLOR_LIMITER) - @norminette -R CheckForbiddenSourceHeader $(SOURCES_PATH) $(HEADER_PATH) - @echo $(GREEN)[Running Norminette on Libft]$(COLOR_LIMITER) - @norminette -R CheckForbiddenSourceHeader $(LIB_PATH) - @echo $(GREEN)[Running Norminette on Libftprintf]$(COLOR_LIMITER) - @norminette -R CheckForbiddenSourceHeader $(LIB_PRINTF_PATH) - -tester: all - @echo $(GREEN)[Running tests]$(COLOR_LIMITER) - @wget -nc https://raw.githubusercontent.com/jos-felipe/pipex/master/funcional_checker.sh > /dev/null 2>&1 - @chmod +x funcional_checker.sh - @./funcional_checker.sh - -qa: nor tester valgrind - clean: @echo $(RED)[Removing Objects]$(COLOR_LIMITER) -rm -rf $(OBJ_PATH) -rm -rf $(DEBUG_OBJ_PATH) - @echo $(RED)[Removing test files]$(COLOR_LIMITER) - -rm -rf $(TESTS_PATH) fclean: clean @echo $(RED)[Removing $(NAME) executable]$(COLOR_LIMITER) @rm -rf $(NAME) @rm -rf $(DEBUG_NAME) @make fclean -C $(LIB_PATH) --no-print-directory -# @make fclean -C $(LIB_PRINTF_PATH) --no-print-directory re: fclean @make --no-print-directory -.PHONY: all clean fclean re libft libftprintf debug valgrind tester nor +.PHONY: all clean fclean re libft debug diff --git a/sources/09_push_swap.c b/sources/09_push_swap.c index 1c9038e..5b32b3f 100644 --- a/sources/09_push_swap.c +++ b/sources/09_push_swap.c @@ -6,7 +6,7 @@ /* By: josfelip +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/22 15:06:28 by gfantoni #+# #+# */ -/* Updated: 2024/02/23 12:21:37 by josfelip ### ########.fr */ +/* Updated: 2024/02/23 17:05:50 by josfelip ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,5 +21,5 @@ void push_swap(t_list_push **a, t_list_push **b, int *rotations) push_cheapest_move(*b, rotations); push_sort(a, b, rotations); } - push_dial(&a); + push_dial(a); } From 5b4ddd5098babb594ac7568ea363491a0fc03209 Mon Sep 17 00:00:00 2001 From: Guilherme Fantoni Borges Date: Fri, 23 Feb 2024 18:02:17 -0300 Subject: [PATCH 02/12] test 00 added and aproved. --- qa/evaluator.py | 6 + .../_00_preparing_environment.py | 8 ++ qa/test.ipynb | 118 +----------------- sources/09_push_swap.c | 6 +- 4 files changed, 22 insertions(+), 116 deletions(-) create mode 100644 qa/evaluator_modules/_00_preparing_environment.py diff --git a/qa/evaluator.py b/qa/evaluator.py index 428253f..89c0e46 100755 --- a/qa/evaluator.py +++ b/qa/evaluator.py @@ -10,6 +10,7 @@ from evaluator_modules import _06_advanced_version from evaluator_modules import _07_nothing_on_string from evaluator_modules import _08_only_space_on_string +from evaluator_modules import _00_preparing_environment # Constant args program = ["../push_swap"] @@ -28,6 +29,11 @@ make = ["make", "-C", "../"] subprocess.run(make, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) +# Preparing environment +print("Preparing environment") +_00_preparing_environment.preparing_environment() +print("\n") + # Error management test print("Error management") _01_error_management.error_management(program, valgrind, valgrind_check, colours) diff --git a/qa/evaluator_modules/_00_preparing_environment.py b/qa/evaluator_modules/_00_preparing_environment.py new file mode 100644 index 0000000..687d922 --- /dev/null +++ b/qa/evaluator_modules/_00_preparing_environment.py @@ -0,0 +1,8 @@ +import subprocess + +def preparing_environment(): + arg = "wget -P ../ -nc https://cdn.intra.42.fr/document/document/23675/checker_linux" + arg_chmod = "chmod +x ../checker_linux" + + subprocess.run(arg, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, shell=True) + subprocess.run(arg_chmod, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, shell=True) \ No newline at end of file diff --git a/qa/test.ipynb b/qa/test.ipynb index 5663c47..3f73ec7 100644 --- a/qa/test.ipynb +++ b/qa/test.ipynb @@ -2,124 +2,16 @@ "cells": [ { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "pb\n", - "pb\n", - "pb\n", - "pa\n", - "rb\n", - "pa\n", - "rra\n", - "rra\n", - "pa\n", - "rra\n", - "rra\n", - "\n", - "\n", - "11\n" - ] - } - ], + "outputs": [], "source": [ "import subprocess\n", "\n", - "program = [\"../push_swap\"]\n", - "arg = [\"6\", \"3\", \"1\", \"2\", \"4\", \"5\"]\n", - "cmd = program + arg\n", + "arg_wget = \"wget -P ../ -nc https://cdn.intra.42.fr/document/document/23675/checker_linux\"\n", + "arg_chmod = \"chmod +x ../checker_linux\"\n", "\n", - "output = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)\n", - "print(output.stdout)\n", - "print(output.stderr)\n", - "\n", - "print(output.stdout.count(\"\\n\"))" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[58, 60, 69, 34, 50, 18, 75, 30, 95, 99, 76, 88, 29, 80, 24, 51, 91, 53, 20, 77, 92, 4, 71, 23, 22, 90, 17, 55, 36, 13, 81, 47, 93, 85, 1, 31, 0, 46, 70, 63, 8, 37, 5, 19, 84, 97, 44, 12, 2, 89, 9, 94, 68, 86, 41, 78, 32, 82, 40, 73, 87, 52, 96, 6, 27, 3, 21, 38, 79, 61, 57, 59, 56, 67, 49, 35, 72, 98, 11, 26, 62, 83, 10, 42, 33, 43, 65, 74, 54, 28, 16, 25, 64, 39, 7, 66, 14, 45, 15, 48]\n", - "['58', '60', '69', '34', '50', '18', '75', '30', '95', '99', '76', '88', '29', '80', '24', '51', '91', '53', '20', '77', '92', '4', '71', '23', '22', '90', '17', '55', '36', '13', '81', '47', '93', '85', '1', '31', '0', '46', '70', '63', '8', '37', '5', '19', '84', '97', '44', '12', '2', '89', '9', '94', '68', '86', '41', '78', '32', '82', '40', '73', '87', '52', '96', '6', '27', '3', '21', '38', '79', '61', '57', '59', '56', '67', '49', '35', '72', '98', '11', '26', '62', '83', '10', '42', '33', '43', '65', '74', '54', '28', '16', '25', '64', '39', '7', '66', '14', '45', '15', '48']\n", - "[58, 60, 69, 34, 50, 18, 75, 30, 95, 99, 76, 88, 29, 80, 24, 51, 91, 53, 20, 77, 92, 4, 71, 23, 22, 90, 17, 55, 36, 13, 81, 47, 93, 85, 1, 31, 0, 46, 70, 63, 8, 37, 5, 19, 84, 97, 44, 12, 2, 89, 9, 94, 68, 86, 41, 78, 32, 82, 40, 73, 87, 52, 96, 6, 27, 3, 21, 38, 79, 61, 57, 59, 56, 67, 49, 35, 72, 98, 11, 26, 62, 83, 10, 42, 33, 43, 65, 74, 54, 28, 16, 25, 64, 39, 7, 66, 14, 45, 15, 48]\n", - "['../push_swap', '58', '60', '69', '34', '50', '18', '75', '30', '95', '99', '76', '88', '29', '80', '24', '51', '91', '53', '20', '77', '92', '4', '71', '23', '22', '90', '17', '55', '36', '13', '81', '47', '93', '85', '1', '31', '0', '46', '70', '63', '8', '37', '5', '19', '84', '97', '44', '12', '2', '89', '9', '94', '68', '86', '41', '78', '32', '82', '40', '73', '87', '52', '96', '6', '27', '3', '21', '38', '79', '61', '57', '59', '56', '67', '49', '35', '72', '98', '11', '26', '62', '83', '10', '42', '33', '43', '65', '74', '54', '28', '16', '25', '64', '39', '7', '66', '14', '45', '15', '48']\n" - ] - } - ], - "source": [ - "import random\n", - "\n", - "numbers_100 = list(range(0, 100, 1))\n", - "random.shuffle(numbers_100)\n", - "arg = [str(i) for i in numbers_100]\n", - "arg_checker = ' '.join(arg)\n", - "arg_checker = \"'\" + arg_checker + \"'\"\n", - "\n", - "print(numbers_100)\n", - "print(arg)\n", - "print(numbers_100)\n", - "\n", - "program = [\"../push_swap\"]\n", - "cmd = program + arg\n", - "\n", - "print(cmd)" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "../push_swap '13 5 1 11 -3 19 17 15 -5 0 2'\n" - ] - } - ], - "source": [ - "program = [\"../push_swap\"]\n", - "program = program[0]\n", - "arg = \" '13 5 1 11 -3 19 17 15 -5 0 2'\"\n", - "cmd = program + arg\n", - "\n", - "print(cmd)" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ../push_swap ' '\n" - ] - } - ], - "source": [ - "program = [\"../push_swap\"]\n", - "program_shell_true = program[0]\n", - "\n", - "valgrind = [\"valgrind\", \"--leak-check=full\", \"--show-leak-kinds=all\", \"--track-origins=yes\"]\n", - "valgrind_shell_true = valgrind[0] + ' ' + valgrind[1] + ' ' + valgrind[2] + ' ' + valgrind[3]\n", - "\n", - "arg = \"' '\"\n", - "\n", - "print(valgrind_shell_true + ' ' + program_shell_true + ' ' + arg)" + "subprocess.run(arg_wget, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, shell=True)" ] } ], diff --git a/sources/09_push_swap.c b/sources/09_push_swap.c index 1c9038e..7a6771a 100644 --- a/sources/09_push_swap.c +++ b/sources/09_push_swap.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* 09_push_swap.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: josfelip +#+ +:+ +#+ */ +/* By: gfantoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/22 15:06:28 by gfantoni #+# #+# */ -/* Updated: 2024/02/23 12:21:37 by josfelip ### ########.fr */ +/* Updated: 2024/02/23 17:43:54 by gfantoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,5 +21,5 @@ void push_swap(t_list_push **a, t_list_push **b, int *rotations) push_cheapest_move(*b, rotations); push_sort(a, b, rotations); } - push_dial(&a); + push_dial(a); } From 7c4c7f1834d2e4733daa8cd084883beb1dc9cc35 Mon Sep 17 00:00:00 2001 From: Guilherme Fantoni Borges Date: Fri, 23 Feb 2024 18:35:09 -0300 Subject: [PATCH 03/12] 00 test output displayed. --- qa/evaluator.py | 2 +- qa/evaluator_modules/_00_preparing_environment.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qa/evaluator.py b/qa/evaluator.py index 89c0e46..a73921c 100755 --- a/qa/evaluator.py +++ b/qa/evaluator.py @@ -30,7 +30,7 @@ subprocess.run(make, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) # Preparing environment -print("Preparing environment") +print("\nPreparing environment") _00_preparing_environment.preparing_environment() print("\n") diff --git a/qa/evaluator_modules/_00_preparing_environment.py b/qa/evaluator_modules/_00_preparing_environment.py index 687d922..0698116 100644 --- a/qa/evaluator_modules/_00_preparing_environment.py +++ b/qa/evaluator_modules/_00_preparing_environment.py @@ -1,8 +1,8 @@ import subprocess def preparing_environment(): - arg = "wget -P ../ -nc https://cdn.intra.42.fr/document/document/23675/checker_linux" + arg_wget = "wget -P ../ -nc https://cdn.intra.42.fr/document/document/23675/checker_linux" arg_chmod = "chmod +x ../checker_linux" - subprocess.run(arg, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, shell=True) + subprocess.run(arg_wget, text=True, shell=True) subprocess.run(arg_chmod, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, shell=True) \ No newline at end of file From c1c26afd4e65539dc88eb77627106d0b4ee40940 Mon Sep 17 00:00:00 2001 From: Jose Felipe Dalcin Stieven Date: Fri, 23 Feb 2024 18:40:07 -0300 Subject: [PATCH 04/12] Actions: evaluator added --- .github/workflows/evaluator.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/evaluator.yml diff --git a/.github/workflows/evaluator.yml b/.github/workflows/evaluator.yml new file mode 100644 index 0000000..ffebc41 --- /dev/null +++ b/.github/workflows/evaluator.yml @@ -0,0 +1,17 @@ +name: Evaluator + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + test: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: evaluator + run: cd qa && ./evaluator.py From a2a170d209be39243a2276965d3676d877f07430 Mon Sep 17 00:00:00 2001 From: Guilherme Fantoni Borges Date: Fri, 23 Feb 2024 18:56:54 -0300 Subject: [PATCH 05/12] python exit_status created. --- qa/evaluator.py | 24 ++++++++++++------- qa/evaluator_modules/_01_error_management.py | 8 +++++-- qa/evaluator_modules/_02_identity_test.py | 8 +++++-- qa/evaluator_modules/_03_simple_version.py | 8 +++++-- .../_04_another_simple_version.py | 8 +++++-- qa/evaluator_modules/_05_middle_version.py | 8 +++++-- qa/evaluator_modules/_06_advanced_version.py | 8 +++++-- qa/evaluator_modules/_07_nothing_on_string.py | 6 ++++- .../_08_only_space_on_string.py | 8 +++++-- 9 files changed, 62 insertions(+), 24 deletions(-) diff --git a/qa/evaluator.py b/qa/evaluator.py index a73921c..941a835 100755 --- a/qa/evaluator.py +++ b/qa/evaluator.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import subprocess +import sys from evaluator_modules import _01_error_management from evaluator_modules import _02_identity_test @@ -12,6 +13,9 @@ from evaluator_modules import _08_only_space_on_string from evaluator_modules import _00_preparing_environment +# Exit Status +exit_status = 0 + # Constant args program = ["../push_swap"] valgrind = ["valgrind", "--leak-check=full", "--show-leak-kinds=all", "--track-origins=yes"] @@ -36,42 +40,44 @@ # Error management test print("Error management") -_01_error_management.error_management(program, valgrind, valgrind_check, colours) +exit_status = _01_error_management.error_management(program, valgrind, valgrind_check, colours, exit_status) print("\n") # Identity test print("Identity test") -_02_identity_test.identity_test(program, valgrind, valgrind_check, colours) +exit_status = _02_identity_test.identity_test(program, valgrind, valgrind_check, colours, exit_status) print("\n") # Simple version print("Simple version") -_03_simple_version.simple_version(program, valgrind, valgrind_check, colours) +exit_status = _03_simple_version.simple_version(program, valgrind, valgrind_check, colours, exit_status) print("\n") # Another simple version print("Another simple version") -_04_another_simple_version.another_simple_version(program, valgrind, valgrind_check, colours) +exit_status = _04_another_simple_version.another_simple_version(program, valgrind, valgrind_check, colours, exit_status) print("\n") # Middle version print("Middle version") -_05_middle_version.middle_version(program, valgrind, valgrind_check, colours) +exit_status = _05_middle_version.middle_version(program, valgrind, valgrind_check, colours, exit_status) print("\n") # Advanced version print("Advanced version") -_06_advanced_version.advanced_version(program, valgrind, valgrind_check, colours) +exit_status = _06_advanced_version.advanced_version(program, valgrind, valgrind_check, colours, exit_status) print("\n") # Nothing on string print("Nothing on string") -_07_nothing_on_string.nothing_on_string(program, valgrind, valgrind_check, colours) +exit_status = _07_nothing_on_string.nothing_on_string(program, valgrind, valgrind_check, colours, exit_status) print("\n") # Only space on string print("Only space on string") -_08_only_space_on_string.only_space_on_string(program, valgrind, valgrind_check, colours) +exit_status = _08_only_space_on_string.only_space_on_string(program, valgrind, valgrind_check, colours, exit_status) print("\n") -subprocess.run(clean, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) \ No newline at end of file +subprocess.run(clean, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + +exit(exit_status) \ No newline at end of file diff --git a/qa/evaluator_modules/_01_error_management.py b/qa/evaluator_modules/_01_error_management.py index 271a27b..ec0526e 100644 --- a/qa/evaluator_modules/_01_error_management.py +++ b/qa/evaluator_modules/_01_error_management.py @@ -1,6 +1,6 @@ import subprocess -def error_management(program, valgrind, valgrind_check, colours): +def error_management(program, valgrind, valgrind_check, colours, exit_status): # Creating args battery = ["str on list", "dup on list", "max on list", "nothing on list"] @@ -33,8 +33,12 @@ def error_management(program, valgrind, valgrind_check, colours): print(f"{colours[0]}{i + 1}. OK{colours[2]}") else: print(f"{colours[1]}{i + 1}. KO{colours[2]}") + exit_status = 1 if valgrind_check in err_val: print(f"{colours[0]} MOK\n{colours[2]}") else: print(f"{colours[1]} MKO\n{colours[2]}") - i = i + 1 \ No newline at end of file + exit_status = 1 + i = i + 1 + + return (exit_status) \ No newline at end of file diff --git a/qa/evaluator_modules/_02_identity_test.py b/qa/evaluator_modules/_02_identity_test.py index 6585ac0..330599e 100644 --- a/qa/evaluator_modules/_02_identity_test.py +++ b/qa/evaluator_modules/_02_identity_test.py @@ -1,6 +1,6 @@ import subprocess -def identity_test(program, valgrind, valgrind_check, colours): +def identity_test(program, valgrind, valgrind_check, colours, exit_status): # Creating args battery = ["One arg ordered", "Two args ordered", "Four args ordered", "Nine args ordered"] @@ -35,8 +35,12 @@ def identity_test(program, valgrind, valgrind_check, colours): print(f"{colours[0]}{i + 1}. OK{colours[2]}") else: print(f"{colours[1]}{i + 1}. KO{colours[2]}") + exit_status = 1 if valgrind_check in err_val: print(f"{colours[0]} MOK\n{colours[2]}") else: print(f"{colours[1]} MKO\n{colours[2]}") - i = i + 1 \ No newline at end of file + exit_status = 1 + i = i + 1 + + return (exit_status) \ No newline at end of file diff --git a/qa/evaluator_modules/_03_simple_version.py b/qa/evaluator_modules/_03_simple_version.py index a542e0d..557a3f8 100644 --- a/qa/evaluator_modules/_03_simple_version.py +++ b/qa/evaluator_modules/_03_simple_version.py @@ -1,6 +1,6 @@ import subprocess -def simple_version(program, valgrind, valgrind_check, colours): +def simple_version(program, valgrind, valgrind_check, colours, exit_status): # Definig args all_tiny_sort_args_checker = ["'1 3 2'", "'2 1 3'", "'2 3 1'", "'3 1 2'", "'3 2 1'"] @@ -38,8 +38,12 @@ def simple_version(program, valgrind, valgrind_check, colours): print(f"{colours[0]}{i}. OK {colours[2]}") else: print(f"{colours[1]}{i}. KO {colours[2]}") + exit_status = 1 if valgrind_check in out_val: print(f"{colours[0]} MOK{colours[2]}") else: print(f"{colours[1]} MKO{colours[2]}") - i = i + 1 \ No newline at end of file + exit_status = 1 + i = i + 1 + + return (exit_status) \ No newline at end of file diff --git a/qa/evaluator_modules/_04_another_simple_version.py b/qa/evaluator_modules/_04_another_simple_version.py index 9475e45..16a5650 100644 --- a/qa/evaluator_modules/_04_another_simple_version.py +++ b/qa/evaluator_modules/_04_another_simple_version.py @@ -1,6 +1,6 @@ import subprocess -def another_simple_version(program, valgrind, valgrind_check, colours): +def another_simple_version(program, valgrind, valgrind_check, colours, exit_status): # Definig args all_tiny_sort_args_checker = ["'1 5 2 4 3'", "'5 4 3 2 1'"] @@ -38,8 +38,12 @@ def another_simple_version(program, valgrind, valgrind_check, colours): print(f"{colours[0]}{i}. OK {colours[2]}") else: print(f"{colours[1]}{i}. KO {colours[2]}") + exit_status = 1 if valgrind_check in out_val: print(f"{colours[0]} MOK{colours[2]}") else: print(f"{colours[1]} MKO{colours[2]}") - i = i + 1 \ No newline at end of file + exit_status = 1 + i = i + 1 + + return (exit_status) \ No newline at end of file diff --git a/qa/evaluator_modules/_05_middle_version.py b/qa/evaluator_modules/_05_middle_version.py index d1a5eff..a17ef53 100644 --- a/qa/evaluator_modules/_05_middle_version.py +++ b/qa/evaluator_modules/_05_middle_version.py @@ -1,7 +1,7 @@ import subprocess import random -def middle_version(program, valgrind, valgrind_check, colours): +def middle_version(program, valgrind, valgrind_check, colours, exit_status): # Definig args numbers_100 = list(range(0, 100, 1)) @@ -33,10 +33,12 @@ def middle_version(program, valgrind, valgrind_check, colours): print(f"{colours[0]} OK {colours[2]}") else: print(f"{colours[1]} KO {colours[2]}") + exit_status = 1 if valgrind_check in output_val: print(f"{colours[0]} MOK{colours[2]}") else: print(f"{colours[1]} MKO{colours[2]}") + exit_status = 1 if output_moves < 700: print(f"5/5 | {output_moves} < 700") elif output_moves < 900: @@ -46,4 +48,6 @@ def middle_version(program, valgrind, valgrind_check, colours): elif output_moves < 1300: print(f"2/5 | {output_moves} < 1300") elif output_moves < 1500: - print(f"1/5 | {output_moves} < 1500") \ No newline at end of file + print(f"1/5 | {output_moves} < 1500") + + return (exit_status) \ No newline at end of file diff --git a/qa/evaluator_modules/_06_advanced_version.py b/qa/evaluator_modules/_06_advanced_version.py index c78f094..25f4030 100644 --- a/qa/evaluator_modules/_06_advanced_version.py +++ b/qa/evaluator_modules/_06_advanced_version.py @@ -1,7 +1,7 @@ import subprocess import random -def advanced_version(program, valgrind, valgrind_check, colours): +def advanced_version(program, valgrind, valgrind_check, colours, exit_status): # Definig args numbers_500 = list(range(0, 500, 1)) @@ -33,10 +33,12 @@ def advanced_version(program, valgrind, valgrind_check, colours): print(f"{colours[0]} OK {colours[2]}") else: print(f"{colours[1]} KO {colours[2]}") + exit_status = 1 if valgrind_check in output_val: print(f"{colours[0]} MOK{colours[2]}") else: print(f"{colours[1]} MKO{colours[2]}") + exit_status = 1 if output_moves < 5500: print(f"5/5 | {output_moves} < 5500") elif output_moves < 7000: @@ -46,4 +48,6 @@ def advanced_version(program, valgrind, valgrind_check, colours): elif output_moves < 10000: print(f"2/5 | {output_moves} < 10000") elif output_moves < 11500: - print(f"1/5 | {output_moves} < 11500") \ No newline at end of file + print(f"1/5 | {output_moves} < 11500") + + return (exit_status) \ No newline at end of file diff --git a/qa/evaluator_modules/_07_nothing_on_string.py b/qa/evaluator_modules/_07_nothing_on_string.py index 10ecabf..0cfffe9 100644 --- a/qa/evaluator_modules/_07_nothing_on_string.py +++ b/qa/evaluator_modules/_07_nothing_on_string.py @@ -1,6 +1,6 @@ import subprocess -def nothing_on_string(program, valgrind, valgrind_check, colours): +def nothing_on_string(program, valgrind, valgrind_check, colours, exit_status): # Definig args program_shell_true = program[0] @@ -25,7 +25,11 @@ def nothing_on_string(program, valgrind, valgrind_check, colours): print(f"{colours[0]} OK {colours[2]}") else: print(f"{colours[1]} KO {colours[2]}") + exit_status = 1 if valgrind_check in output_val: print(f"{colours[0]} MOK{colours[2]}") else: print(f"{colours[1]} MKO{colours[2]}") + exit_status = 1 + + return (exit_status) diff --git a/qa/evaluator_modules/_08_only_space_on_string.py b/qa/evaluator_modules/_08_only_space_on_string.py index 2d5a8d2..97bbf05 100644 --- a/qa/evaluator_modules/_08_only_space_on_string.py +++ b/qa/evaluator_modules/_08_only_space_on_string.py @@ -1,6 +1,6 @@ import subprocess -def only_space_on_string(program, valgrind, valgrind_check, colours): +def only_space_on_string(program, valgrind, valgrind_check, colours, exit_status): # Definig args program_shell_true = program[0] @@ -26,7 +26,11 @@ def only_space_on_string(program, valgrind, valgrind_check, colours): print(f"{colours[0]} OK {colours[2]}") else: print(f"{colours[1]} KO {colours[2]}") + exit_status = 1 if valgrind_check in output_val: print(f"{colours[0]} MOK{colours[2]}") else: - print(f"{colours[1]} MKO{colours[2]}") \ No newline at end of file + print(f"{colours[1]} MKO{colours[2]}") + exit_status = 1 + + return (exit_status) \ No newline at end of file From 5f485512ecf62a4a183202404a14499110c2a0c8 Mon Sep 17 00:00:00 2001 From: Jose Felipe Dalcin Stieven Date: Fri, 23 Feb 2024 19:03:56 -0300 Subject: [PATCH 06/12] Werror --- lib/sources/functions/sources/ft_math_sqrt.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/sources/functions/sources/ft_math_sqrt.c b/lib/sources/functions/sources/ft_math_sqrt.c index 14c6be6..b423c2b 100644 --- a/lib/sources/functions/sources/ft_math_sqrt.c +++ b/lib/sources/functions/sources/ft_math_sqrt.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* ft_math_sqrt.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: gfantoni +#+ +:+ +#+ */ +/* By: josfelip +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/23 18:07:22 by gfantoni #+# #+# */ -/* Updated: 2024/01/29 09:58:19 by gfantoni ### ########.fr */ +/* Updated: 2024/02/23 19:01:14 by josfelip ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,9 +15,7 @@ long ft_math_sqrt(long nb, long kick) { long result; - long iteration; - iteration = 0; if (nb > 0) { while (1) From bf4df995a40fc6e59ab975ff60f3381cfdea9515 Mon Sep 17 00:00:00 2001 From: Guilherme Fantoni Borges Date: Mon, 26 Feb 2024 09:21:12 -0300 Subject: [PATCH 07/12] parameter 'a' removed from push_bst_indexing; evaluator aproved. --- includes/push_swap.h | 6 +++--- sources/00_main.c | 6 +++--- sources/02_indexing.c | 7 +++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/includes/push_swap.h b/includes/push_swap.h index f6aaccc..a108d70 100644 --- a/includes/push_swap.h +++ b/includes/push_swap.h @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* push_swap.h :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: josfelip +#+ +:+ +#+ */ +/* By: gfantoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/30 10:52:24 by josfelip #+# #+# */ -/* Updated: 2024/02/23 12:17:15 by josfelip ### ########.fr */ +/* Updated: 2024/02/26 09:18:48 by gfantoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -60,7 +60,7 @@ void push_pre_user_input_validation(int *argc, char ***argv); void push_fill_stack(t_list_push **a, int argc, char *argv[]); int push_bst_is_member(t_bst *node, int find_key); void push_lst_indexing(t_list_push *a, t_bst *bst); -void push_bst_indexing(t_bst **bst, t_list_push **a); +void push_bst_indexing(t_bst **bst); void push_bst_in_order_static(t_bst *node, int index); // 03_moves.c diff --git a/sources/00_main.c b/sources/00_main.c index 7b4d91a..385d916 100644 --- a/sources/00_main.c +++ b/sources/00_main.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* 00_main.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: josfelip +#+ +:+ +#+ */ +/* By: gfantoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/30 10:52:11 by josfelip #+# #+# */ -/* Updated: 2024/02/23 12:21:27 by josfelip ### ########.fr */ +/* Updated: 2024/02/26 09:18:30 by gfantoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,7 +28,7 @@ int main(int argc, char *argv[]) push_free_split(argv); if (push_is_sorted(a)) push_safe_exit(0, &a, &b, &bst); - push_bst_indexing(&bst, &a); + push_bst_indexing(&bst); push_lst_indexing(a, bst); push_only_swap_or_tiny_sort(&a, &b, &bst); push_all_save_three(&a, &b); diff --git a/sources/02_indexing.c b/sources/02_indexing.c index 484eb25..44d51a0 100644 --- a/sources/02_indexing.c +++ b/sources/02_indexing.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* 02_indexing.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: josfelip +#+ +:+ +#+ */ +/* By: gfantoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/01 19:05:24 by josfelip #+# #+# */ -/* Updated: 2024/02/23 12:35:53 by josfelip ### ########.fr */ +/* Updated: 2024/02/26 09:18:20 by gfantoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -50,10 +50,9 @@ void push_lst_indexing(t_list_push *a, t_bst *bst) } } -void push_bst_indexing(t_bst **bst, t_list_push **a) +void push_bst_indexing(t_bst **bst) { push_bst_in_order_static(*bst, 0); - a = NULL; return ; } From d017e4f8d9a421c328f07ea86c3ca113ca6eb236 Mon Sep 17 00:00:00 2001 From: Guilherme Fantoni Borges Date: Mon, 26 Feb 2024 09:26:15 -0300 Subject: [PATCH 08/12] variable temp removed from push_comp_cost; evaluator aproved. --- sources/06_comp_cost.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sources/06_comp_cost.c b/sources/06_comp_cost.c index 0f6c458..71c0981 100644 --- a/sources/06_comp_cost.c +++ b/sources/06_comp_cost.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* 06_comp_cost.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: josfelip +#+ +:+ +#+ */ +/* By: gfantoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/22 14:57:55 by josfelip #+# #+# */ -/* Updated: 2024/02/22 14:58:22 by josfelip ### ########.fr */ +/* Updated: 2024/02/26 09:23:05 by gfantoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,13 +14,11 @@ void push_comp_cost(t_list_push *a, t_list_push *b) { - t_list_push *temp; int lstsize_a; int lstsize_b; lstsize_a = push_lstsize(a); lstsize_b = push_lstsize(b); - temp = b; while (b) { if (b->position > lstsize_b / 2) From 7f01d3f4404120a9cdecaecd58a2d0614ac7527a Mon Sep 17 00:00:00 2001 From: Guilherme Fantoni Borges Date: Mon, 26 Feb 2024 09:29:25 -0300 Subject: [PATCH 09/12] variable 'temp' removed from push_cheapest_move; evaluator aproved. --- sources/07_cheapest_move.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sources/07_cheapest_move.c b/sources/07_cheapest_move.c index aa0d641..1597ff8 100644 --- a/sources/07_cheapest_move.c +++ b/sources/07_cheapest_move.c @@ -6,7 +6,7 @@ /* By: gfantoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/22 15:05:33 by gfantoni #+# #+# */ -/* Updated: 2024/02/22 15:05:45 by gfantoni ### ########.fr */ +/* Updated: 2024/02/26 09:27:34 by gfantoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,10 +14,8 @@ void push_cheapest_move(t_list_push *b, int *rotations) { - t_list_push *temp; int total_cost; - temp = b; total_cost = INT_MAX; while (b) { From fd56b9031739587025e9e1803cdac5e35ed31907 Mon Sep 17 00:00:00 2001 From: Jose Felipe Dalcin Stieven Date: Mon, 26 Feb 2024 11:07:34 -0300 Subject: [PATCH 10/12] docker valgrind. --- .github/workflows/evaluator.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/evaluator.yml b/.github/workflows/evaluator.yml index ffebc41..096e54c 100644 --- a/.github/workflows/evaluator.yml +++ b/.github/workflows/evaluator.yml @@ -13,5 +13,7 @@ jobs: steps: - uses: actions/checkout@v3 - - name: evaluator - run: cd qa && ./evaluator.py + - name: 42valgrind Leak checker + uses: solareenlo/42valgrind-action@v1.0.3 + with: + flags: "cd qa && ./evaluator.py" From bb329f8556394ec16230ad79cace5af1da30d2a5 Mon Sep 17 00:00:00 2001 From: Jose Felipe Dalcin Stieven Date: Mon, 26 Feb 2024 11:16:52 -0300 Subject: [PATCH 11/12] without sudo --- .github/workflows/evaluator.bkp | 19 +++++++++++++++++++ .github/workflows/evaluator.yml | 6 ++---- 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/evaluator.bkp diff --git a/.github/workflows/evaluator.bkp b/.github/workflows/evaluator.bkp new file mode 100644 index 0000000..096e54c --- /dev/null +++ b/.github/workflows/evaluator.bkp @@ -0,0 +1,19 @@ +name: Evaluator + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + test: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: 42valgrind Leak checker + uses: solareenlo/42valgrind-action@v1.0.3 + with: + flags: "cd qa && ./evaluator.py" diff --git a/.github/workflows/evaluator.yml b/.github/workflows/evaluator.yml index 096e54c..3157af9 100644 --- a/.github/workflows/evaluator.yml +++ b/.github/workflows/evaluator.yml @@ -13,7 +13,5 @@ jobs: steps: - uses: actions/checkout@v3 - - name: 42valgrind Leak checker - uses: solareenlo/42valgrind-action@v1.0.3 - with: - flags: "cd qa && ./evaluator.py" + - name: evaluator + run: apt update && apt install valgrind && cd qa && ./evaluator.py From 52ac90ef497e9a61b67ecbe6e34ade1929ec684b Mon Sep 17 00:00:00 2001 From: Jose Felipe Dalcin Stieven Date: Mon, 26 Feb 2024 11:18:27 -0300 Subject: [PATCH 12/12] with sudo --- .github/workflows/evaluator.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/evaluator.yml b/.github/workflows/evaluator.yml index 3157af9..4df2434 100644 --- a/.github/workflows/evaluator.yml +++ b/.github/workflows/evaluator.yml @@ -14,4 +14,4 @@ jobs: steps: - uses: actions/checkout@v3 - name: evaluator - run: apt update && apt install valgrind && cd qa && ./evaluator.py + run: sudo apt update && sudo apt install valgrind && cd qa && ./evaluator.py