[notmuch] [PATCH 2/3] Update test framework for use with notmuch

2010-02-08 Thread Michal Sojka
This removes Git specific things from the test-lib.sh and adds helper
functions for notmuch taken from Carl's notmuch-test script. README is
also slightly modified to reflect the current state.

Signed-off-by: Michal Sojka 
---
 test/Makefile   |1 +
 test/README |   12 +-
 test/t-basic.sh |  332 +++
 test/test-lib.sh|  320 +++--
 4 files changed, 204 insertions(+), 461 deletions(-)
 mode change 100644 => 100755 test/test-lib.sh

diff --git a/test/Makefile b/test/Makefile
index bd09390..e07c7fd 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -6,6 +6,7 @@
 -include ../config.mak

 #GIT_TEST_OPTS=--verbose --debug
+SHELL=/bin/bash
 SHELL_PATH ?= $(SHELL)
 TAR ?= $(TAR)
 RM ?= rm -f
diff --git a/test/README b/test/README
index dcd3ebb..0f5bddb 100644
--- a/test/README
+++ b/test/README
@@ -165,10 +165,10 @@ Writing Tests
 -

 The test script is written as a shell script.  It should start
-with the standard "#!/bin/sh" with copyright notices, and an
+with the standard "#!/bin/bash" with copyright notices, and an
 assignment to variable 'test_description', like this:

-   #!/bin/sh
+   #!/bin/bash
#
# Copyright (c) 2005 Junio C Hamano
#
@@ -192,9 +192,11 @@ This test harness library does the following things:
  - If the script is invoked with command line argument --help
(or -h), it shows the test_description and exits.

- - Creates an empty test directory with an empty .git/objects
-   database and chdir(2) into it.  This directory is 't/trash directory'
-   if you must know, but I do not think you care.
+ - Creates a test directory with default notmuch-config and empty mail
+   store. This directory is 't/trash directory.' (note
+   the space) if you must know, but I do not think you care. The path
+   to notmuch-config is exported in NOTMUCH_CONFIG environment
+   variable and mail store path is stored in MAIL_DIR variabl.

  - Defines standard test helper functions for your scripts to
use.  These functions are designed to make all scripts behave
diff --git a/test/t-basic.sh b/test/t-basic.sh
index f4ca4fc..cc2ca21 100755
--- a/test/t-basic.sh
+++ b/test/t-basic.sh
@@ -5,46 +5,39 @@

 test_description='Test the very basics part #1.

-The rest of the test suite does not check the basic operation of git
-plumbing commands to work very carefully.  Their job is to concentrate
-on tricky features that caused bugs in the past to detect regression.
-
-This test runs very basic features, like registering things in cache,
-writing tree, etc.
-
-Note that this test *deliberately* hard-codes many expected object
-IDs.  When object ID computation changes, like in the previous case of
-swapping compression and hashing order, the person who is making the
-modification *should* take notice and update the test vectors here.
+Tests the test framework itself.
 '
-
 
 # It appears that people try to run tests without building...

-../git >/dev/null
-if test $? != 1
+if ! test -x ../notmuch
 then
-   echo >&2 'You do not seem to have built git yet.'
+   echo >&2 'You do not seem to have built notmuch yet.'
exit 1
 fi

 . ./test-lib.sh

 
-# git init has been done in an empty repository.
-# make sure it is empty.
+# Test mail store prepared in test-lib.sh
+
+test_expect_success \
+'test that mail store was created' \
+'test -d "${MAIL_DIR}"'
+

-find .git/objects -type f -print >should-be-empty
+find "${MAIL_DIR}" -type f -print >should-be-empty
 test_expect_success \
-'.git/objects should be empty after git init in an empty repo.' \
+'mail store should be empty' \
 'cmp -s /dev/null should-be-empty'

-# also it should have 2 subdirectories; no fan-out anymore, pack, and info.
-# 3 is counting "objects" itself
-find .git/objects -type d -print >full-of-directories
 test_expect_success \
-'.git/objects should have 3 subdirectories.' \
-'test $(wc -l < full-of-directories) = 3'
+'NOTMUCH_CONFIG is set and points to an existing file' \
+'test -f "${NOTMUCH_CONFIG}"'
+
+test_expect_success \
+'PATH is set to this repository' \
+'test "`echo $PATH|cut -f1 -d:`" = "`dirname ${TEST_DIRECTORY}`"'

 
 # Test harness
@@ -73,296 +66,5 @@ then
exit 1
 fi

-
-# Basics of the basics
-
-# updating a new file without --add should fail.
-test_expect_success 'git update-index without --add should fail adding.' '
-test_must_fail git update-index should-be-empty
-'
-
-# and with --add it should succeed, even if it is empty (it used to fail).
-test_expect_success \
-'git update-index with --add should succeed.' \
-'git update-index --add 

[notmuch] [PATCH 2/3] Update test framework for use with notmuch

2010-02-08 Thread Michal Sojka
This removes Git specific things from the test-lib.sh and adds helper
functions for notmuch taken from Carl's notmuch-test script. README is
also slightly modified to reflect the current state.

Signed-off-by: Michal Sojka sojk...@fel.cvut.cz
---
 test/Makefile   |1 +
 test/README |   12 +-
 test/t-basic.sh |  332 +++
 test/test-lib.sh|  320 +++--
 4 files changed, 204 insertions(+), 461 deletions(-)
 mode change 100644 = 100755 test/test-lib.sh

diff --git a/test/Makefile b/test/Makefile
index bd09390..e07c7fd 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -6,6 +6,7 @@
 -include ../config.mak
 
 #GIT_TEST_OPTS=--verbose --debug
+SHELL=/bin/bash
 SHELL_PATH ?= $(SHELL)
 TAR ?= $(TAR)
 RM ?= rm -f
diff --git a/test/README b/test/README
index dcd3ebb..0f5bddb 100644
--- a/test/README
+++ b/test/README
@@ -165,10 +165,10 @@ Writing Tests
 -
 
 The test script is written as a shell script.  It should start
-with the standard #!/bin/sh with copyright notices, and an
+with the standard #!/bin/bash with copyright notices, and an
 assignment to variable 'test_description', like this:
 
-   #!/bin/sh
+   #!/bin/bash
#
# Copyright (c) 2005 Junio C Hamano
#
@@ -192,9 +192,11 @@ This test harness library does the following things:
  - If the script is invoked with command line argument --help
(or -h), it shows the test_description and exits.
 
- - Creates an empty test directory with an empty .git/objects
-   database and chdir(2) into it.  This directory is 't/trash directory'
-   if you must know, but I do not think you care.
+ - Creates a test directory with default notmuch-config and empty mail
+   store. This directory is 't/trash directory.test-basename' (note
+   the space) if you must know, but I do not think you care. The path
+   to notmuch-config is exported in NOTMUCH_CONFIG environment
+   variable and mail store path is stored in MAIL_DIR variabl.
 
  - Defines standard test helper functions for your scripts to
use.  These functions are designed to make all scripts behave
diff --git a/test/t-basic.sh b/test/t-basic.sh
index f4ca4fc..cc2ca21 100755
--- a/test/t-basic.sh
+++ b/test/t-basic.sh
@@ -5,46 +5,39 @@
 
 test_description='Test the very basics part #1.
 
-The rest of the test suite does not check the basic operation of git
-plumbing commands to work very carefully.  Their job is to concentrate
-on tricky features that caused bugs in the past to detect regression.
-
-This test runs very basic features, like registering things in cache,
-writing tree, etc.
-
-Note that this test *deliberately* hard-codes many expected object
-IDs.  When object ID computation changes, like in the previous case of
-swapping compression and hashing order, the person who is making the
-modification *should* take notice and update the test vectors here.
+Tests the test framework itself.
 '
-
 
 # It appears that people try to run tests without building...
 
-../git /dev/null
-if test $? != 1
+if ! test -x ../notmuch
 then
-   echo 2 'You do not seem to have built git yet.'
+   echo 2 'You do not seem to have built notmuch yet.'
exit 1
 fi
 
 . ./test-lib.sh
 
 
-# git init has been done in an empty repository.
-# make sure it is empty.
+# Test mail store prepared in test-lib.sh
+
+test_expect_success \
+'test that mail store was created' \
+'test -d ${MAIL_DIR}'
+
 
-find .git/objects -type f -print should-be-empty
+find ${MAIL_DIR} -type f -print should-be-empty
 test_expect_success \
-'.git/objects should be empty after git init in an empty repo.' \
+'mail store should be empty' \
 'cmp -s /dev/null should-be-empty'
 
-# also it should have 2 subdirectories; no fan-out anymore, pack, and info.
-# 3 is counting objects itself
-find .git/objects -type d -print full-of-directories
 test_expect_success \
-'.git/objects should have 3 subdirectories.' \
-'test $(wc -l  full-of-directories) = 3'
+'NOTMUCH_CONFIG is set and points to an existing file' \
+'test -f ${NOTMUCH_CONFIG}'
+
+test_expect_success \
+'PATH is set to this repository' \
+'test `echo $PATH|cut -f1 -d:` = `dirname ${TEST_DIRECTORY}`'
 
 
 # Test harness
@@ -73,296 +66,5 @@ then
exit 1
 fi
 
-
-# Basics of the basics
-
-# updating a new file without --add should fail.
-test_expect_success 'git update-index without --add should fail adding.' '
-test_must_fail git update-index should-be-empty
-'
-
-# and with --add it should succeed, even if it is empty (it used to fail).
-test_expect_success \
-'git update-index with --add should succeed.' \
-