File: test_wrap-and-sort

package info (click to toggle)
devscripts 2.25.15
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 8,528 kB
  • sloc: perl: 26,530; sh: 11,698; python: 4,428; makefile: 363
file content (59 lines) | stat: -rwxr-xr-x 1,687 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh

# Copyright (C) 2022, Niels Thykier <niels@thykier.net>
#
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.

set -u


WORK_DIR="$(readlink -f "${0%/*}")"
if test "${1:-}" = --installed; then
    wrap_and_sort="wrap-and-sort "
    shift
else
    wrap_and_sort="${WORK_DIR}/../scripts/wrap-and-sort"
fi

. "${WORK_DIR}/test_helper.sh"

oneTimeSetUp() {
  TEMP_DIR=$(mktemp -d -p "$SHUNIT_TMPDIR" wrap-and-sort.XXXXX)
}

# Run as `prepare_and_run_wrap_and_sort <test-name> [args-for-wrap-and-sort]`
prepare_and_run_wrap_and_sort() {
  TEST_NAME="$1"
  shift
  TEST_DIR="${TEMP_DIR}/${TEST_NAME}"

  mkdir "${TEST_DIR}"
  cp -a "${WORK_DIR}/wrap-and-sort/${TEST_NAME}/in/"* "$TEST_DIR/" || exit 1
  assertPasses $wrap_and_sort -d "$TEST_DIR" "$@"
  assertPasses diff -Nuarp "${WORK_DIR}/wrap-and-sort/${TEST_NAME}/out" "${TEST_DIR}"
}

test_build_system_first() {
  prepare_and_run_wrap_and_sort 'build-system-first' -sat
}

test_install_comments() {
  prepare_and_run_wrap_and_sort 'install-comments'
}

test_control_templates() {
  prepare_and_run_wrap_and_sort 'control-templates'
}

. shunit2