Blob


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