[PATCH] tests: fail sooner (and with a good explanation) without mongod

Jim Meyering jim at meyering.net
Thu Apr 21 19:49:13 UTC 2011


Pete Zaitcev wrote:
> On Thu, 21 Apr 2011 14:03:16 +0200
> Jim Meyering <jim at meyering.net> wrote:
>
>> Too often, people would try to run tests without first installing the
>> build-required mongodb-server package (i.e., mongod).  That led to a
>> test failure that is not obviously due to the lack of mongod.
>> With this change, the diagnostic makes it very clear:
>
>> +mongod --help || fail_ "mongod is not installed"
>
> Does the help end in the t/test-suite.log?

Not normally, but it will appear there if the t/basic test fails.
If you'd like to avoid that, we can redirect stdout to /dev/null:

    mongod --help > /dev/null || ...


Then I realized I should simply do it. ;-)
So did:

From 997465cfa8080f04bbe368549d9e11e83f23a1e5 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Thu, 21 Apr 2011 21:46:58 +0200
Subject: [PATCH] tests: redirect mongod --help's stdout to /dev/null

* t/basic: as above.  Suggestion from Pete Zaitcev.
---
 t/basic |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/t/basic b/t/basic
index 3e88db9..800c08d 100644
--- a/t/basic
+++ b/t/basic
@@ -17,7 +17,7 @@ mkdir FS mongod iwhd || framework_failure_ mkdir failed
 m_port=$(get_port $mongo_base_port $lock_dir/m-) \
   || fail_ "failed to get mongodb port"

-mongod --help || fail_ "the mongod program is not installed"
+mongod --help > /dev/null || fail_ "the mongod program is not installed"

 mongod --port $m_port --pidfilepath mongod/pid --dbpath mongod > mongod.log 2>&1 &
 mongo_pid=$!
--
1.7.5.rc3.291.g63e4e


More information about the iwhd-devel mailing list