faboussard / 42_minishell

1 stars 0 forks source link

Résultats des tests de mcombeau. #88

Closed melobern closed 4 months ago

melobern commented 6 months ago

J'ai implémenté le code de mcombeau pour pouvoir tester avec son changement du main: :warning: Pour que les tests fonctionnent, aller dans bash et faire export de la langue anglaise :warning:

minitester-minishell-tester git:(main) ✗ bash
melodie@bash:~/42_minishell/minitester-minishell-tester$ export LANG=en_US.UTF-8
melodie@bash:~/42_minishell/minitester-minishell-tester$ bash minitester.sh > TEST_MINISTESTER 

Exporter dans un fichier permet de relire plus facilement une fois les tests finis, notamment avec un cat TEST_MINISTESTER

Ceci est à refaire à chaque réouverture de terminal, celui-ci reprenant la langue française sinon.

Voici le main à utiliser :


int main(int ac, char **av, char **envp)
{
    t_minishell minishell;
    char        *readline_input;
    char        **arg_input;
    int         i;

    if (ac > 2 && !av[2])
    {
        ft_putendl_fd("bash: -c: option requires an argument", 2);
        exit(2);
    }
    ft_bzero(&minishell, (sizeof(t_minishell)));
    minishell.total_commands = 1;
    set_minishell_paths(&minishell);
    set_environment(&minishell, envp);
    if (ac == 3 && ft_strcmp(av[1], "-c") == 0 && av[2])
    {
        if (!av[2])
        {
            ft_putendl_fd("bash: -c: option requires an argument", 2);
            exit(2);
        }
        arg_input = ft_split(av[2], ';');
        if (!arg_input)
            return (1);
        i = 0;
        while (arg_input[i])
        {
            minishell_non_interactive(&minishell, arg_input[i]);
            init_before_next_prompt(&minishell);
            i++;
        }
    }
    else
    {
        while (1)
        {
            readline_input = readline(PROMPT);
            minishell_non_interactive(&minishell, readline_input);
            init_before_next_prompt(&minishell);
        }
    }
    if (0 && is_interactive(&minishell, ac, av) == true)
        minishell_interactive(&minishell);
    free_minishell(&minishell);
    return (minishell.status);
}

(Pour ne pas se mélanger avec notre vrai main, le mieux est de commenter notre main et de copier-coller cette version pour tester).

image

Mise à jour : après avoir codé cd : image

Mise à jour : après amélioratiions exit, echo, exec : image

melobern commented 6 months ago
3   [KO]  [usr/bin/ls] 
4   [KO]  [./ls] 
6   [KO]  [/usr/bin/hello] 
7   [KO]  [./hello] 
9   [KO]  [.] 
10  [KO]  [..] 
11  [KO]  [$] 
12  [KO]  [./] 
13  [KO]  [../] 
14  [KO]  [./existing_dir] 
15  [KO]  [../fake_dir/] 
16  [KO]  [./existing_file] 
17  [KO]  [./nonexistant_file] 
19  [KO]  [.executable_file] 
25  [KO]  [cat infile.txt | grep dream | wc -l | cd x] 
26  [KO]  [cat infile.txt | grep dream | wc -l | x] 
31  [KO]  [x | x | x | x | x] 
32  [KO]  [x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x] 
37  [KO]  [                          ] 
59  [KO]  [echo "" "" "" test] 
63  [KO]  [echo $USE""R]  ->> il est en fait bon
69  [KO]  [echo $""USER]   ->> il est en fait bonl
75  [KO]  [ls '"] 
76  [KO]  [ls "'] 
77  [KO]  [ls " "] 
97  [KO]  [ls || cat] 
98  [KO]  [ls | | cat] 
102 [KO]  [fake_cmd | | ls] 
103 [KO]  [ls || fake_cmd] 
104 [KO]  [ls | | fake_cmd] 
138 [KO]  [< $FAKE_VAR cat] 
139 [KO]  [cat < $FAKE_VAR] 
140 [KO]  [cat < $123456] 
141 [KO]  [< $USER cat] 
165 [KO]  [echo a '' b '' c '' d] 
166 [KO]  [echo a "" b "" c "" d] 
167 [KO]  [echo -n a '' b '' c '' d] 
168 [KO]  [echo -n a "" b "" c "" d] 
172 [KO]  [echo a   -nnnnhello] 
174 [KO]  [echo a   hello -nhello] 
175 [KO]  [ENV | sort | grep -v SHLVL | grep -v _=] 
176 [KO]  [Env | sort | grep -v SHLVL | grep -v _=] 
177 [KO]  [env | sort | grep -v SHLVL | grep -v _=] 
179 [KO]  [env | grep PATH] 
182 [KO]  [export ""] 
183 [KO]  [export 42] 
184 [KO]  [export 42; env | grep 42] 
185 [KO]  [export =] 
186 [KO]  [export =; env | grep = | wc -l] 
189 [KO]  [export A=a; echo $A] 
190 [KO]  [export A=a B=b C=c; echo $A$B$C] 
191 [KO]  [export A=a B=b C=c; export A=c B=a C=b; echo $A$B$C] 
192 [KO]  [export A=a B=b C=c D=d E=e F=f G=g H=h I=i J=j K=k L=l M=m N=n O=o P=p Q=q R=r S=s T=t U=u V=v W=w X=x Y=y Z=z; echo $A$B$C$D$E$F$G$H$I$J$K$L$M$N$O$P$Q$R$S$T$U$V$W$X$Y$Z] 
193 [KO]  [export A==a; echo $A] 
194 [KO]  [export A===a; echo $A] 
195 [KO]  [export A====a; echo $A] 
196 [KO]  [export A=====a; echo $A] 
197 [KO]  [export A======a; echo $A] 
198 [KO]  [export A=a=a=a=a=a; echo $A] 
199 [KO]  [export HELLOWORLD=a; echo $HELLOWORLD] 
200 [KO]  [export helloworld=a; echo $helloworld] 
201 [KO]  [export hello_world=a; echo $hello_world] 
202 [KO]  [export HELLOWORLD1=a; echo $HELLOWORLD1] 
203 [KO]  [export H1ELL_0_W123Orld_a=a; echo $H1ELL_0_W123Orld_a] 
204 [KO]  [export a0123456789=a; echo $a0123456789] 
205 [KO]  [export abcdefghijklmnopqrstuvwxyz=a; echo $abcdefghijklmnopqrstuvwxyz] 
206 [KO]  [export __________________________=a; echo $__________________________] 
207 [KO]  [export _hello_=a; echo $_hello_] 
208 [KO]  [export 1] 
209 [KO]  [export 1=] 
210 [KO]  [export 1=a] 
211 [KO]  [export HELLOWORLD =a] 
213 [KO]  [export HELLO'WORLD'=a] 
217 [KO]  [export A='hello this world is wonderful'; echo $A] 
218 [KO]  [export A="hello this world is wonderful"; echo $A] 
219 [KO]  [export A 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf ' C; echo $A$B$C] 
220 [KO]  [export 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf ' C; echo $A$B$C] 
221 [KO]  [export A 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf '; echo $A$B$C] 
222 [KO]  [export A B C; echo $A$B$C] 
223 [KO]  [export 'HELLO@'=hello] 
224 [KO]  [export "HELLO'"=hello] 
225 [KO]  [export 'HELLO"'=hello] 
226 [KO]  [export 'HELLO$'=hello] 
227 [KO]  [export 'HELLO!'=hello] 
228 [KO]  [export 'HELLO|'=hello] 
229 [KO]  [export 'HELLO&'=hello] 
230 [KO]  [export 'HELLO'=hello] 
231 [KO]  [export ALPHA="abc def ghi"; echo $ALPHA] 
232 [KO]  [export ALPHA='abc def ghi'; echo $ALPHA] 
233 [KO]  [export DIGITS="0 1 2 3 4 5 6 7 8 9"; echo $DIGITS] 
234 [KO]  [export DIGITS='0 1 2 3 4 5 6 7 8 9'; echo $DIGITS] 
235 [KO]  [export DIGITS=0 1 2 3 4 5 6 7 8 9; echo $DIGITS] 
238 [KO]  [unset] 
239 [KO]  [unset PATH] 
240 [KO]  [unset PATH USER; echo $PATH; echo $USER] 
241 [KO]  [unset PATH; echo $PATH] 
242 [KO]  [unset PATH; ls] 
243 [KO]  [unset NOT_A_VAR] 
244 [KO]  [unset ""] 
245 [KO]  [unset ''] 
247 [KO]  [export A=a A2=a; unset A; echo $A $A2] 
248 [KO]  [export A=a; unset 'A '; echo $A] 
249 [KO]  [export A=a; unset A=; echo $A] 
250 [KO]  [export A=a; unset 'A='; echo $A] 
251 [KO]  [export A=a B=b C=c; unset A B C; echo $A$B$C] 
252 [KO]  [export A=a B=b C=c; unset A 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf ' C] 
253 [KO]  [export A=a B=b C=c; unset A 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf ' C; echo $A$B$C] 
254 [KO]  [export A=a B=b C=c; unset 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf ' C] 
255 [KO]  [export A=a B=b C=c; unset 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf ' C; echo $A$B$C] 
256 [KO]  [export A=a B=b C=c; unset A 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf '] 
257 [KO]  [export A=a B=b C=c; unset A 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf '; echo $A$B$C] 
258 [KO]  [export A=a B=b C=c; unset A] 
259 [KO]  [export A=a B=b C=c; unset A; echo $A$B$C] 
260 [KO]  [export A=a B=b C=c; unset B] 
261 [KO]  [export A=a B=b C=c; unset B; echo $A$B$C] 
262 [KO]  [export A=a B=b C=c; unset C] 
263 [KO]  [export A=a B=b C=c; unset C; echo $A$B$C] 
264 [KO]  [unset 'HELLO@'] 
265 [KO]  [unset "HELLO'"] 
266 [KO]  [unset 'HELLO"'] 
267 [KO]  [unset 'HELLO$'] 
268 [KO]  [unset 'HELLO!'] 
269 [KO]  [unset 'HELLO|'] 
270 [KO]  [unset 'HELLO&'] 
271 [KO]  [unset 'HELLO'] 
289 [KO]  [mkdir a a/b; cd a/b; rm -rf ../../a; pwd] 
295 [KO]  [cd; pwd] 
299 [KO]  [cd ..; pwd] 
301 [KO]  [cd existing_dir; pwd] 
303 [KO]  [cd /dev; pwd] 
315 [KO]  [cd ../../../../../../../../../../../../../../../../../../../../../../; pwd] 
317 [KO]  [cd $HOME; pwd] 
318 [KO]  [unset HOME; cd $HOME] 
319 [KO]  [unset HOME; cd $HOME; pwd] 
320 [KO]  [unset HOME; cd] 
321 [KO]  [unset HOME; cd; pwd] 
340 [KO]  [exit - 42] 
341 [KO]  [exit + 42] 
344 [KO]  [exit ""] 
345 [KO]  [exit ''] 
346 [KO]  [exit " "] 
347 [KO]  [exit ' '] 
351 [KO]  [exit '5 '] 
373 [KO]  [exit 0 | exit 1] 
375 [KO]  [ls | exit 42] 
376 [KO]  [ls | exit 12 abc] 
377 [KO]  [ls | exit abc 12] 
384 [KO]  [echo $] 
385 [KO]  [echo $$] 
388 [KO]  [echo $USE] 
411 [KO]  [export ECHO=echo; $ECHO $ECHO] 
412 [KO]  [export L="ls -la"; $L] 
413 [KO]  [export L='ls -la'; $L] 
415 [KO]  [<infile.txt cat] 
417 [KO]  [cat <infile.txt] 
419 [KO]  [< file_does_not_exist] 
420 [KO]  [< forbidden] 
422 [KO]  [cat < file_does_not_exist] 
423 [KO]  [cat < file_does_not_exist] 
424 [KO]  [< file_does_not_exist cat] 
425 [KO]  [<file_does_not_exist cat] 
426 [KO]  [cat < forbidden] 
427 [KO]  [cat <forbidden] 
428 [KO]  [< forbidden cat] 
429 [KO]  [<forbidden cat] 
430 [KO]  [< file_does_not_exist < infile.txt cat] 
431 [KO]  [cat < infile.txt < file_does_not_exist] 
435 [KO]  [<infile.txt cat < infile_2.txt] 
439 [KO]  [cat < forbidden < infile.txt] 
440 [KO]  [cat < infile.txt < forbidden] 
441 [KO]  [cat < forbidden | cat < infile.txt] 
442 [KO]  [cat < infile.txt | cat < forbidden] 
444 [KO]  [> forbidden; echo $?] 
451 [KO]  [echo hello world > forbidden] 
461 [KO]  [echo abcdefghijk > forbidden > out > out_2] 
462 [KO]  [echo abcdefghijk > out > forbidden > out_2] 
463 [KO]  [echo abcdefghijk > out > out_2 > forbidden] 
478 [KO]  [echo hello > out | echo world > forbidden] 
481 [KO]  [>> forbidden; echo $?] 
488 [KO]  [echo hello world >> forbidden] 
494 [KO]  [echo abcdefghijk >> out >> out_2] 
496 [KO]  [echo hello world >> out >> out >> out >> out >> out >> out] 
498 [KO]  [echo abcdefghijk >> forbidden >> out >> out_2] 
499 [KO]  [echo abcdefghijk >> out >> forbidden >> out_2] 
500 [KO]  [echo abcdefghijk >> out >> out_2 >> forbidden] 
515 [KO]  [echo hello >> out | echo world >> forbidden] 
543 [KO]  [< forbidden < infile_2.txt cat > out >> out_2] 
544 [KO]  [< infile.txt < forbidden cat > out >> out_2] 
545 [KO]  [< infile.txt < infile_2.txt cat > forbidden >> out] 
546 [KO]  [< infile_2.txt < infile.txt cat > out >> forbidden] 
547 [KO]  [< infile.txt < infile_2.txt cat >> forbidden > out] 
548 [KO]  [< infile_2.txt < infile.txt cat >> out > forbidden] 
549 [KO]  [< forbidden cat > forbidden >> forbidden] 
550 [KO]  [< forbidden cat >> forbidden > forbidden] 
551 [KO]  [cat >> forbidden > forbidden < forbidden] 
552 [KO]  [< infile.txt cat | grep dream > forbidden] 
553 [KO]  [< infile_2.txt cat | grep dream >> forbidden] 
556 [KO]  [< infile.txt cat >> out | wc -l > forbidden] 
557 [KO]  [< infile_2.txt cat > out | wc -l >> forbidden] 
562 [KO]  [$?; echo $?] 
563 [KO]  [fakecmd; echo $?] 
564 [KO]  [cat < file_does_not_exist; echo $?] 
565 [KO]  [cat < forbidden; echo $?] 
566 [KO]  [./forbidden; echo $?] 
568 [KO]  [cd forbidden_dir; echo $?] 
569 [KO]  [cd dir_does_not_exist; echo $?] 
570 [KO]  [cd file_does_not_exist; echo $?] 
571 [KO]  [cd infile.txt; echo $?] 
572 [KO]  [ls dir_does_not_exist; echo $?] 
576 [KO]  [unset PATH; usr/bin/ls] 
577 [KO]  [unset PATH; ./ls] 
578 [KO]  [unset PATH; hello] 
579 [KO]  [unset PATH; /usr/bin/hello] 
580 [KO]  [unset PATH; ./hello] 
581 [KO]  [unset PATH; ""] 
582 [KO]  [unset PATH; .] 
583 [KO]  [unset PATH; ..] 
584 [KO]  [unset PATH; $] 
585 [KO]  [unset PATH; ./] 
586 [KO]  [unset PATH; ../] 
587 [KO]  [unset PATH; ./existing_dir] 
588 [KO]  [unset PATH; ../fake_dir/] 
589 [KO]  [unset PATH; ./existing_file] 
590 [KO]  [unset PATH; ./nonexistant_file] 
592 [KO]  [unset PATH; .executable_file] 
593 [KO]  [unset PATH; executable_file] 
597 [KO]  [unset PATH; env | grep PATH] 
598 [KO]  [unset PATH; env | grep USER] 
599 [KO]  [unset PATH; env | grep SHELL] 
600 [KO]  [unset PATH; env | grep PWD] 
602 [KO]  [unset PATH; export 42=hello] 
603 [KO]  [unset PATH; export hello=42; echo $hello] 
604 [KO]  [unset PATH; export PATH=/usr/bin:/sbin/; ls] 
605 [KO]  [unset PATH] 
606 [KO]  [unset PATH; export hello=42; unset hello] 
608 [KO]  [unset PATH; unset USER] 
654 [KO]  [unset PATH; exit - 42] 
655 [KO]  [unset PATH; exit + 42] 
melobern commented 6 months ago

Pour une vue plus rapide des erreurs actuelles : :arrow_left: cat TEST_MINISTESTER | grep 'KO]' sur le fichier de sortie permet de voir les tests qui ont échoué. Sortie copiée sur le précédent message.

Pour une vue plus intéressante (savoir le soucis exact) : :arrow_right: cat TEST_MINISTESTER | grep -10 'KO]' permet de voir les 10 lignes qui entourent ce KO, et donc de savoir si c'est STDOUT, STDERR ou EXIT STATUSqui ont échoué.

Pour aller plus loin et chercher des tests en particulier, on peut rajouter un grep : :arrow_right: cat TEST_MINISTESTER | grep -10 'KO]' | grep -10 cd

faboussard commented 6 months ago

23/05 à 15h23

TOUT EST OK LES FAILS SONT CONNUS ET NE SONT PAS À TRAITER

Final : "3" erreurs : 2 dues au env pas dans le meme ordre et 1 stderr pas essentiel.