Je n'ai que 20% de couverture de test pour mon projet. https://coveralls.io/github/montao/opsh
Je veux ajouter un test d'erreur de syntaxe. Je ne parviens pas à recevoir le résultat "erreur de syntaxe" d'une simple commande oneliner Shell. Pourriez-vous m'aider avec quelques exemples?
;
résultats:
bash: syntax error near unexpected token `;'
Vous pouvez utiliser la grande majorité des mots réservés et des opérateurs de contrôle de bash
pour provoquer une erreur de syntaxe. Faisons un test rapide pour obtenir une liste (bien sûr incomplète!):
$ tabs 10
for i in '|' '&' ';' '(' ')' '<' '>' '||' '&&' \
';;' '|&' 'case' 'coproc' 'do' 'done' \
'Elif' 'else' 'esac' 'fi' 'for' 'function' \
'if' 'in' 'select' 'then' 'until' 'while' \
'{' '}' '[[' ']]';
do
printf "%s\t" "$i"; bash -c $i |& sed '2d;s/.*://'
done
| syntax error near unexpected token `|'
& syntax error near unexpected token `&'
; syntax error near unexpected token `;'
( unexpected end of file
) syntax error near unexpected token `)'
< syntax error near unexpected token `newline'
> syntax error near unexpected token `newline'
|| syntax error near unexpected token `||'
&& syntax error near unexpected token `&&'
;; syntax error near unexpected token `;;'
|& syntax error near unexpected token `|&'
case syntax error near unexpected token `newline'
coproc syntax error near unexpected token `newline'
do syntax error near unexpected token `do'
done syntax error near unexpected token `done'
Elif syntax error near unexpected token `Elif'
else syntax error near unexpected token `else'
esac syntax error near unexpected token `esac'
fi syntax error near unexpected token `fi'
for syntax error near unexpected token `newline'
function syntax error near unexpected token `newline'
if unexpected end of file
in syntax error near unexpected token `in'
select syntax error near unexpected token `newline'
then syntax error near unexpected token `then'
until unexpected end of file
while unexpected end of file
{ unexpected end of file
} syntax error near unexpected token `}'
[[ unexpected token `EOF' in conditional command
]] syntax error near unexpected token `]]'
J'ai pris ceux de man bash
/DEFINITIONS et / MOTS RÉSERVÉS .