Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add a test for a failure applying patch adding file #66

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions tests/test_applier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1138,3 +1138,44 @@ PATCH_TEST(applier_multi_line_addition_from_empty_file)
}
)");
}

PATCH_TEST(PATCH_XFAIL_applier_add_file_but_file_already_exits_with_conflicts)
{
{
Patch::File file("diff.patch", std::ios_base::out);
file << R"(
--- /dev/null 2023-10-31 17:55:44.017202200 +1300
+++ a 2023-11-11 20:05:33.898828568 +1300
@@ -0,0 +1,4 @@
+1
+2
+3
+4
)";
}

const std::string file_contents = R"(a
b
c
d
)";

{
Patch::File file("a", std::ios_base::out);
file << file_contents;
}

Process process(patch_path, { patch_path, "-f", "-i", "diff.patch", nullptr });

EXPECT_EQ(process.stdout_data(), R"(The next patch would create the file a,
which already exists! Applying it anyway.
patching file a
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file a.rej
)");

EXPECT_EQ(process.stderr_data(), "");
EXPECT_EQ(process.return_code(), 1);

EXPECT_FILE_EQ("a", file_contents);
}
Loading