Blame


1 5ef14e63 2019-06-02 stsp #!/bin/sh
2 5ef14e63 2019-06-02 stsp #
3 5ef14e63 2019-06-02 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 5ef14e63 2019-06-02 stsp #
5 5ef14e63 2019-06-02 stsp # Permission to use, copy, modify, and distribute this software for any
6 5ef14e63 2019-06-02 stsp # purpose with or without fee is hereby granted, provided that the above
7 5ef14e63 2019-06-02 stsp # copyright notice and this permission notice appear in all copies.
8 5ef14e63 2019-06-02 stsp #
9 5ef14e63 2019-06-02 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 5ef14e63 2019-06-02 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 5ef14e63 2019-06-02 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 5ef14e63 2019-06-02 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 5ef14e63 2019-06-02 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 5ef14e63 2019-06-02 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 5ef14e63 2019-06-02 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 5ef14e63 2019-06-02 stsp
17 5ef14e63 2019-06-02 stsp . ./common.sh
18 5ef14e63 2019-06-02 stsp
19 5ef14e63 2019-06-02 stsp function test_backout_basic {
20 5ef14e63 2019-06-02 stsp local testroot=`test_init backout_basic`
21 5ef14e63 2019-06-02 stsp
22 5ef14e63 2019-06-02 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 5ef14e63 2019-06-02 stsp ret="$?"
24 5ef14e63 2019-06-02 stsp if [ "$ret" != "0" ]; then
25 5ef14e63 2019-06-02 stsp test_done "$testroot" "$ret"
26 5ef14e63 2019-06-02 stsp return 1
27 5ef14e63 2019-06-02 stsp fi
28 5ef14e63 2019-06-02 stsp
29 5ef14e63 2019-06-02 stsp echo "modified alpha" > $testroot/wt/alpha
30 5ef14e63 2019-06-02 stsp (cd $testroot/wt && got commit -m "changing alpha" > /dev/null)
31 5ef14e63 2019-06-02 stsp
32 5ef14e63 2019-06-02 stsp local bad_commit=`git_show_head $testroot/repo`
33 5ef14e63 2019-06-02 stsp
34 5ef14e63 2019-06-02 stsp
35 5ef14e63 2019-06-02 stsp (cd $testroot/wt && got update > /dev/null)
36 5ef14e63 2019-06-02 stsp
37 5ef14e63 2019-06-02 stsp echo "modified beta" > $testroot/wt/beta
38 5ef14e63 2019-06-02 stsp (cd $testroot/wt && got commit -m "changing beta" > /dev/null)
39 5ef14e63 2019-06-02 stsp
40 5ef14e63 2019-06-02 stsp (cd $testroot/wt && got update > /dev/null)
41 5ef14e63 2019-06-02 stsp
42 5ef14e63 2019-06-02 stsp (cd $testroot/wt && got backout $bad_commit > $testroot/stdout)
43 5ef14e63 2019-06-02 stsp
44 5ef14e63 2019-06-02 stsp echo "G alpha" > $testroot/stdout.expected
45 a7648d7a 2019-06-02 stsp echo "Backed out commit $bad_commit" >> $testroot/stdout.expected
46 5ef14e63 2019-06-02 stsp cmp -s $testroot/stdout.expected $testroot/stdout
47 5ef14e63 2019-06-02 stsp ret="$?"
48 5ef14e63 2019-06-02 stsp if [ "$ret" != "0" ]; then
49 5ef14e63 2019-06-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
50 5ef14e63 2019-06-02 stsp test_done "$testroot" "$ret"
51 5ef14e63 2019-06-02 stsp return 1
52 5ef14e63 2019-06-02 stsp fi
53 5ef14e63 2019-06-02 stsp
54 5ef14e63 2019-06-02 stsp echo "alpha" > $testroot/content.expected
55 5ef14e63 2019-06-02 stsp cat $testroot/wt/alpha > $testroot/content
56 5ef14e63 2019-06-02 stsp cmp -s $testroot/content.expected $testroot/content
57 5ef14e63 2019-06-02 stsp ret="$?"
58 5ef14e63 2019-06-02 stsp if [ "$ret" != "0" ]; then
59 5ef14e63 2019-06-02 stsp diff -u $testroot/content.expected $testroot/content
60 5ef14e63 2019-06-02 stsp test_done "$testroot" "$ret"
61 5ef14e63 2019-06-02 stsp return 1
62 5ef14e63 2019-06-02 stsp fi
63 5ef14e63 2019-06-02 stsp
64 5ef14e63 2019-06-02 stsp echo 'M alpha' > $testroot/stdout.expected
65 5ef14e63 2019-06-02 stsp (cd $testroot/wt && got status > $testroot/stdout)
66 5ef14e63 2019-06-02 stsp cmp -s $testroot/stdout.expected $testroot/stdout
67 5ef14e63 2019-06-02 stsp ret="$?"
68 5ef14e63 2019-06-02 stsp if [ "$ret" != "0" ]; then
69 5ef14e63 2019-06-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
70 5ef14e63 2019-06-02 stsp fi
71 5ef14e63 2019-06-02 stsp test_done "$testroot" "$ret"
72 5ef14e63 2019-06-02 stsp }
73 5ef14e63 2019-06-02 stsp
74 5ef14e63 2019-06-02 stsp run_test test_backout_basic