From: Eric Sunshine Date: Wed, 02 Sep 2020 16:38:00 GMT Subject: Re: [PATCH v5 2/8] t1308-config-set: avoid false positives when using test-config Message-ID: In-Reply-To: On Wed, Sep 2, 2020 at 12:16 PM Matheus Tavares Bernardino wrote: > With that said, I'm wondering now whether we should change the > function's signature from: > > `check_config [expect_code ] ` > > to: > > `check_config ` > `check_config expect_not_found ` > > The second form would then automatically expect exit code 1 and check > stdout for the message 'Value not found for ""'. With this we > can avoid wrong uses of check_config to check an arbitrary error code > without also checking stderr. Yes, that seems more straightforward. In fact, at this point, you could just have two distinct functions and eliminate the ugly complexity of the existing check_config() implementation. Perhaps something like this (typed in email): check_config () { test_tool config "$1" "$2" >actual && shift && shift && printf "%s\n" "$@" >expect && test_cmp expect actual } check_not_found () { test_expect_code 1 test_tool config "$1" "$2" >actual && echo "Value not found for \"$2\"" >expect && test_cmp expect actual }