1#! /bin/sh
2# Copyright (C) 2004-2021 Free Software Foundation, Inc.
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2, or (at your option)
7# any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program.  If not, see <https://www.gnu.org/licenses/>.
16
17# Test Automake's command-line options.
18
19. test-init.sh
20
21plan_ 14
22
23# Usage: bad_cmdline DESCRIPTION REGEX-FOR-STDERR [ARGS-FOR-AUTOMAKE...]
24do_check ()
25{
26  test $# -ge 3 || fatal_ "do_check: invalid usage"
27  desc=$1; shift
28  regex=$1; shift
29  AUTOMAKE_fails -d "$desc (run)" -- "$@"
30  command_ok_ "$desc (stderr)" grep "$regex" stderr
31  cat stderr
32}
33
34do_check 'invalid long option' 'unrecognized option.*--voo' --voo
35
36do_check "empty argument" \
37         'empty argument' ''
38
39do_check "missing argument for long option" \
40         'option.*-W.*requires an argument' -W
41
42do_check "missing argument for short option" \
43         'option.*--warnings.*requires an argument' --warnings
44
45do_check "'--help' as option argument" \
46         'unknown warning.*--help' --warnings --help
47
48do_check "'--help' as option argument" \
49         'unknown warning.*--help' --warnings --help
50
51do_check "ambiguous incomplete option" \
52         'unrecognized option.*--ver' --ver
53
54:
55