applied, unapplied, and top regression scripts
[gq.git] / regression / 022-applied.sh
blobac26efc4c5cdbc6d69ff25910003093a7f0ac465
2 # Test the applied 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 "modify"
68 function expected_status_add
70 echo "modify"
71 echo "add"
74 function expected_status_remove
76 echo "modify"
77 echo "add"
78 echo "remove"
81 function expected_status_mode
83 echo "modify"
84 echo "add"
85 echo "remove"
86 echo "mode"
89 # the test itself
90 empty_repo
91 cd $REPODIR
92 gq-init
94 prepare_for_tests
96 # NOTE: this has to be in the same order as the series file
97 tests="modify add remove mode"
99 for t in $tests
101 gq-push > /dev/null
103 gq-applied > /tmp/reg.$$
105 expected_status_$t | diff -u - /tmp/reg.$$
106 expected_status_$t | diff -u - $REPODIR/.git/patches/master/status
108 echo -n "[$t] "
109 done
111 rm -f /tmp/reg.$$
113 complete_test