Merge branch 'jk/sort-iter-test-output'
authorJunio C Hamano <gitster@pobox.com>
Thu, 1 Aug 2019 16:10:50 +0000 (09:10 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 1 Aug 2019 16:10:50 +0000 (09:10 -0700)
* jk/sort-iter-test-output:
t: sort output of hashmap iteration

t/t0011-hashmap.sh
t/t0016-oidmap.sh
index 9c96b3e3b10a99c20a1e6f5d4d0349c4fbcb0a10..5343ffd3f92c1637bb60719d812a01e0ab6d4064 100755 (executable)
@@ -170,31 +170,45 @@ NULL
 '
 
 test_expect_success 'iterate' '
-
-test_hashmap "put key1 value1
-put key2 value2
-put fooBarFrotz value3
-iterate" "NULL
-NULL
-NULL
-key2 value2
-key1 value1
-fooBarFrotz value3"
-
+       test-tool hashmap >actual.raw <<-\EOF &&
+       put key1 value1
+       put key2 value2
+       put fooBarFrotz value3
+       iterate
+       EOF
+
+       cat >expect <<-\EOF &&
+       NULL
+       NULL
+       NULL
+       fooBarFrotz value3
+       key1 value1
+       key2 value2
+       EOF
+
+       sort <actual.raw >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success 'iterate (case insensitive)' '
-
-test_hashmap "put key1 value1
-put key2 value2
-put fooBarFrotz value3
-iterate" "NULL
-NULL
-NULL
-fooBarFrotz value3
-key2 value2
-key1 value1" ignorecase
-
+       test-tool hashmap ignorecase >actual.raw <<-\EOF &&
+       put key1 value1
+       put key2 value2
+       put fooBarFrotz value3
+       iterate
+       EOF
+
+       cat >expect <<-\EOF &&
+       NULL
+       NULL
+       NULL
+       fooBarFrotz value3
+       key1 value1
+       key2 value2
+       EOF
+
+       sort <actual.raw >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success 'grow / shrink' '
index bbe719e9509689e38dd1d524d5d4b57de934a757..31f8276ba82bad3129c4a3cfa92f2d0ba798073c 100755 (executable)
@@ -86,17 +86,25 @@ NULL"
 '
 
 test_expect_success 'iterate' '
-
-test_oidmap "put one 1
-put two 2
-put three 3
-iterate" "NULL
-NULL
-NULL
-$(git rev-parse two) 2
-$(git rev-parse one) 1
-$(git rev-parse three) 3"
-
+       test-tool oidmap >actual.raw <<-\EOF &&
+       put one 1
+       put two 2
+       put three 3
+       iterate
+       EOF
+
+       # sort "expect" too so we do not rely on the order of particular oids
+       sort >expect <<-EOF &&
+       NULL
+       NULL
+       NULL
+       $(git rev-parse one) 1
+       $(git rev-parse two) 2
+       $(git rev-parse three) 3
+       EOF
+
+       sort <actual.raw >actual &&
+       test_cmp expect actual
 '
 
 test_done