Test: Update selectively commenting test to include C-style comments

This commit is contained in:
Riyyi
2022-02-11 21:48:21 +01:00
parent 8ccdd907fc
commit 59fe52202b
+301 -30
View File
@@ -4,8 +4,10 @@
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
#include <cstddef> // size_t
#include <cstdint> // uint32_t
#include <cstdio> // stderr #include <cstdio> // stderr
#include <filesystem> #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,64 +239,338 @@ 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=" + 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"( "# >>> distro=" + placeholder + " hostname=" + hostname + " user=" + username + R"(
# this should remain commented test data # comment
# <<< # <<<
)", )",
" # >>> distro=" + distro + " hostname=" + placeholder + " user=" + username + R"( " # >>> distro=" + distro + " hostname=" + placeholder + " user=" + username + R"(
# this should remain commented test data # comment
# <<< # <<<
)", )",
" # >>> distro=" + distro + " hostname=" + hostname + " user=" + placeholder + R"( " # >>> distro=" + distro + " hostname=" + hostname + " user=" + placeholder + R"(
this should be commented test data # comment
# <<< # <<<
)", )",
" # >>> distro=" + distro + R"( " # >>> distro=" + placeholder + " hostname=" + hostname + " user=" + username + R"(
# this should be uncommented test data # comment
# <<< # <<<
)", )",
" # >>> user=" + username + R"(
# this should be uncommented // Uncomment #
"# >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
# test data # uncomment
# <<< # <<<
)", )",
" # >>> hostname=" + hostname + R"( " # >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
this should remain uncommented # 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=" + 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"( "# >>> distro=" + placeholder + " hostname=" + hostname + " user=" + username + R"(
# this should remain commented # test data # comment
# <<< # <<<
)", )",
" # >>> distro=" + distro + " hostname=" + placeholder + " user=" + username + R"( " # >>> distro=" + distro + " hostname=" + placeholder + " user=" + username + R"(
# this should remain commented # test data # comment
# <<< # <<<
)", )",
" # >>> distro=" + distro + " hostname=" + hostname + " user=" + placeholder + R"( " # >>> distro=" + distro + " hostname=" + hostname + " user=" + placeholder + R"(
# this should be commented # test data # comment
# <<< # <<<
)", )",
" # >>> distro=" + distro + R"( " # >>> distro=" + placeholder + " hostname=" + hostname + " user=" + username + R"(
this should be uncommented # test data # comment
# <<< # <<<
)", )",
" # >>> user=" + username + R"(
this should be uncommented // Uncomment #
"# >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
test data # uncomment
# <<< # <<<
)", )",
" # >>> hostname=" + hostname + R"( " # >>> distro=" + distro + " hostname=" + hostname + " user=" + username + R"(
this should remain uncommented 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
/* <<< */
)", )",
}; };