Browse code

Add test for package file ordering

Add a simple test to ensure package install files remain sorted
alphabetically (follow-on from the sorting of the files done in
I01e42defbf778626afd8dd457f93f0b02dd1a19d)

Change-Id: I75568871e92afcd81dac2c3ce18b84aa34cdd289

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