Ian Wienand | ecf06db | 2015-11-09 17:42:23 +1100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # basic test to ensure that package-install files remain sorted |
| 4 | # alphabetically. |
| 5 | |
| 6 | TOP=$(cd $(dirname "$0")/.. && pwd) |
| 7 | |
| 8 | source $TOP/tests/unittest.sh |
| 9 | |
| 10 | PKG_FILES=$(find $TOP/files/debs $TOP/files/rpms $TOP/files/rpms-suse -type f) |
| 11 | |
| 12 | TMPDIR=$(mktemp -d) |
| 13 | |
| 14 | SORTED=${TMPDIR}/sorted |
| 15 | UNSORTED=${TMPDIR}/unsorted |
| 16 | |
| 17 | for p in $PKG_FILES; do |
| 18 | grep -v '^#' $p > ${UNSORTED} |
| 19 | sort ${UNSORTED} > ${SORTED} |
| 20 | |
| 21 | if [ -n "$(diff -c ${UNSORTED} ${SORTED})" ]; then |
| 22 | failed "$p is unsorted" |
| 23 | # output this, it's helpful to see what exactly is unsorted |
| 24 | diff -c ${UNSORTED} ${SORTED} |
| 25 | else |
| 26 | passed "$p is sorted" |
| 27 | fi |
| 28 | done |
| 29 | |
| 30 | rm -rf ${TMPDIR} |
| 31 | |
| 32 | report_results |