1 # Copyright 2011 The Kyua Authors.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 # * Neither the name of Google Inc. nor the names of its contributors
14 # may be used to endorse or promote products derived from this software
15 # without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 utils_test_case global
32 atf_check -s exit:0 -o save:stdout -e empty kyua help
33 grep -E 'kyua .*[0-9]+\.[0-9]+' stdout || atf_fail 'No version reported'
34 grep '^Usage: kyua' stdout || atf_fail 'No usage line printed'
35 grep -- '--loglevel' stdout || atf_fail 'Generic options not printed'
36 if grep -- '--show' stdout; then
37 atf_fail 'One option of the about subcommand appeared in the output'
39 grep 'about *Shows detailed' stdout || atf_fail 'Commands not printed'
43 utils_test_case one_command
45 atf_check -s exit:0 -o save:stdout -e empty kyua help test
46 grep -E 'kyua .*[0-9]+\.[0-9]+' stdout || atf_fail 'No version reported'
47 grep '^Usage: kyua' stdout || atf_fail 'No usage line printed'
48 grep '^Run tests' stdout || atf_fail 'No description printed'
49 grep -- '--loglevel' stdout || atf_fail 'Generic options not printed'
50 grep -- '--kyuafile' stdout || atf_fail 'Command options not printed'
51 if grep 'about: Shows detailed' stdout; then
52 atf_fail 'Printed table of commands, but should not have done so'
57 utils_test_case ignore_bad_config
58 ignore_bad_config_body() {
59 echo 'this is an invalid configuration file' >bad-config
60 atf_check -s exit:0 -o save:stdout -e empty kyua -c bad-config help
61 grep '^Usage: kyua' stdout || atf_fail 'No usage line printed'
62 grep -- '--loglevel' stdout || atf_fail 'Generic options not printed'
66 utils_test_case unknown_command
67 unknown_command_body() {
69 Usage error for command help: The command abc does not exist.
70 Type 'kyua help help' for usage information.
72 atf_check -s exit:3 -o empty -e file:stderr kyua help abc
76 utils_test_case too_many_arguments
77 too_many_arguments_body() {
79 Usage error for command help: Too many arguments.
80 Type 'kyua help help' for usage information.
82 atf_check -s exit:3 -o empty -e file:stderr kyua help about cde
86 atf_init_test_cases() {
87 atf_add_test_case global
88 atf_add_test_case one_command
90 atf_add_test_case ignore_bad_config
91 atf_add_test_case unknown_command
92 atf_add_test_case too_many_arguments