Test: Update selectively commenting test to include C-style comments
This commit is contained in:
+320
-49
@@ -4,8 +4,10 @@
|
|||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cstdio> // stderr
|
#include <cstddef> // size_t
|
||||||
#include <filesystem>
|
#include <cstdint> // uint32_t
|
||||||
|
#include <cstdio> // stderr
|
||||||
|
#include <filesystem> // path
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unistd.h> // geteuid, setegid, seteuid
|
#include <unistd.h> // geteuid, setegid, seteuid
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -226,15 +228,10 @@ TEST_CASE(PushDotfilesWithExcludePath)
|
|||||||
|
|
||||||
TEST_CASE(PushDotfilesSelectivelyComment)
|
TEST_CASE(PushDotfilesSelectivelyComment)
|
||||||
{
|
{
|
||||||
std::vector<std::string> fileNames = {
|
std::vector<std::string> fileNames;
|
||||||
"__test-file-1",
|
for (size_t i = 0; i < 36; ++i) {
|
||||||
"__test-file-2",
|
fileNames.push_back( "__test-file-" + std::to_string(i + 1));
|
||||||
"__test-file-3",
|
}
|
||||||
"__test-file-4",
|
|
||||||
"__test-file-5",
|
|
||||||
"__test-file-6",
|
|
||||||
"__test-file-7",
|
|
||||||
};
|
|
||||||
|
|
||||||
auto distro = Machine::the().distroId();
|
auto distro = Machine::the().distroId();
|
||||||
auto hostname = Machine::the().hostname();
|
auto hostname = Machine::the().hostname();
|
||||||
@@ -242,65 +239,339 @@ TEST_CASE(PushDotfilesSelectivelyComment)
|
|||||||
std::string placeholder = "@@@@";
|
std::string placeholder = "@@@@";
|
||||||
|
|
||||||
std::vector<std::string> fileContents = {
|
std::vector<std::string> fileContents = {
|
||||||
|
// Untouched #
|
||||||
"# >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
"# >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
# this should be uncommented
|
test data # untouched
|
||||||
# <<<
|
# <<<
|
||||||
)",
|
)",
|
||||||
"# >>> distro=" + placeholder + " hostname=" + hostname + " user=" + username + R"(
|
" # >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
# this should remain commented
|
test data # untouched
|
||||||
# <<<
|
|
||||||
)",
|
|
||||||
"# >>> distro=" + distro + " hostname=" + placeholder + " user=" + username + R"(
|
|
||||||
# this should remain commented
|
|
||||||
# <<<
|
|
||||||
)",
|
|
||||||
"# >>> distro=" + distro + " hostname=" + hostname + " user=" + placeholder + R"(
|
|
||||||
this should be commented
|
|
||||||
# <<<
|
|
||||||
)",
|
|
||||||
" # >>> distro=" + distro + R"(
|
|
||||||
# this should be uncommented
|
|
||||||
# <<<
|
# <<<
|
||||||
)",
|
)",
|
||||||
" # >>> user=" + username + R"(
|
" # >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
# this should be uncommented
|
test data # untouched
|
||||||
# <<<
|
# <<<
|
||||||
)",
|
)",
|
||||||
" # >>> hostname=" + hostname + R"(
|
" # >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
this should remain uncommented
|
test data # untouched
|
||||||
# <<<
|
# <<<
|
||||||
)",
|
)",
|
||||||
|
|
||||||
|
// Comment #
|
||||||
|
"# >>> distro=" + placeholder + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data # comment
|
||||||
|
# <<<
|
||||||
|
)",
|
||||||
|
" # >>> distro=" + distro + " hostname=" + placeholder + " user=" + username + R"(
|
||||||
|
test data # comment
|
||||||
|
# <<<
|
||||||
|
)",
|
||||||
|
" # >>> distro=" + distro + " hostname=" + hostname + " user=" + placeholder + R"(
|
||||||
|
test data # comment
|
||||||
|
# <<<
|
||||||
|
)",
|
||||||
|
" # >>> distro=" + placeholder + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data # comment
|
||||||
|
# <<<
|
||||||
|
)",
|
||||||
|
|
||||||
|
// Uncomment #
|
||||||
|
"# >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
# test data # uncomment
|
||||||
|
# <<<
|
||||||
|
)",
|
||||||
|
" # >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
# test data # uncomment
|
||||||
|
# <<<
|
||||||
|
)",
|
||||||
|
" # >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
# test data # uncomment
|
||||||
|
# <<<
|
||||||
|
)",
|
||||||
|
" # >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
# test data # uncomment
|
||||||
|
# <<<
|
||||||
|
)",
|
||||||
|
|
||||||
|
// -----------------------------------------
|
||||||
|
|
||||||
|
// Untouched //
|
||||||
|
"// >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data // untouched
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
" // >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data // untouched
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
" // >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data // untouched
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
" // >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data // untouched
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
|
||||||
|
// Comment //
|
||||||
|
"// >>> distro=" + placeholder + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data // comment
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
" // >>> distro=" + distro + " hostname=" + placeholder + " user=" + username + R"(
|
||||||
|
test data // comment
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
" // >>> distro=" + distro + " hostname=" + hostname + " user=" + placeholder + R"(
|
||||||
|
test data // comment
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
" // >>> distro=" + placeholder + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data // comment
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
|
||||||
|
// Uncomment //
|
||||||
|
"// >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
// test data // uncomment
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
" // >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
// test data // uncomment
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
" // >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
// test data // uncomment
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
" // >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
// test data // uncomment
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
|
||||||
|
// -----------------------------------------
|
||||||
|
|
||||||
|
// Untouched /**/
|
||||||
|
"/* >>> distro=" + distro + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
test data /**/ untouched
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
" /* >>> distro=" + distro + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
test data /**/ untouched
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
" /* >>> distro=" + distro + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
test data /**/ untouched
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
" /* >>> distro=" + distro + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
test data /**/ untouched
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
|
||||||
|
// Comment /**/
|
||||||
|
"/* >>> distro=" + placeholder + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
test data /**/ comment
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
" /* >>> distro=" + distro + " hostname=" + placeholder + " user=" + username + " */" + R"(
|
||||||
|
test data /**/ comment
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
" /* >>> distro=" + distro + " hostname=" + hostname + " user=" + placeholder + " */" + R"(
|
||||||
|
test data /**/ comment
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
" /* >>> distro=" + placeholder + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
test data /**/ comment
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
|
||||||
|
// Uncomment /**/
|
||||||
|
"/* >>> distro=" + distro + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
/* test data /**/ uncomment */
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
" /* >>> distro=" + distro + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
/* test data /**/ uncomment */
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
" /* >>> distro=" + distro + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
/* test data /**/ uncomment */
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
" /* >>> distro=" + distro + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
/* test data /**/ uncomment */
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<std::string> pushedFileContents = {
|
std::vector<std::string> pushedFileContents = {
|
||||||
|
// Untouched #
|
||||||
"# >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
"# >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
this should be uncommented
|
test data # untouched
|
||||||
# <<<
|
# <<<
|
||||||
)",
|
)",
|
||||||
"# >>> distro=" + placeholder + " hostname=" + hostname + " user=" + username + R"(
|
" # >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
# this should remain commented
|
test data # untouched
|
||||||
# <<<
|
|
||||||
)",
|
|
||||||
"# >>> distro=" + distro + " hostname=" + placeholder + " user=" + username + R"(
|
|
||||||
# this should remain commented
|
|
||||||
# <<<
|
|
||||||
)",
|
|
||||||
"# >>> distro=" + distro + " hostname=" + hostname + " user=" + placeholder + R"(
|
|
||||||
# this should be commented
|
|
||||||
# <<<
|
|
||||||
)",
|
|
||||||
" # >>> distro=" + distro + R"(
|
|
||||||
this should be uncommented
|
|
||||||
# <<<
|
# <<<
|
||||||
)",
|
)",
|
||||||
" # >>> user=" + username + R"(
|
" # >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
this should be uncommented
|
test data # untouched
|
||||||
# <<<
|
# <<<
|
||||||
)",
|
)",
|
||||||
" # >>> hostname=" + hostname + R"(
|
" # >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
this should remain uncommented
|
test data # untouched
|
||||||
# <<<
|
# <<<
|
||||||
)",
|
)",
|
||||||
|
|
||||||
|
// Comment #
|
||||||
|
"# >>> distro=" + placeholder + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
# test data # comment
|
||||||
|
# <<<
|
||||||
|
)",
|
||||||
|
" # >>> distro=" + distro + " hostname=" + placeholder + " user=" + username + R"(
|
||||||
|
# test data # comment
|
||||||
|
# <<<
|
||||||
|
)",
|
||||||
|
" # >>> distro=" + distro + " hostname=" + hostname + " user=" + placeholder + R"(
|
||||||
|
# test data # comment
|
||||||
|
# <<<
|
||||||
|
)",
|
||||||
|
" # >>> distro=" + placeholder + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
# test data # comment
|
||||||
|
# <<<
|
||||||
|
)",
|
||||||
|
|
||||||
|
// Uncomment #
|
||||||
|
"# >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data # uncomment
|
||||||
|
# <<<
|
||||||
|
)",
|
||||||
|
" # >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data # uncomment
|
||||||
|
# <<<
|
||||||
|
)",
|
||||||
|
" # >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data # uncomment
|
||||||
|
# <<<
|
||||||
|
)",
|
||||||
|
" # >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data # uncomment
|
||||||
|
# <<<
|
||||||
|
)",
|
||||||
|
|
||||||
|
// -----------------------------------------
|
||||||
|
|
||||||
|
// Untouched //
|
||||||
|
"// >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data // untouched
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
" // >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data // untouched
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
" // >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data // untouched
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
" // >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data // untouched
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
|
||||||
|
// Comment //
|
||||||
|
"// >>> distro=" + placeholder + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
// test data // comment
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
" // >>> distro=" + distro + " hostname=" + placeholder + " user=" + username + R"(
|
||||||
|
// test data // comment
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
" // >>> distro=" + distro + " hostname=" + hostname + " user=" + placeholder + R"(
|
||||||
|
// test data // comment
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
" // >>> distro=" + placeholder + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
// test data // comment
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
|
||||||
|
// Uncomment //
|
||||||
|
"// >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data // uncomment
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
" // >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data // uncomment
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
" // >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data // uncomment
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
" // >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
|
||||||
|
test data // uncomment
|
||||||
|
// <<<
|
||||||
|
)",
|
||||||
|
|
||||||
|
// -----------------------------------------
|
||||||
|
|
||||||
|
// Untouched /**/
|
||||||
|
"/* >>> distro=" + distro + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
test data /**/ untouched
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
" /* >>> distro=" + distro + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
test data /**/ untouched
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
" /* >>> distro=" + distro + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
test data /**/ untouched
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
" /* >>> distro=" + distro + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
test data /**/ untouched
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
|
||||||
|
// Comment /**/
|
||||||
|
"/* >>> distro=" + placeholder + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
/* test data /**/ comment */
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
" /* >>> distro=" + distro + " hostname=" + placeholder + " user=" + username + " */" + R"(
|
||||||
|
/* test data /**/ comment */
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
" /* >>> distro=" + distro + " hostname=" + hostname + " user=" + placeholder + " */" + R"(
|
||||||
|
/* test data /**/ comment */
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
" /* >>> distro=" + placeholder + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
/* test data /**/ comment */
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
|
||||||
|
// Uncomment /**/
|
||||||
|
"/* >>> distro=" + distro + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
test data /**/ uncomment
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
" /* >>> distro=" + distro + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
test data /**/ uncomment
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
" /* >>> distro=" + distro + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
test data /**/ uncomment
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
|
" /* >>> distro=" + distro + " hostname=" + hostname + " user=" + username + " */" + R"(
|
||||||
|
test data /**/ uncomment
|
||||||
|
/* <<< */
|
||||||
|
)",
|
||||||
};
|
};
|
||||||
|
|
||||||
createTestDotfiles(fileNames, fileContents);
|
createTestDotfiles(fileNames, fileContents);
|
||||||
|
|||||||
Reference in New Issue
Block a user