1 1.1 rillig #! /bin/sh 2 1.11 rillig # $NetBSD: t_options.sh,v 1.11 2023/05/20 21:32:05 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 # Tests for indent that focus on comparing the effects of the various command 29 1.1 rillig # line options. 30 1.1 rillig # 31 1.1 rillig # The test files contain the input to be formatted, the formatting options 32 1.1 rillig # and the output, all as close together as possible. The test files use the 33 1.1 rillig # following directives: 34 1.1 rillig # 35 1.10 rillig # //indent input [description] 36 1.1 rillig # Specifies the input to be formatted. 37 1.10 rillig # //indent run [options] 38 1.1 rillig # Runs indent on the input, using the given options. 39 1.10 rillig # //indent end [description] 40 1.10 rillig # Finishes an '//indent input' or '//indent run' section. 41 1.10 rillig # //indent run-equals-input [options] 42 1.3 rillig # Runs indent on the input, expecting unmodified output. 43 1.10 rillig # //indent run-equals-prev-output [options] 44 1.5 rillig # Runs indent on the input, expecting the same output as from 45 1.5 rillig # the previous run. 46 1.1 rillig # 47 1.5 rillig # All text outside these directives is not passed to indent. 48 1.1 rillig 49 1.1 rillig srcdir=$(atf_get_srcdir) 50 1.1 rillig indent=$(atf_config_get usr.bin.indent.test_indent /usr/bin/indent) 51 1.1 rillig 52 1.1 rillig check() 53 1.1 rillig { 54 1.1 rillig atf_check -o "file:expected.out" \ 55 1.11 rillig env INDENT="$indent" lua "$srcdir/t_options.lua" "$srcdir/$1.c" 56 1.1 rillig } 57 1.1 rillig 58 1.1 rillig atf_init_test_cases() 59 1.1 rillig { 60 1.6 rillig for fname in "$srcdir"/*.c; do 61 1.1 rillig test_name=${fname##*/} 62 1.1 rillig test_name=${test_name%.c} 63 1.1 rillig 64 1.1 rillig atf_test_case "$test_name" 65 1.1 rillig eval "${test_name}_body() { check '$test_name'; }" 66 1.1 rillig atf_add_test_case "$test_name" 67 1.1 rillig done 68 1.1 rillig } 69