From c2428a4e3bdafaba9a8a40cdedbb6d3391d7f258 Mon Sep 17 00:00:00 2001 From: Mike Kelly Date: Thu, 31 May 2012 03:02:02 +2000 Subject: [PATCH] [PATCH v2 7/9] test/count: fix numeric comparision tests on FreeBSD --- e3/5e738c08e6206f5d15170993d493e796089173 | 142 ++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 e3/5e738c08e6206f5d15170993d493e796089173 diff --git a/e3/5e738c08e6206f5d15170993d493e796089173 b/e3/5e738c08e6206f5d15170993d493e796089173 new file mode 100644 index 000000000..deb5e95c1 --- /dev/null +++ b/e3/5e738c08e6206f5d15170993d493e796089173 @@ -0,0 +1,142 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id A217E431FD2 + for ; Wed, 30 May 2012 00:02:58 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 9bO3j2l6BRok for ; + Wed, 30 May 2012 00:02:57 -0700 (PDT) +Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com + [209.85.220.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id F3C43431FAF + for ; Wed, 30 May 2012 00:02:55 -0700 (PDT) +Received: by mail-vc0-f181.google.com with SMTP id f1so4187995vcb.26 + for ; Wed, 30 May 2012 00:02:55 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=google.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references + :x-gm-message-state; + bh=p6l7vxdTZnwwRJ6TCqtNq8A8oPuCnSvrVnR/UcLpeGg=; + b=gLaWg9Sle+lK/ESBPijfXa+fPfzhFB5Plyp0vFW2JIsR9DctwLu2c1pe8yO7kZQSud + ShOvZoGYlyWYdHQAtu8n2yZ7SyYSnGO+W3kZ4dsoj4nPFDbH5UVlf++0YRDCDuMTa4xk + k66A/g65GPfk1Q4Uvls7xMkCyFPwOijlZ1PWE8YipPmMFTMZRMRVzvZMaXzVIBq846rC + DXp651shmEKbtWOOySZsfe0zkzzqt+h4vpmEjBekC5RjgT7ZfrQBaP4qxuPhiFvYIzKh + 7qdCrn9iF8lA6DYEPV4FyFaslFJB7bCf6aI5iiW562aLDAQWIGyCZcJ9q0vzOBpNjmUR + WSHQ== +Received: by 10.52.90.199 with SMTP id by7mr13350786vdb.30.1338361375638; + Wed, 30 May 2012 00:02:55 -0700 (PDT) +Received: from nas.home.pioto.org (pool-71-182-155-97.pitbpa.fios.verizon.net. + [71.182.155.97]) + by mx.google.com with ESMTPS id d20sm28307480vde.20.2012.05.30.00.02.54 + (version=TLSv1/SSLv3 cipher=OTHER); + Wed, 30 May 2012 00:02:55 -0700 (PDT) +Received: by nas.home.pioto.org (Postfix, from userid 1001) + id 086F8287DC; Wed, 30 May 2012 03:02:53 -0400 (EDT) +From: Mike Kelly +To: notmuch@notmuchmail.org +Subject: [PATCH v2 7/9] test/count: fix numeric comparision tests on FreeBSD +Date: Wed, 30 May 2012 03:02:02 -0400 +Message-Id: <1338361324-57289-8-git-send-email-pioto@pioto.org> +X-Mailer: git-send-email 1.7.10.2 +In-Reply-To: <1338361324-57289-1-git-send-email-pioto@pioto.org> +References: <1338361324-57289-1-git-send-email-pioto@pioto.org> +X-Gm-Message-State: + ALoCoQkXkPhyqBsZjex6ilBNRQykMsV/8h+cHpY3cACUC/1zxaQL6iKuPLkLKpYNFDJVFigN/8q0 +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Wed, 30 May 2012 07:02:59 -0000 + +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. +--- + test/count | 8 ++++---- + test/test-lib.sh | 22 ++++++++++++++++++++++ + 2 files changed, 26 insertions(+), 4 deletions(-) + +diff --git a/test/count b/test/count +index 300b171..902c7c6 100755 +--- a/test/count ++++ b/test/count +@@ -7,22 +7,22 @@ add_email_corpus + SEARCH="\"*\"" + + test_begin_subtest "message count is the default for notmuch count" +-test_expect_equal \ ++test_expect_equal_num \ + "`notmuch search --output=messages ${SEARCH} | wc -l`" \ + "`notmuch count ${SEARCH}`" + + test_begin_subtest "message count with --output=messages" +-test_expect_equal \ ++test_expect_equal_num \ + "`notmuch search --output=messages ${SEARCH} | wc -l`" \ + "`notmuch count --output=messages ${SEARCH}`" + + test_begin_subtest "thread count with --output=threads" +-test_expect_equal \ ++test_expect_equal_num \ + "`notmuch search --output=threads ${SEARCH} | wc -l`" \ + "`notmuch count --output=threads ${SEARCH}`" + + test_begin_subtest "thread count is the default for notmuch search" +-test_expect_equal \ ++test_expect_equal_num \ + "`notmuch search ${SEARCH} | wc -l`" \ + "`notmuch count --output=threads ${SEARCH}`" + +diff --git a/test/test-lib.sh b/test/test-lib.sh +index da792b7..2ac92f7 100644 +--- a/test/test-lib.sh ++++ b/test/test-lib.sh +@@ -512,6 +512,28 @@ test_expect_equal_file () + fi + } + ++# Like test_expect_equal, but does a numeric comparision instead of a ++# string comparision ++test_expect_equal_num () { ++ exec 1>&6 2>&7 # Restore stdout and stderr ++ inside_subtest= ++ test "$#" = 3 && { prereq=$1; shift; } || prereq= ++ test "$#" = 2 || ++ error "bug in the test script: not 2 or 3 parameters to test_expect_equal" ++ ++ output="$1" ++ expected="$2" ++ if ! test_skip "$test_subtest_name" ++ then ++ if test "$output" -eq "$expected" ++ then ++ test_ok_ "$test_subtest_name" ++ else ++ test_failure_ "$test_subtest_name" "$output != $expected" ++ fi ++ fi ++} ++ + test_emacs_expect_t () { + test "$#" = 2 && { prereq=$1; shift; } || prereq= + test "$#" = 1 || +-- +1.7.10.2 + -- 2.26.2