add tester
This commit is contained in:
parent
5b7b7350c5
commit
6514dfa49b
@ -19,6 +19,7 @@ A lot of amazing shell stuff
|
|||||||
|
|
||||||
## Tester
|
## Tester
|
||||||
- [minishell_tester](https://github.com/LucasKuhn/minishell_tester)
|
- [minishell_tester](https://github.com/LucasKuhn/minishell_tester)
|
||||||
|
- [python tester](https://minishell-test.readthedocs.io/en/latest/index.html)
|
||||||
|
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|||||||
30
minishell_test.cfg
Normal file
30
minishell_test.cfg
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
[minishell_test]
|
||||||
|
bonus = false
|
||||||
|
exec_name = minishell
|
||||||
|
make = true
|
||||||
|
make_args = MINISHELL_TEST_FLAGS=-DNOBANNER
|
||||||
|
pager = false
|
||||||
|
pager_prog = less
|
||||||
|
log_path = minishell_test.log
|
||||||
|
check_error_messages = false
|
||||||
|
end_command_with_linefeed = true
|
||||||
|
|
||||||
|
[shell]
|
||||||
|
available_commands =
|
||||||
|
rmdir
|
||||||
|
env
|
||||||
|
cat
|
||||||
|
touch
|
||||||
|
ls
|
||||||
|
grep
|
||||||
|
sh
|
||||||
|
head
|
||||||
|
path_variable = {shell_available_commands_dir}
|
||||||
|
|
||||||
|
[shell:reference]
|
||||||
|
path = /bin/bash
|
||||||
|
args =
|
||||||
|
|
||||||
|
[timeout]
|
||||||
|
test = 0.5
|
||||||
|
leaks = 10
|
||||||
43
src/main.c
43
src/main.c
@ -1,15 +1,16 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* :::::::: */
|
/* ::: :::::::: */
|
||||||
/* main.c :+: :+: */
|
/* main.c :+: :+: :+: */
|
||||||
/* +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
||||||
/* +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/04 16:19:22 by whaffman #+# #+# */
|
/* Created: 2025/02/04 16:19:22 by whaffman #+# #+# */
|
||||||
/* Updated: 2025/03/04 16:08:26 by whaffman ######## odam.nl */
|
/* Updated: 2025/03/05 15:17:58 by qmennen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
static void main_loop(t_minishell *msh)
|
static void main_loop(t_minishell *msh)
|
||||||
@ -28,18 +29,40 @@ static void main_loop(t_minishell *msh)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void main_test(t_minishell *msh, char *line)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char **args;
|
||||||
|
|
||||||
|
args = ft_split(line, ';');
|
||||||
|
i = 0;
|
||||||
|
while (args[i])
|
||||||
|
{
|
||||||
|
msh->line = args[i];
|
||||||
|
msh->lexer = ft_lexer_new(msh);
|
||||||
|
msh->tokens = ft_parse_input(msh);
|
||||||
|
ft_lstiter(msh->tokens, token_print);
|
||||||
|
msh->commands = parser_get_commands(msh);
|
||||||
|
executor_execute_pipeline(msh);
|
||||||
|
free_minishell_line(msh);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
free(args);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv, char **envp)
|
int main(int argc, char **argv, char **envp)
|
||||||
{
|
{
|
||||||
t_minishell *msh;
|
t_minishell *msh;
|
||||||
|
|
||||||
(void)argc;
|
|
||||||
(void)argv;
|
|
||||||
print_banner();
|
print_banner();
|
||||||
history_load();
|
history_load();
|
||||||
msh = init_minishell();
|
msh = init_minishell();
|
||||||
signal_init_minishell();
|
signal_init_minishell();
|
||||||
environment_parse(msh, envp);
|
environment_parse(msh, envp);
|
||||||
main_loop(msh);
|
if (argc > 2 && ft_strcmp(argv[1], "-c") == 0)
|
||||||
|
main_test(msh, argv[2]);
|
||||||
|
else
|
||||||
|
main_loop(msh);
|
||||||
free_minishell(&msh);
|
free_minishell(&msh);
|
||||||
rl_clear_history();
|
rl_clear_history();
|
||||||
return (EXIT_SUCCESS);
|
return (EXIT_SUCCESS);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user