@matheusbsbs / matheus-bagliano / commits / b26d8d217d
Fork 0

Test git-patch-id

So far, git-patch-id was untested. Add some simple checks for output format and patch (in)equality. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Thomas Rast committed Feb 19, 2009 at 12:13 UTC b26d8d217d8d960cbd9ed1dbf6b3cccfd1a3a4db
1 file changed +38
t/t4203-patch-id.sh new
+38
@@ -0,0 +1,38 @@
1 +#!/bin/sh
2 +
3 +test_description='git patch-id'
4 +
5 +. ./test-lib.sh
6 +
7 +test_expect_success 'setup' '
8 + test_commit initial foo a &&
9 + test_commit first foo b &&
10 + git checkout -b same HEAD^ &&
11 + test_commit same-msg foo b &&
12 + git checkout -b notsame HEAD^ &&
13 + test_commit notsame-msg foo c
14 +'
15 +
16 +test_expect_success 'patch-id output is well-formed' '
17 + git log -p -1 | git patch-id > output &&
18 + grep "^[a-f0-9]\{40\} $(git rev-parse HEAD)$" output
19 +'
20 +
21 +get_patch_id () {
22 + git log -p -1 "$1" | git patch-id |
23 + sed "s# .*##" > patch-id_"$1"
24 +}
25 +
26 +test_expect_success 'patch-id detects equality' '
27 + get_patch_id master &&
28 + get_patch_id same &&
29 + test_cmp patch-id_master patch-id_same
30 +'
31 +
32 +test_expect_success 'patch-id detects inequality' '
33 + get_patch_id master &&
34 + get_patch_id notsame &&
35 + ! test_cmp patch-id_master patch-id_notsame
36 +'
37 +
38 +test_done