152c2bb75SMartin Matuska /*-
2*bd66c1b4SMartin Matuska * SPDX-License-Identifier: BSD-2-Clause
3*bd66c1b4SMartin Matuska *
452c2bb75SMartin Matuska * Copyright (c) 2019 Martin Matuska
552c2bb75SMartin Matuska * All rights reserved.
652c2bb75SMartin Matuska */
752c2bb75SMartin Matuska #include "test.h"
852c2bb75SMartin Matuska
DEFINE_TEST(test_option_exclude_vcs)952c2bb75SMartin Matuska DEFINE_TEST(test_option_exclude_vcs)
1052c2bb75SMartin Matuska {
11b9128a37SMartin Matuska assertUmask(0);
1252c2bb75SMartin Matuska assertMakeDir("in", 0755);
1352c2bb75SMartin Matuska assertChdir("in");
1452c2bb75SMartin Matuska assertMakeFile("file", 0644, "");
1552c2bb75SMartin Matuska assertMakeDir("dir", 0755);
1652c2bb75SMartin Matuska assertMakeDir("CVS", 0755);
1752c2bb75SMartin Matuska assertMakeFile("CVS/fileattr", 0644, "");
1852c2bb75SMartin Matuska assertMakeFile(".cvsignore", 0644, "");
1952c2bb75SMartin Matuska assertMakeDir("RCS", 0755);
2052c2bb75SMartin Matuska assertMakeFile("RCS/somefile", 0655, "");
2152c2bb75SMartin Matuska assertMakeDir("SCCS", 0755);
2252c2bb75SMartin Matuska assertMakeFile("SCCS/somefile", 0655, "");
2352c2bb75SMartin Matuska assertMakeDir(".svn", 0755);
2452c2bb75SMartin Matuska assertMakeFile(".svn/format", 0655, "");
2552c2bb75SMartin Matuska assertMakeDir(".git", 0755);
2652c2bb75SMartin Matuska assertMakeFile(".git/config", 0655, "");
2752c2bb75SMartin Matuska assertMakeFile(".gitignore", 0644, "");
2852c2bb75SMartin Matuska assertMakeFile(".gitattributes", 0644, "");
2952c2bb75SMartin Matuska assertMakeFile(".gitmodules", 0644, "");
3052c2bb75SMartin Matuska assertMakeDir(".arch-ids", 0755);
3152c2bb75SMartin Matuska assertMakeFile(".arch-ids/somefile", 0644, "");
3252c2bb75SMartin Matuska assertMakeDir("{arch}", 0755);
3352c2bb75SMartin Matuska assertMakeFile("{arch}/somefile", 0644, "");
3452c2bb75SMartin Matuska assertMakeFile("=RELEASE-ID", 0644, "");
3552c2bb75SMartin Matuska assertMakeFile("=meta-update", 0644, "");
3652c2bb75SMartin Matuska assertMakeFile("=update", 0644, "");
3752c2bb75SMartin Matuska assertMakeDir(".bzr", 0755);
3852c2bb75SMartin Matuska assertMakeDir(".bzr/checkout", 0755);
3952c2bb75SMartin Matuska assertMakeFile(".bzrignore", 0644, "");
4052c2bb75SMartin Matuska assertMakeFile(".bzrtags", 0644, "");
4152c2bb75SMartin Matuska assertMakeDir(".hg", 0755);
4252c2bb75SMartin Matuska assertMakeFile(".hg/dirstate", 0644, "");
4352c2bb75SMartin Matuska assertMakeFile(".hgignore", 0644, "");
4452c2bb75SMartin Matuska assertMakeFile(".hgtags", 0644, "");
4552c2bb75SMartin Matuska assertMakeDir("_darcs", 0755);
4652c2bb75SMartin Matuska assertMakeFile("_darcs/format", 0644, "");
4752c2bb75SMartin Matuska assertChdir("..");
4852c2bb75SMartin Matuska
4952c2bb75SMartin Matuska assertEqualInt(0, systemf("%s -c -C in -f included.tar .", testprog));
5052c2bb75SMartin Matuska assertEqualInt(0,
5152c2bb75SMartin Matuska systemf("%s -c --exclude-vcs -C in -f excluded.tar .", testprog));
5252c2bb75SMartin Matuska
5352c2bb75SMartin Matuska /* No flags, archive with vcs files */
5452c2bb75SMartin Matuska assertMakeDir("vcs-noexclude", 0755);
5552c2bb75SMartin Matuska assertEqualInt(0, systemf("%s -x -C vcs-noexclude -f included.tar",
5652c2bb75SMartin Matuska testprog));
5752c2bb75SMartin Matuska assertChdir("vcs-noexclude");
5852c2bb75SMartin Matuska assertFileExists("file");
5952c2bb75SMartin Matuska assertIsDir("dir", 0755);
6052c2bb75SMartin Matuska assertIsDir("CVS", 0755);
6152c2bb75SMartin Matuska assertFileExists("CVS/fileattr");
6252c2bb75SMartin Matuska assertFileExists(".cvsignore");
6352c2bb75SMartin Matuska assertIsDir("RCS", 0755);
6452c2bb75SMartin Matuska assertFileExists("RCS/somefile");
6552c2bb75SMartin Matuska assertIsDir("SCCS", 0755);
6652c2bb75SMartin Matuska assertFileExists("SCCS/somefile");
6752c2bb75SMartin Matuska assertIsDir(".svn", 0755);
6852c2bb75SMartin Matuska assertFileExists(".svn/format");
6952c2bb75SMartin Matuska assertIsDir(".git", 0755);
7052c2bb75SMartin Matuska assertFileExists(".git/config");
7152c2bb75SMartin Matuska assertFileExists(".gitignore");
7252c2bb75SMartin Matuska assertFileExists(".gitattributes");
7352c2bb75SMartin Matuska assertFileExists(".gitmodules");
7452c2bb75SMartin Matuska assertIsDir(".arch-ids", 0755);
7552c2bb75SMartin Matuska assertFileExists(".arch-ids/somefile");
7652c2bb75SMartin Matuska assertIsDir("{arch}", 0755);
7752c2bb75SMartin Matuska assertFileExists("{arch}/somefile");
7852c2bb75SMartin Matuska assertFileExists("=RELEASE-ID");
7952c2bb75SMartin Matuska assertFileExists("=meta-update");
8052c2bb75SMartin Matuska assertFileExists("=update");
8152c2bb75SMartin Matuska assertIsDir(".bzr", 0755);
8252c2bb75SMartin Matuska assertIsDir(".bzr/checkout", 0755);
8352c2bb75SMartin Matuska assertFileExists(".bzrignore");
8452c2bb75SMartin Matuska assertFileExists(".bzrtags");
8552c2bb75SMartin Matuska assertIsDir(".hg", 0755);
8652c2bb75SMartin Matuska assertFileExists(".hg/dirstate");
8752c2bb75SMartin Matuska assertFileExists(".hgignore");
8852c2bb75SMartin Matuska assertFileExists(".hgtags");
8952c2bb75SMartin Matuska assertIsDir("_darcs", 0755);
9052c2bb75SMartin Matuska assertFileExists("_darcs/format");
9152c2bb75SMartin Matuska assertChdir("..");
9252c2bb75SMartin Matuska
9352c2bb75SMartin Matuska /* --exclude-vcs, archive with vcs files */
9452c2bb75SMartin Matuska assertMakeDir("vcs-exclude", 0755);
9552c2bb75SMartin Matuska assertEqualInt(0,
9652c2bb75SMartin Matuska systemf("%s -x --exclude-vcs -C vcs-exclude -f included.tar", testprog));
9752c2bb75SMartin Matuska assertChdir("vcs-exclude");
9852c2bb75SMartin Matuska assertFileExists("file");
9952c2bb75SMartin Matuska assertIsDir("dir", 0755);
10052c2bb75SMartin Matuska assertFileNotExists("CVS");
10152c2bb75SMartin Matuska assertFileNotExists("CVS/fileattr");
10252c2bb75SMartin Matuska assertFileNotExists(".cvsignore");
10352c2bb75SMartin Matuska assertFileNotExists("RCS");
10452c2bb75SMartin Matuska assertFileNotExists("RCS/somefile");
10552c2bb75SMartin Matuska assertFileNotExists("SCCS");
10652c2bb75SMartin Matuska assertFileNotExists("SCCS/somefile");
10752c2bb75SMartin Matuska assertFileNotExists(".svn");
10852c2bb75SMartin Matuska assertFileNotExists(".svn/format");
10952c2bb75SMartin Matuska assertFileNotExists(".git");
11052c2bb75SMartin Matuska assertFileNotExists(".git/config");
11152c2bb75SMartin Matuska assertFileNotExists(".gitignore");
11252c2bb75SMartin Matuska assertFileNotExists(".gitattributes");
11352c2bb75SMartin Matuska assertFileNotExists(".gitmodules");
11452c2bb75SMartin Matuska assertFileNotExists(".arch-ids");
11552c2bb75SMartin Matuska assertFileNotExists(".arch-ids/somefile");
11652c2bb75SMartin Matuska assertFileNotExists("{arch}");
11752c2bb75SMartin Matuska assertFileNotExists("{arch}/somefile");
11852c2bb75SMartin Matuska assertFileNotExists("=RELEASE-ID");
11952c2bb75SMartin Matuska assertFileNotExists("=meta-update");
12052c2bb75SMartin Matuska assertFileNotExists("=update");
12152c2bb75SMartin Matuska assertFileNotExists(".bzr");
12252c2bb75SMartin Matuska assertFileNotExists(".bzr/checkout");
12352c2bb75SMartin Matuska assertFileNotExists(".bzrignore");
12452c2bb75SMartin Matuska assertFileNotExists(".bzrtags");
12552c2bb75SMartin Matuska assertFileNotExists(".hg");
12652c2bb75SMartin Matuska assertFileNotExists(".hg/dirstate");
12752c2bb75SMartin Matuska assertFileNotExists(".hgignore");
12852c2bb75SMartin Matuska assertFileNotExists(".hgtags");
12952c2bb75SMartin Matuska assertFileNotExists("_darcs");
13052c2bb75SMartin Matuska assertFileNotExists("_darcs/format");
13152c2bb75SMartin Matuska assertChdir("..");
13252c2bb75SMartin Matuska
13352c2bb75SMartin Matuska /* --exclude-vcs, archive without vcs files */
13452c2bb75SMartin Matuska assertMakeDir("novcs-exclude", 0755);
13552c2bb75SMartin Matuska assertEqualInt(0,
13652c2bb75SMartin Matuska systemf("%s -x --exclude-vcs -C novcs-exclude -f excluded.tar",
13752c2bb75SMartin Matuska testprog));
13852c2bb75SMartin Matuska assertChdir("novcs-exclude");
13952c2bb75SMartin Matuska assertFileExists("file");
14052c2bb75SMartin Matuska assertIsDir("dir", 0755);
14152c2bb75SMartin Matuska assertFileNotExists("CVS");
14252c2bb75SMartin Matuska assertFileNotExists("CVS/fileattr");
14352c2bb75SMartin Matuska assertFileNotExists(".cvsignore");
14452c2bb75SMartin Matuska assertFileNotExists("RCS");
14552c2bb75SMartin Matuska assertFileNotExists("RCS/somefile");
14652c2bb75SMartin Matuska assertFileNotExists("SCCS");
14752c2bb75SMartin Matuska assertFileNotExists("SCCS/somefile");
14852c2bb75SMartin Matuska assertFileNotExists(".svn");
14952c2bb75SMartin Matuska assertFileNotExists(".svn/format");
15052c2bb75SMartin Matuska assertFileNotExists(".git");
15152c2bb75SMartin Matuska assertFileNotExists(".git/config");
15252c2bb75SMartin Matuska assertFileNotExists(".gitignore");
15352c2bb75SMartin Matuska assertFileNotExists(".gitattributes");
15452c2bb75SMartin Matuska assertFileNotExists(".gitmodules");
15552c2bb75SMartin Matuska assertFileNotExists(".arch-ids");
15652c2bb75SMartin Matuska assertFileNotExists(".arch-ids/somefile");
15752c2bb75SMartin Matuska assertFileNotExists("{arch}");
15852c2bb75SMartin Matuska assertFileNotExists("{arch}/somefile");
15952c2bb75SMartin Matuska assertFileNotExists("=RELEASE-ID");
16052c2bb75SMartin Matuska assertFileNotExists("=meta-update");
16152c2bb75SMartin Matuska assertFileNotExists("=update");
16252c2bb75SMartin Matuska assertFileNotExists(".bzr");
16352c2bb75SMartin Matuska assertFileNotExists(".bzr/checkout");
16452c2bb75SMartin Matuska assertFileNotExists(".bzrignore");
16552c2bb75SMartin Matuska assertFileNotExists(".bzrtags");
16652c2bb75SMartin Matuska assertFileNotExists(".hg");
16752c2bb75SMartin Matuska assertFileNotExists(".hg/dirstate");
16852c2bb75SMartin Matuska assertFileNotExists(".hgignore");
16952c2bb75SMartin Matuska assertFileNotExists(".hgtags");
17052c2bb75SMartin Matuska assertFileNotExists("_darcs");
17152c2bb75SMartin Matuska assertFileNotExists("_darcs/format");
17252c2bb75SMartin Matuska assertChdir("..");
17352c2bb75SMartin Matuska
17452c2bb75SMartin Matuska /* No flags, archive without vcs files */
17552c2bb75SMartin Matuska assertMakeDir("novcs-noexclude", 0755);
17652c2bb75SMartin Matuska assertEqualInt(0,
17752c2bb75SMartin Matuska systemf("%s -x -C novcs-noexclude -f excluded.tar", testprog));
17852c2bb75SMartin Matuska assertChdir("novcs-noexclude");
17952c2bb75SMartin Matuska assertFileExists("file");
18052c2bb75SMartin Matuska assertIsDir("dir", 0755);
18152c2bb75SMartin Matuska assertFileNotExists("CVS");
18252c2bb75SMartin Matuska assertFileNotExists("CVS/fileattr");
18352c2bb75SMartin Matuska assertFileNotExists(".cvsignore");
18452c2bb75SMartin Matuska assertFileNotExists("RCS");
18552c2bb75SMartin Matuska assertFileNotExists("RCS/somefile");
18652c2bb75SMartin Matuska assertFileNotExists("SCCS");
18752c2bb75SMartin Matuska assertFileNotExists("SCCS/somefile");
18852c2bb75SMartin Matuska assertFileNotExists(".svn");
18952c2bb75SMartin Matuska assertFileNotExists(".svn/format");
19052c2bb75SMartin Matuska assertFileNotExists(".git");
19152c2bb75SMartin Matuska assertFileNotExists(".git/config");
19252c2bb75SMartin Matuska assertFileNotExists(".gitignore");
19352c2bb75SMartin Matuska assertFileNotExists(".gitattributes");
19452c2bb75SMartin Matuska assertFileNotExists(".gitmodules");
19552c2bb75SMartin Matuska assertFileNotExists(".arch-ids");
19652c2bb75SMartin Matuska assertFileNotExists(".arch-ids/somefile");
19752c2bb75SMartin Matuska assertFileNotExists("{arch}");
19852c2bb75SMartin Matuska assertFileNotExists("{arch}/somefile");
19952c2bb75SMartin Matuska assertFileNotExists("=RELEASE-ID");
20052c2bb75SMartin Matuska assertFileNotExists("=meta-update");
20152c2bb75SMartin Matuska assertFileNotExists("=update");
20252c2bb75SMartin Matuska assertFileNotExists(".bzr");
20352c2bb75SMartin Matuska assertFileNotExists(".bzr/checkout");
20452c2bb75SMartin Matuska assertFileNotExists(".bzrignore");
20552c2bb75SMartin Matuska assertFileNotExists(".bzrtags");
20652c2bb75SMartin Matuska assertFileNotExists(".hg");
20752c2bb75SMartin Matuska assertFileNotExists(".hg/dirstate");
20852c2bb75SMartin Matuska assertFileNotExists(".hgignore");
20952c2bb75SMartin Matuska assertFileNotExists(".hgtags");
21052c2bb75SMartin Matuska assertFileNotExists("_darcs");
21152c2bb75SMartin Matuska assertFileNotExists("_darcs/format");
21252c2bb75SMartin Matuska }
213