From: Johannes Sixt Date: Sat, 21 Nov 2015 08:11:49 GMT Subject: Re: [PATCH 3/2] test: factor out helper function test_must_contain Message-ID: <56502745.2000307@kdbg.org> In-Reply-To: <564F8781.1080902@web.de> Am 20.11.2015 um 21:50 schrieb René Scharfe: > Extract a helper function for searching for a pattern in a file and > printing the whole file if the pattern is not found. It is useful > when starting tests with --verbose for debugging purposes. > +# Check if a file contains an expected pattern. > +test_must_contain () { > + if grep "$1" "$2" > + then > + return 0 > + else > + echo "didn't find /$1/ in '$2', it contains:" > + cat "$2" > + return 1 > + fi > +} There is already test_i18n_grep. Should it be folded into this function? Wouldn't we also want to have a function test_must_not_contain? IMHO, we should not increase the number of functions that give a bonus only when there is a test case failure. They do not scale well: There is a permanent mental burden on every reviewer to watch out that they are used in new tests. But without those functions, the burden is on the one person investigating a test case failure, who has to live without the debugging support. -- Hannes