From 947075ea7b15c365e7608b32ae5fbfbaba5f6228 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sat, 10 Feb 2024 23:59:37 +1300 Subject: [PATCH] LibDiff/Tests: Make verifying against stdout optional It's not always important to verify what the contents of stdout are when adding a patch test - especially if it's not exactly what we want it to be, so make this optional when running patch for a test. --- Tests/Utilities/TestPatch.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Tests/Utilities/TestPatch.cpp b/Tests/Utilities/TestPatch.cpp index e39c02f28f..ee5374b2e2 100644 --- a/Tests/Utilities/TestPatch.cpp +++ b/Tests/Utilities/TestPatch.cpp @@ -43,7 +43,7 @@ private: } }; -static void run_patch(Vector&& arguments, StringView standard_input, StringView expected_stdout) +static void run_patch(Vector&& arguments, StringView standard_input, Optional expected_stdout = {}) { // Ask patch to run the test in a temporary directory so we don't leave any files around. Vector args_with_chdir = { "patch", "-d", s_test_dir }; @@ -60,7 +60,9 @@ static void run_patch(Vector&& arguments, StringView standard_input if (status != Core::Command::ProcessResult::DoneWithZeroExitCode) { FAIL(MUST(String::formatted("patch didn't exit cleanly: status: {}, stdout:{}, stderr: {}", static_cast(status), StringView { stdout.bytes() }, StringView { stderr.bytes() }))); } - EXPECT_EQ(StringView { expected_stdout.bytes() }, StringView { stdout.bytes() }); + + if (expected_stdout.has_value()) + EXPECT_EQ(StringView { expected_stdout->bytes() }, StringView { stdout.bytes() }); } TEST_CASE(basic_change_patch)