From d796cedbe8ca77310a7dabcafe60b040aa0e2b67 Mon Sep 17 00:00:00 2001 From: Ævar Arnfjörð Bjarmason Date: Wed, 12 Oct 2022 12:52:32 +0000 Subject: bundle-uri: unit test "key=value" parsing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create a new 'test-tool bundle-uri' test helper. This helper will assist in testing logic deep in the bundle URI feature. This change introduces the 'parse-key-values' subcommand, which parses an input file as a list of lines. These are fed into bundle_uri_parse_line() to test how we construct a 'struct bundle_list' from that data. The list is then output to stdout as if the key-value pairs were a Git config file. We use an input file instead of stdin because of a future change to parse in config-file format that works better as an input file. Co-authored-by: Derrick Stolee Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- t/test-lib-functions.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 't/test-lib-functions.sh') diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index c6479f24eb..5d2f20983b 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1868,3 +1868,14 @@ test_is_magic_mtime () { rm -f .git/test-mtime-actual return $ret } + +# Given two filenames, parse both using 'git config --list --file' +# and compare the sorted output of those commands. Useful when +# wanting to ignore whitespace differences and sorting concerns. +test_cmp_config_output () { + git config --list --file="$1" >config-expect && + git config --list --file="$2" >config-actual && + sort config-expect >sorted-expect && + sort config-actual >sorted-actual && + test_cmp sorted-expect sorted-actual +} -- cgit v1.3-5-g9baa