Remove tempfile after regression script finishes
[guilt.git] / regression / 024-unapplied.sh
blob029a65ccf338a4313a5c44c3c8f317c17fc51e0c
2 # Test the unapplied code
5 source scaffold
7 function prepare_for_tests
9 # set up the repo so we have something interesting to run gq on
10 echo "abc" > def
11 git-add def
12 git-commit -s -m "initial" 2> /dev/null > /dev/null
14 # patch to modify a file
15 cat << DONE > .git/patches/master/modify
16 diff --git a/def b/def
17 index 8baef1b..7d69c2f 100644
18 --- a/def
19 +++ b/def
20 @@ -1 +1,2 @@
21 abc
22 +asjhfksad
23 DONE
25 # patch to add a new file
26 cat << DONE > .git/patches/master/add
27 diff --git a/abd b/abd
28 new file mode 100644
29 index 0000000..489450e
30 --- /dev/null
31 +++ b/abd
32 @@ -0,0 +1 @@
33 +qweert
34 DONE
36 # patch to remove an existing file
37 cat << DONE > .git/patches/master/remove
38 diff --git a/abd b/abd
39 deleted file mode 100644
40 index 489450e..0000000
41 --- a/abd
42 +++ /dev/null
43 @@ -1 +0,0 @@
44 -qweert
45 DONE
47 # patch to change a mode
48 cat << DONE > .git/patches/master/mode
49 diff --git a/def b/def
50 old mode 100644
51 new mode 100755
52 DONE
54 # the series file of all the things
55 cat << DONE > .git/patches/master/series
56 modify
57 add
58 remove
59 mode
60 DONE
63 function expected_status_modify
65 echo "add"
66 echo "remove"
67 echo "mode"
70 function expected_status_add
72 echo "remove"
73 echo "mode"
76 function expected_status_remove
78 echo "mode"
81 function expected_status_mode
83 return 0
86 # the test itself
87 empty_repo
88 cd $REPODIR
89 gq-init
91 prepare_for_tests
93 # NOTE: this has to be in the same order as the series file
94 tests="modify add remove mode"
96 for t in $tests
98 gq-push > /dev/null
100 gq-unapplied > /tmp/reg.$$
102 expected_status_$t | diff -u - /tmp/reg.$$
104 echo -n "[$t] "
105 done
107 rm -f /tmp/reg.$$
109 complete_test