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_status_basic {
20 local testroot=`test_init status_basic`
22 got checkout $testroot/repo $testroot/wt > /dev/null
23 if [ "$?" != "0" ]; then
24 test_done "$testroot" "$?"
25 return 1
26 fi
28 echo "modified alpha" > $testroot/wt/alpha
29 echo "unversioned file" > $testroot/wt/foo
30 rm $testroot/wt/epsilon/zeta
32 echo 'M alpha' > $testroot/stdout.expected
33 echo '! epsilon/zeta' >> $testroot/stdout.expected
34 echo '? foo' >> $testroot/stdout.expected
36 (cd $testroot/wt && got status > $testroot/stdout)
38 cmp $testroot/stdout.expected $testroot/stdout
39 if [ "$?" != "0" ]; then
40 diff -u $testroot/stdout.expected $testroot/stdout
41 test_done "$testroot" "$?"
42 return 1
43 fi
45 test_done "$testroot" "0"
46 }
48 function test_status_subdir_no_mods {
49 local testroot=`test_init status_subdir_no_mods 1`
51 mkdir $testroot/repo/Basic/
52 mkdir $testroot/repo/Basic/Targets/
53 touch $testroot/repo/Basic/Targets/AArch64.cpp
54 touch $testroot/repo/Basic/Targets.cpp
55 touch $testroot/repo/Basic/Targets.h
56 (cd $testroot/repo && git add .)
57 git_commit $testroot/repo -m "add subdir with files"
59 got checkout $testroot/repo $testroot/wt > /dev/null
60 if [ "$?" != "0" ]; then
61 test_done "$testroot" "$?"
62 return 1
63 fi
65 touch $testroot/stdout.expected
67 # This used to erroneously print:
68 #
69 # ! Basic/Targets.cpp
70 # ? Basic/Targets.cpp
71 (cd $testroot/wt && got status > $testroot/stdout)
73 cmp $testroot/stdout.expected $testroot/stdout
74 if [ "$?" != "0" ]; then
75 diff -u $testroot/stdout.expected $testroot/stdout
76 test_done "$testroot" "$?"
77 return 1
78 fi
80 test_done "$testroot" "0"
81 }
83 function test_status_subdir_no_mods2 {
84 local testroot=`test_init status_subdir_no_mods2 1`
86 mkdir $testroot/repo/AST
87 touch $testroot/repo/AST/APValue.cpp
88 mkdir $testroot/repo/ASTMatchers
89 touch $testroot/repo/ASTMatchers/ASTMatchFinder.cpp
90 mkdir $testroot/repo/Frontend
91 touch $testroot/repo/Frontend/ASTConsumers.cpp
92 mkdir $testroot/repo/Frontend/Rewrite
93 touch $testroot/repo/Frontend/Rewrite/CMakeLists.txt
94 mkdir $testroot/repo/FrontendTool
95 touch $testroot/repo/FrontendTool/CMakeLists.txt
96 touch $testroot/repo/FrontendTool/ExecuteCompilerInvocation.cpp
97 (cd $testroot/repo && git add .)
98 git_commit $testroot/repo -m "add subdir with files"
100 got checkout $testroot/repo $testroot/wt > /dev/null
101 if [ "$?" != "0" ]; then
102 test_done "$testroot" "$?"
103 return 1
104 fi
106 touch $testroot/stdout.expected
108 # This used to erroneously print:
110 # ! AST/APValue.cpp
111 # ? AST/APValue.cpp
112 # ! Frontend/ASTConsumers.cpp
113 # ! Frontend/Rewrite/CMakeLists.txt
114 # ? Frontend/ASTConsumers.cpp
115 # ? Frontend/Rewrite/CMakeLists.txt
116 (cd $testroot/wt && got status > $testroot/stdout)
118 cmp $testroot/stdout.expected $testroot/stdout
119 if [ "$?" != "0" ]; then
120 diff -u $testroot/stdout.expected $testroot/stdout
121 test_done "$testroot" "$?"
122 return 1
123 fi
125 test_done "$testroot" "0"
128 run_test test_status_basic
129 run_test test_status_subdir_no_mods
130 run_test test_status_subdir_no_mods2