On Wed, 30 May 2012, Tomi Ollila <tomi.ollila@iki.fi> wrote: > On Wed, May 30 2012, Jameson Graef Rollins <jrollins@finestructure.net> wrote: > >> On Wed, May 30 2012, Mike Kelly <pioto@pioto.org> wrote: >>> FreeBSD's `wc -l` includes some white space in front of the number. >>> Instead, we add a test_expect_equal_num() to test-lib.sh, which ensures >>> we do a proper numeric comparision, and in a portable way. >> >> Is there a way we can avoid adding another new test function here? This >> new function is almost completely identical with the old one, except >> that it uses "test .. -eq" instead of "[ .. =". If the problem is just >> that the arguments occasionally contain superfluous spaces, I would >> rather see the existing function just strip the spaces. Of maybe add an >> option to the test to ask for arithmetic rather than string comparison. >> That would be preferable to introducing an new function that is >> confusingly similar to an existing one. > > I liked Mike's suggestion as I also thought the options; stripping in > test_expect_equal cannot be done as there might be whitespace differences > which mean failure arguments to test_expect_equal cannot be given without > quotes as variable might be split into multiple args. if test_expect_equal > were changed to take comparison argument (like '-eq' or '=') then all > calls would need to be changes (and function name could be changed to > something more generic...) None of these sounded as good options... > > But, there is at least one option more: > > test_expect_equal \ > - "`notmuch search --output=messages ${SEARCH} | wc -l`" \ > + "$((`notmuch search --output=messages ${SEARCH} | wc -l`))" \ > "`notmuch count --output=messages ${SEARCH}`" > > this makes arithmetic evaluation -- no operation to be done but > the spaces around the value are dropped. But it's non-obvious. How about just adding '| tr -d " "' to the end and be done with it? J. > >> >> jamie. > > Tomi > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch