# Tests for ob_parse_control() # # Copyright (C) 2018, 2019 Patrick McDermott # # This file is part of opkbuild. # # opkbuild is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # opkbuild is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with opkbuild. If not, see . set -eu . "${TOP_SRCDIR}/tests/aux/tap-functions.sh" . "${TOP_SRCDIR}/tests/aux/common.sh" . "${TOP_BUILDDIR}/lib/libopkbuild.${SHSOEXT}.${LIBOPKBUILD_SHSOVERSION}" LF=' ' CONTROL="$(cat <<-'EOF' Maintainer: "J. Random Hacker" Build-Depends: opkhelper-3.0, libfoo-dev, libbar-dev, Homepage: http://www.example.com/ EOF )" plan_ 7 field=0 field_1() { local name="${1}" local value="${2}" local user_data="${3}" shift 3 is 'maintainer field name' "${name}" 'Maintainer' is 'maintainer field value' "${value}" \ '"J. Random Hacker" ' return 0 } field_2() { local name="${1}" local value="${2}" local user_data="${3}" shift 3 is 'build-depends field name' "${name}" 'Build-Depends' is 'build-depends field value' "${value}" \ "opkhelper-3.0,${LF}libfoo-dev,${LF} libbar-dev," return 0 } field_3() { local name="${1}" local value="${2}" local user_data="${3}" shift 3 is 'homepage field name' "${name}" 'Homepage' is 'homepage field value' "${value}" 'http://www.example.com/' return 0 } field_4() { : This should not be reached. } field_cb() { field=$((${field} + 1)) "field_${field}" "${@}" } ob_parse_control - field_cb '' 'Maintainer' 'Build-Depends Homepage' <<-EOF ${CONTROL} EOF is 'number of parsed fields' "${field}" 3