1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2019 Martin Matuska
5 * All rights reserved.
6 */
7 #include "test.h"
8
DEFINE_TEST(test_option_exclude_vcs)9 DEFINE_TEST(test_option_exclude_vcs)
10 {
11 assertUmask(0);
12 assertMakeDir("in", 0755);
13 assertChdir("in");
14 assertMakeFile("file", 0644, "");
15 assertMakeDir("dir", 0755);
16 assertMakeDir("CVS", 0755);
17 assertMakeFile("CVS/fileattr", 0644, "");
18 assertMakeFile(".cvsignore", 0644, "");
19 assertMakeDir("RCS", 0755);
20 assertMakeFile("RCS/somefile", 0655, "");
21 assertMakeDir("SCCS", 0755);
22 assertMakeFile("SCCS/somefile", 0655, "");
23 assertMakeDir(".svn", 0755);
24 assertMakeFile(".svn/format", 0655, "");
25 assertMakeDir(".git", 0755);
26 assertMakeFile(".git/config", 0655, "");
27 assertMakeFile(".gitignore", 0644, "");
28 assertMakeFile(".gitattributes", 0644, "");
29 assertMakeFile(".gitmodules", 0644, "");
30 assertMakeDir(".arch-ids", 0755);
31 assertMakeFile(".arch-ids/somefile", 0644, "");
32 assertMakeDir("{arch}", 0755);
33 assertMakeFile("{arch}/somefile", 0644, "");
34 assertMakeFile("=RELEASE-ID", 0644, "");
35 assertMakeFile("=meta-update", 0644, "");
36 assertMakeFile("=update", 0644, "");
37 assertMakeDir(".bzr", 0755);
38 assertMakeDir(".bzr/checkout", 0755);
39 assertMakeFile(".bzrignore", 0644, "");
40 assertMakeFile(".bzrtags", 0644, "");
41 assertMakeDir(".hg", 0755);
42 assertMakeFile(".hg/dirstate", 0644, "");
43 assertMakeFile(".hgignore", 0644, "");
44 assertMakeFile(".hgtags", 0644, "");
45 assertMakeDir("_darcs", 0755);
46 assertMakeFile("_darcs/format", 0644, "");
47 assertChdir("..");
48
49 assertEqualInt(0, systemf("%s -c -C in -f included.tar .", testprog));
50 assertEqualInt(0,
51 systemf("%s -c --exclude-vcs -C in -f excluded.tar .", testprog));
52
53 /* No flags, archive with vcs files */
54 assertMakeDir("vcs-noexclude", 0755);
55 assertEqualInt(0, systemf("%s -x -C vcs-noexclude -f included.tar",
56 testprog));
57 assertChdir("vcs-noexclude");
58 assertFileExists("file");
59 assertIsDir("dir", 0755);
60 assertIsDir("CVS", 0755);
61 assertFileExists("CVS/fileattr");
62 assertFileExists(".cvsignore");
63 assertIsDir("RCS", 0755);
64 assertFileExists("RCS/somefile");
65 assertIsDir("SCCS", 0755);
66 assertFileExists("SCCS/somefile");
67 assertIsDir(".svn", 0755);
68 assertFileExists(".svn/format");
69 assertIsDir(".git", 0755);
70 assertFileExists(".git/config");
71 assertFileExists(".gitignore");
72 assertFileExists(".gitattributes");
73 assertFileExists(".gitmodules");
74 assertIsDir(".arch-ids", 0755);
75 assertFileExists(".arch-ids/somefile");
76 assertIsDir("{arch}", 0755);
77 assertFileExists("{arch}/somefile");
78 assertFileExists("=RELEASE-ID");
79 assertFileExists("=meta-update");
80 assertFileExists("=update");
81 assertIsDir(".bzr", 0755);
82 assertIsDir(".bzr/checkout", 0755);
83 assertFileExists(".bzrignore");
84 assertFileExists(".bzrtags");
85 assertIsDir(".hg", 0755);
86 assertFileExists(".hg/dirstate");
87 assertFileExists(".hgignore");
88 assertFileExists(".hgtags");
89 assertIsDir("_darcs", 0755);
90 assertFileExists("_darcs/format");
91 assertChdir("..");
92
93 /* --exclude-vcs, archive with vcs files */
94 assertMakeDir("vcs-exclude", 0755);
95 assertEqualInt(0,
96 systemf("%s -x --exclude-vcs -C vcs-exclude -f included.tar", testprog));
97 assertChdir("vcs-exclude");
98 assertFileExists("file");
99 assertIsDir("dir", 0755);
100 assertFileNotExists("CVS");
101 assertFileNotExists("CVS/fileattr");
102 assertFileNotExists(".cvsignore");
103 assertFileNotExists("RCS");
104 assertFileNotExists("RCS/somefile");
105 assertFileNotExists("SCCS");
106 assertFileNotExists("SCCS/somefile");
107 assertFileNotExists(".svn");
108 assertFileNotExists(".svn/format");
109 assertFileNotExists(".git");
110 assertFileNotExists(".git/config");
111 assertFileNotExists(".gitignore");
112 assertFileNotExists(".gitattributes");
113 assertFileNotExists(".gitmodules");
114 assertFileNotExists(".arch-ids");
115 assertFileNotExists(".arch-ids/somefile");
116 assertFileNotExists("{arch}");
117 assertFileNotExists("{arch}/somefile");
118 assertFileNotExists("=RELEASE-ID");
119 assertFileNotExists("=meta-update");
120 assertFileNotExists("=update");
121 assertFileNotExists(".bzr");
122 assertFileNotExists(".bzr/checkout");
123 assertFileNotExists(".bzrignore");
124 assertFileNotExists(".bzrtags");
125 assertFileNotExists(".hg");
126 assertFileNotExists(".hg/dirstate");
127 assertFileNotExists(".hgignore");
128 assertFileNotExists(".hgtags");
129 assertFileNotExists("_darcs");
130 assertFileNotExists("_darcs/format");
131 assertChdir("..");
132
133 /* --exclude-vcs, archive without vcs files */
134 assertMakeDir("novcs-exclude", 0755);
135 assertEqualInt(0,
136 systemf("%s -x --exclude-vcs -C novcs-exclude -f excluded.tar",
137 testprog));
138 assertChdir("novcs-exclude");
139 assertFileExists("file");
140 assertIsDir("dir", 0755);
141 assertFileNotExists("CVS");
142 assertFileNotExists("CVS/fileattr");
143 assertFileNotExists(".cvsignore");
144 assertFileNotExists("RCS");
145 assertFileNotExists("RCS/somefile");
146 assertFileNotExists("SCCS");
147 assertFileNotExists("SCCS/somefile");
148 assertFileNotExists(".svn");
149 assertFileNotExists(".svn/format");
150 assertFileNotExists(".git");
151 assertFileNotExists(".git/config");
152 assertFileNotExists(".gitignore");
153 assertFileNotExists(".gitattributes");
154 assertFileNotExists(".gitmodules");
155 assertFileNotExists(".arch-ids");
156 assertFileNotExists(".arch-ids/somefile");
157 assertFileNotExists("{arch}");
158 assertFileNotExists("{arch}/somefile");
159 assertFileNotExists("=RELEASE-ID");
160 assertFileNotExists("=meta-update");
161 assertFileNotExists("=update");
162 assertFileNotExists(".bzr");
163 assertFileNotExists(".bzr/checkout");
164 assertFileNotExists(".bzrignore");
165 assertFileNotExists(".bzrtags");
166 assertFileNotExists(".hg");
167 assertFileNotExists(".hg/dirstate");
168 assertFileNotExists(".hgignore");
169 assertFileNotExists(".hgtags");
170 assertFileNotExists("_darcs");
171 assertFileNotExists("_darcs/format");
172 assertChdir("..");
173
174 /* No flags, archive without vcs files */
175 assertMakeDir("novcs-noexclude", 0755);
176 assertEqualInt(0,
177 systemf("%s -x -C novcs-noexclude -f excluded.tar", testprog));
178 assertChdir("novcs-noexclude");
179 assertFileExists("file");
180 assertIsDir("dir", 0755);
181 assertFileNotExists("CVS");
182 assertFileNotExists("CVS/fileattr");
183 assertFileNotExists(".cvsignore");
184 assertFileNotExists("RCS");
185 assertFileNotExists("RCS/somefile");
186 assertFileNotExists("SCCS");
187 assertFileNotExists("SCCS/somefile");
188 assertFileNotExists(".svn");
189 assertFileNotExists(".svn/format");
190 assertFileNotExists(".git");
191 assertFileNotExists(".git/config");
192 assertFileNotExists(".gitignore");
193 assertFileNotExists(".gitattributes");
194 assertFileNotExists(".gitmodules");
195 assertFileNotExists(".arch-ids");
196 assertFileNotExists(".arch-ids/somefile");
197 assertFileNotExists("{arch}");
198 assertFileNotExists("{arch}/somefile");
199 assertFileNotExists("=RELEASE-ID");
200 assertFileNotExists("=meta-update");
201 assertFileNotExists("=update");
202 assertFileNotExists(".bzr");
203 assertFileNotExists(".bzr/checkout");
204 assertFileNotExists(".bzrignore");
205 assertFileNotExists(".bzrtags");
206 assertFileNotExists(".hg");
207 assertFileNotExists(".hg/dirstate");
208 assertFileNotExists(".hgignore");
209 assertFileNotExists(".hgtags");
210 assertFileNotExists("_darcs");
211 assertFileNotExists("_darcs/format");
212 }
213