Home | History | Annotate | Line # | Download | only in indent
t_errors.sh revision 1.1
      1  1.1  rillig #! /bin/sh
      2  1.1  rillig # $NetBSD: t_errors.sh,v 1.1 2021/10/13 23:33:52 rillig Exp $
      3  1.1  rillig #
      4  1.1  rillig # Copyright (c) 2021 The NetBSD Foundation, Inc.
      5  1.1  rillig # All rights reserved.
      6  1.1  rillig #
      7  1.1  rillig # Redistribution and use in source and binary forms, with or without
      8  1.1  rillig # modification, are permitted provided that the following conditions
      9  1.1  rillig # are met:
     10  1.1  rillig # 1. Redistributions of source code must retain the above copyright
     11  1.1  rillig #    notice, this list of conditions and the following disclaimer.
     12  1.1  rillig # 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  rillig #    notice, this list of conditions and the following disclaimer in the
     14  1.1  rillig #    documentation and/or other materials provided with the distribution.
     15  1.1  rillig #
     16  1.1  rillig # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  1.1  rillig # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  1.1  rillig # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  1.1  rillig # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  1.1  rillig # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  1.1  rillig # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  1.1  rillig # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  1.1  rillig # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  1.1  rillig # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  1.1  rillig # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  1.1  rillig # POSSIBILITY OF SUCH DAMAGE.
     27  1.1  rillig #
     28  1.1  rillig # $FreeBSD$
     29  1.1  rillig 
     30  1.1  rillig indent=$(atf_config_get usr.bin.indent.test_indent /usr/bin/indent)
     31  1.1  rillig nl='
     32  1.1  rillig '
     33  1.1  rillig 
     34  1.1  rillig atf_test_case 'option_unknown'
     35  1.1  rillig option_unknown_body()
     36  1.1  rillig {
     37  1.1  rillig 	atf_check -s 'exit:1' \
     38  1.1  rillig 	    -e 'inline:indent: Command line: unknown option "-Z-unknown"'"$nl" \
     39  1.1  rillig 	    "$indent" -Z-unknown
     40  1.1  rillig }
     41  1.1  rillig 
     42  1.1  rillig atf_test_case 'option_bool_trailing_garbage'
     43  1.1  rillig option_bool_trailing_garbage_body()
     44  1.1  rillig {
     45  1.1  rillig 	atf_check -s 'exit:1' \
     46  1.1  rillig 	    -e 'inline:indent: Command line: unknown option "-bacchus"'"$nl" \
     47  1.1  rillig 	    "$indent" -bacchus
     48  1.1  rillig }
     49  1.1  rillig 
     50  1.1  rillig atf_test_case 'option_int_missing_parameter'
     51  1.1  rillig option_int_missing_parameter_body()
     52  1.1  rillig {
     53  1.1  rillig 	atf_check -s 'exit:1' \
     54  1.1  rillig 	    -e 'inline:indent: Command line: option "-ts" requires an integer parameter'"$nl" \
     55  1.1  rillig 	    "$indent" -tsx
     56  1.1  rillig }
     57  1.1  rillig 
     58  1.1  rillig atf_init_test_cases()
     59  1.1  rillig {
     60  1.1  rillig 	atf_add_test_case 'option_unknown'
     61  1.1  rillig 	atf_add_test_case 'option_bool_trailing_garbage'
     62  1.1  rillig 	atf_add_test_case 'option_int_missing_parameter'
     63  1.1  rillig }
     64