diff --git a/tests/definitions.sh b/tests/definitions.sh index 63741ed2e..b841e2834 100755 --- a/tests/definitions.sh +++ b/tests/definitions.sh @@ -8,10 +8,11 @@ # virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. # - . ./include.ctest.sh +label="definitions_test" REDIRECT=/dev/null +tempOut=temp.$label.txt [ -z "$ECCODES_DEFINITION_PATH" ] || ECCODES_DEFINITION_PATH=`${tools_dir}/codes_info -d` @@ -19,3 +20,13 @@ for file in `find ${ECCODES_DEFINITION_PATH}/ -name '*.def' -print | grep -v gri do ${tools_dir}/codes_parser $file > $REDIRECT done + +# Try an invalid input +set +e +echo 'transient xx=1' | ${tools_dir}/codes_parser - 2>$tempOut +status=$? +set -e +[ $status -ne 0 ] +grep -q "Parser: syntax error" $tempOut + +rm -f $tempOut diff --git a/tools/codes_parser.cc b/tools/codes_parser.cc index 465f8a271..92669c32b 100644 --- a/tools/codes_parser.cc +++ b/tools/codes_parser.cc @@ -21,6 +21,7 @@ int main(int argc, char* argv[]) for (i = 1; i < argc; i++) { printf("%s ... ", argv[i]); fflush(stdout); + // argv can be "-" to indicate stdin if (!(a = grib_parse_file(c, argv[i]))) { fail++; printf("FAILED\n");