diff --git a/src/emc/ini/linuxcnc_check_ini.py b/src/emc/ini/linuxcnc_check_ini.py index 79acb0b8733..83e8997604e 100755 --- a/src/emc/ini/linuxcnc_check_ini.py +++ b/src/emc/ini/linuxcnc_check_ini.py @@ -422,7 +422,7 @@ def main(): if o in ("-e", "--error"): global error_on_warning error_on_warning = True - if o in ("-h", "--help"): + elif o in ("-h", "--help"): usage() # no return from here else: print("Unhandled option: '{}'".format(o), file=sys.stderr); diff --git a/tests/linuxcnc_check_ini/README b/tests/linuxcnc_check_ini/README new file mode 100644 index 00000000000..baf410ed924 --- /dev/null +++ b/tests/linuxcnc_check_ini/README @@ -0,0 +1,5 @@ +Test the exit value of linuxcnc_check_ini with the -e/--error option. + +warn.ini contains only a warning (duplicate entry). Without -e the exit +value must be 0, with -e or --error warnings are treated as errors and the +exit value must be 1. diff --git a/tests/linuxcnc_check_ini/expected b/tests/linuxcnc_check_ini/expected new file mode 100644 index 00000000000..443f5214a62 --- /dev/null +++ b/tests/linuxcnc_check_ini/expected @@ -0,0 +1,8 @@ +warn.ini -> 0 +1 +-e warn.ini -> 1 +1 +--error warn.ini -> 1 +1 +-h -> 2 +0 diff --git a/tests/linuxcnc_check_ini/test.sh b/tests/linuxcnc_check_ini/test.sh new file mode 100755 index 00000000000..d8b26676377 --- /dev/null +++ b/tests/linuxcnc_check_ini/test.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# Check the exit value of linuxcnc_check_ini with and without -e/--error on +# an INI file that only produces warnings. + +run() { + msgs=$(linuxcnc_check_ini "$@" 2>&1 > /dev/null) + echo "$* -> $?" + echo "$msgs" | grep -c ": warning: " +} + +run warn.ini +run -e warn.ini +run --error warn.ini +run -h +exit 0 diff --git a/tests/linuxcnc_check_ini/warn.ini b/tests/linuxcnc_check_ini/warn.ini new file mode 100644 index 00000000000..38e13a096bd --- /dev/null +++ b/tests/linuxcnc_check_ini/warn.ini @@ -0,0 +1,13 @@ +# Valid configuration except for one duplicated joint entry, which makes +# linuxcnc_check_ini emit a warning (but no error). +[KINS] +KINEMATICS = genhexkins +JOINTS = 1 + +[TRAJ] +LINEAR_UNITS = mm +ANGULAR_UNITS = degree + +[JOINT_0] +MAX_VELOCITY = 1.0 +MAX_VELOCITY = 2.0