Mentions légales du service

Skip to content

Directive placement may be counter intuitive

Let's consider this test

echo hello

:hello

!NO_LAUNCHER:

echo bye

:bye

!EXIT_CODE: 2

LANG=C ls lkjlkjfsdlkfjksdlfjlsdkjflksdjflskfjd

0:.

I have three tests each time preceded by a command. In this case I would understand that I don't want a launcher for the second and third commands and that I want an exit code equals to 2 for the last command only.

However this is not how the file is interpreted. The !NO_LAUNCHER also applies to the first command and the !EXIT_CODE also applies to the second command.

For those tests to work as expected I should write them as:

echo hello

:hello

echo bye
# Applies to the second and third test
!NO_LAUNCHER:

:bye


LANG=C ls lkjlkjfsdlkfjksdlfjlsdkjflksdjflskfjd
# Applies to the third test
!EXIT_CODE: 2

0:.

Thus the directives have to be placed after the first command they apply to. This may be counter-intuitive as even someone who knows very well this test framework made the mistake ;) If the directive is before or after the command (but before the tests), that directive should apply to that command, not to the previous one.