]> arthur.barton.de Git - bup.git/commitdiff
test-gc: sort ls output defensively before comm
authorRob Browning <rlb@defaultvalue.org>
Sat, 5 Nov 2016 19:36:20 +0000 (14:36 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sat, 5 Nov 2016 19:40:55 +0000 (14:40 -0500)
Explicitly sort the output of ls before passing it to comm in order to
accommodate some systems that apparently used to change the default sort
order.  The order must match LC_COLLATE for comm to work.

While we're here, improve error checking around the comm invocations.

Thanks to Nick Alcock for reporting the original problem, and proposing
an initial fix.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
t/test-gc.sh

index f3059549921a50267cad47c84b8f6143efae1fa8..82be29ca867c64c84f9e3d3f3b33b1887917667d 100755 (executable)
@@ -201,13 +201,22 @@ packs_after="$(ls "$BUP_DIR/objects/pack/"*.pack)" || exit $?
 WVPASSEQ 1 "$(grep -cE '^rewriting ' gc.log)"
 
 # Check that only one pack was rewritten
-only_in_before="$(comm -2 -3 <(echo "$packs_before") <(echo "$packs_after"))"
-only_in_after="$(comm -1 -3 <(echo "$packs_before") <(echo "$packs_after"))"
-in_both="$(comm -1 -2 <(echo "$packs_before") <(echo "$packs_after"))"
+
+# Accommodate some systems that apparently used to change the default
+# ls sort order which must match LC_COLLATE for comm to work.
+packs_before="$(sort <(echo "$packs_before"))" || die $?
+packs_after="$(sort <(echo "$packs_after"))" || die $?
+
+only_in_before="$(comm -2 -3 <(echo "$packs_before") <(echo "$packs_after"))" \
+    || die $?
+
+only_in_after="$(comm -1 -3 <(echo "$packs_before") <(echo "$packs_after"))" \
+    || die $?
+
+in_both="$(comm -1 -2 <(echo "$packs_before") <(echo "$packs_after"))" || die $?
 
 WVPASSEQ 1 $(echo "$only_in_before" | wc -l)
 WVPASSEQ 1 $(echo "$only_in_after" | wc -l)
 WVPASSEQ 1 $(echo "$in_both" | wc -l)
 
-
 WVPASS rm -rf "$tmpdir"