[PATCH v2 06/13] test: make it possible to have several corpora

Jani Nikula jani at nikula.org
Sat Feb 22 14:25:37 PST 2014


Move the existing corpus under corpus/default, and make it possible to
have multiple corpora under the directory.
---
 test/.gitignore                     |  2 +-
 test/Makefile.local                 |  2 +-
 test/T480-hex-escaping.sh           |  4 ++--
 test/corpus/{ => default}/cur/01:2, |  0
 test/corpus/{ => default}/cur/02:2, |  0
 test/corpus/{ => default}/cur/03:2, |  0
 test/corpus/{ => default}/cur/04:2, |  0
 test/corpus/{ => default}/cur/05:2, |  0
 test/corpus/{ => default}/cur/06:2, |  0
 test/corpus/{ => default}/cur/07:2, |  0
 test/corpus/{ => default}/cur/08:2, |  0
 test/corpus/{ => default}/cur/09:2, |  0
 test/corpus/{ => default}/cur/10:2, |  0
 test/corpus/{ => default}/cur/11:2, |  0
 test/corpus/{ => default}/cur/12:2, |  0
 test/corpus/{ => default}/cur/13:2, |  0
 test/corpus/{ => default}/cur/14:2, |  0
 test/corpus/{ => default}/cur/15:2, |  0
 test/corpus/{ => default}/cur/16:2, |  0
 test/corpus/{ => default}/cur/17:2, |  0
 test/corpus/{ => default}/cur/18:2, |  0
 test/corpus/{ => default}/cur/19:2, |  0
 test/corpus/{ => default}/cur/20:2, |  0
 test/corpus/{ => default}/cur/21:2, |  0
 test/corpus/{ => default}/cur/22:2, |  0
 test/corpus/{ => default}/cur/23:2, |  0
 test/corpus/{ => default}/cur/24:2, |  0
 test/corpus/{ => default}/cur/25:2, |  0
 test/corpus/{ => default}/cur/26:2, |  0
 test/corpus/{ => default}/cur/27:2, |  0
 test/corpus/{ => default}/cur/28:2, |  0
 test/corpus/{ => default}/cur/29:2, |  0
 test/corpus/{ => default}/cur/30:2, |  0
 test/corpus/{ => default}/cur/31:2, |  0
 test/corpus/{ => default}/cur/32:2, |  0
 test/corpus/{ => default}/cur/33:2, |  0
 test/corpus/{ => default}/cur/34:2, |  0
 test/corpus/{ => default}/cur/35:2, |  0
 test/corpus/{ => default}/cur/36:2, |  0
 test/corpus/{ => default}/cur/37:2, |  0
 test/corpus/{ => default}/cur/38:2, |  0
 test/corpus/{ => default}/cur/39:2, |  0
 test/corpus/{ => default}/cur/40:2, |  0
 test/corpus/{ => default}/cur/41:2, |  0
 test/corpus/{ => default}/cur/42:2, |  0
 test/corpus/{ => default}/cur/43:2, |  0
 test/corpus/{ => default}/cur/44:2, |  0
 test/corpus/{ => default}/cur/45:2, |  0
 test/corpus/{ => default}/cur/46:2, |  0
 test/corpus/{ => default}/cur/47:2, |  0
 test/corpus/{ => default}/cur/48:2, |  0
 test/corpus/{ => default}/cur/49:2, |  0
 test/corpus/{ => default}/cur/50:2, |  0
 test/corpus/{ => default}/cur/51:2, |  0
 test/corpus/{ => default}/cur/52:2, |  0
 test/corpus/{ => default}/cur/53:2, |  0
 test/notmuch-test                   |  2 +-
 test/test-lib.sh                    | 21 +++++++++++++--------
 58 files changed, 18 insertions(+), 13 deletions(-)
 rename test/corpus/{ => default}/cur/01:2, (100%)
 rename test/corpus/{ => default}/cur/02:2, (100%)
 rename test/corpus/{ => default}/cur/03:2, (100%)
 rename test/corpus/{ => default}/cur/04:2, (100%)
 rename test/corpus/{ => default}/cur/05:2, (100%)
 rename test/corpus/{ => default}/cur/06:2, (100%)
 rename test/corpus/{ => default}/cur/07:2, (100%)
 rename test/corpus/{ => default}/cur/08:2, (100%)
 rename test/corpus/{ => default}/cur/09:2, (100%)
 rename test/corpus/{ => default}/cur/10:2, (100%)
 rename test/corpus/{ => default}/cur/11:2, (100%)
 rename test/corpus/{ => default}/cur/12:2, (100%)
 rename test/corpus/{ => default}/cur/13:2, (100%)
 rename test/corpus/{ => default}/cur/14:2, (100%)
 rename test/corpus/{ => default}/cur/15:2, (100%)
 rename test/corpus/{ => default}/cur/16:2, (100%)
 rename test/corpus/{ => default}/cur/17:2, (100%)
 rename test/corpus/{ => default}/cur/18:2, (100%)
 rename test/corpus/{ => default}/cur/19:2, (100%)
 rename test/corpus/{ => default}/cur/20:2, (100%)
 rename test/corpus/{ => default}/cur/21:2, (100%)
 rename test/corpus/{ => default}/cur/22:2, (100%)
 rename test/corpus/{ => default}/cur/23:2, (100%)
 rename test/corpus/{ => default}/cur/24:2, (100%)
 rename test/corpus/{ => default}/cur/25:2, (100%)
 rename test/corpus/{ => default}/cur/26:2, (100%)
 rename test/corpus/{ => default}/cur/27:2, (100%)
 rename test/corpus/{ => default}/cur/28:2, (100%)
 rename test/corpus/{ => default}/cur/29:2, (100%)
 rename test/corpus/{ => default}/cur/30:2, (100%)
 rename test/corpus/{ => default}/cur/31:2, (100%)
 rename test/corpus/{ => default}/cur/32:2, (100%)
 rename test/corpus/{ => default}/cur/33:2, (100%)
 rename test/corpus/{ => default}/cur/34:2, (100%)
 rename test/corpus/{ => default}/cur/35:2, (100%)
 rename test/corpus/{ => default}/cur/36:2, (100%)
 rename test/corpus/{ => default}/cur/37:2, (100%)
 rename test/corpus/{ => default}/cur/38:2, (100%)
 rename test/corpus/{ => default}/cur/39:2, (100%)
 rename test/corpus/{ => default}/cur/40:2, (100%)
 rename test/corpus/{ => default}/cur/41:2, (100%)
 rename test/corpus/{ => default}/cur/42:2, (100%)
 rename test/corpus/{ => default}/cur/43:2, (100%)
 rename test/corpus/{ => default}/cur/44:2, (100%)
 rename test/corpus/{ => default}/cur/45:2, (100%)
 rename test/corpus/{ => default}/cur/46:2, (100%)
 rename test/corpus/{ => default}/cur/47:2, (100%)
 rename test/corpus/{ => default}/cur/48:2, (100%)
 rename test/corpus/{ => default}/cur/49:2, (100%)
 rename test/corpus/{ => default}/cur/50:2, (100%)
 rename test/corpus/{ => default}/cur/51:2, (100%)
 rename test/corpus/{ => default}/cur/52:2, (100%)
 rename test/corpus/{ => default}/cur/53:2, (100%)

diff --git a/test/.gitignore b/test/.gitignore
index 97e024878728..ed20d1ac6e42 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -1,5 +1,5 @@
 test-results
-corpus.mail
+corpus.mail.*
 smtp-dummy
 symbol-test
 arg-test
diff --git a/test/Makefile.local b/test/Makefile.local
index 8870ca374848..20f17629dda3 100644
--- a/test/Makefile.local
+++ b/test/Makefile.local
@@ -57,4 +57,4 @@ CLEAN := $(CLEAN) $(dir)/smtp-dummy $(dir)/smtp-dummy.o \
 	 $(dir)/database-test.o \
 	 $(dir)/random-corpus $(dir)/random-corpus.o \
 	 $(dir)/parse-time $(dir)/parse-time.o \
-	 $(dir)/corpus.mail $(dir)/test-results $(dir)/tmp.*
+	 $(dir)/corpus.mail.* $(dir)/test-results $(dir)/tmp.*
diff --git a/test/T480-hex-escaping.sh b/test/T480-hex-escaping.sh
index ad50e1bcc071..15701650df83 100755
--- a/test/T480-hex-escaping.sh
+++ b/test/T480-hex-escaping.sh
@@ -3,7 +3,7 @@ test_description="hex encoding and decoding"
 . ./test-lib.sh
 
 test_begin_subtest "round trip"
-find $TEST_DIRECTORY/corpus -type f -print | sort | xargs cat > EXPECTED
+find $TEST_DIRECTORY/corpus/default -type f -print | sort | xargs cat > EXPECTED
 $TEST_DIRECTORY/hex-xcode --direction=encode < EXPECTED | $TEST_DIRECTORY/hex-xcode --direction=decode > OUTPUT
 test_expect_equal_file OUTPUT EXPECTED
 
@@ -25,7 +25,7 @@ $TEST_DIRECTORY/hex-xcode --direction=decode  < EXPECTED.$test_count |\
 test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count
 
 test_begin_subtest "round trip (in-place)"
-find $TEST_DIRECTORY/corpus -type f -print | sort | xargs cat > EXPECTED
+find $TEST_DIRECTORY/corpus/default -type f -print | sort | xargs cat > EXPECTED
 $TEST_DIRECTORY/hex-xcode --in-place --direction=encode < EXPECTED |\
      $TEST_DIRECTORY/hex-xcode --in-place --direction=decode > OUTPUT
 test_expect_equal_file OUTPUT EXPECTED
diff --git a/test/corpus/cur/01:2, b/test/corpus/default/cur/01:2,
similarity index 100%
rename from test/corpus/cur/01:2,
rename to test/corpus/default/cur/01:2,
diff --git a/test/corpus/cur/02:2, b/test/corpus/default/cur/02:2,
similarity index 100%
rename from test/corpus/cur/02:2,
rename to test/corpus/default/cur/02:2,
diff --git a/test/corpus/cur/03:2, b/test/corpus/default/cur/03:2,
similarity index 100%
rename from test/corpus/cur/03:2,
rename to test/corpus/default/cur/03:2,
diff --git a/test/corpus/cur/04:2, b/test/corpus/default/cur/04:2,
similarity index 100%
rename from test/corpus/cur/04:2,
rename to test/corpus/default/cur/04:2,
diff --git a/test/corpus/cur/05:2, b/test/corpus/default/cur/05:2,
similarity index 100%
rename from test/corpus/cur/05:2,
rename to test/corpus/default/cur/05:2,
diff --git a/test/corpus/cur/06:2, b/test/corpus/default/cur/06:2,
similarity index 100%
rename from test/corpus/cur/06:2,
rename to test/corpus/default/cur/06:2,
diff --git a/test/corpus/cur/07:2, b/test/corpus/default/cur/07:2,
similarity index 100%
rename from test/corpus/cur/07:2,
rename to test/corpus/default/cur/07:2,
diff --git a/test/corpus/cur/08:2, b/test/corpus/default/cur/08:2,
similarity index 100%
rename from test/corpus/cur/08:2,
rename to test/corpus/default/cur/08:2,
diff --git a/test/corpus/cur/09:2, b/test/corpus/default/cur/09:2,
similarity index 100%
rename from test/corpus/cur/09:2,
rename to test/corpus/default/cur/09:2,
diff --git a/test/corpus/cur/10:2, b/test/corpus/default/cur/10:2,
similarity index 100%
rename from test/corpus/cur/10:2,
rename to test/corpus/default/cur/10:2,
diff --git a/test/corpus/cur/11:2, b/test/corpus/default/cur/11:2,
similarity index 100%
rename from test/corpus/cur/11:2,
rename to test/corpus/default/cur/11:2,
diff --git a/test/corpus/cur/12:2, b/test/corpus/default/cur/12:2,
similarity index 100%
rename from test/corpus/cur/12:2,
rename to test/corpus/default/cur/12:2,
diff --git a/test/corpus/cur/13:2, b/test/corpus/default/cur/13:2,
similarity index 100%
rename from test/corpus/cur/13:2,
rename to test/corpus/default/cur/13:2,
diff --git a/test/corpus/cur/14:2, b/test/corpus/default/cur/14:2,
similarity index 100%
rename from test/corpus/cur/14:2,
rename to test/corpus/default/cur/14:2,
diff --git a/test/corpus/cur/15:2, b/test/corpus/default/cur/15:2,
similarity index 100%
rename from test/corpus/cur/15:2,
rename to test/corpus/default/cur/15:2,
diff --git a/test/corpus/cur/16:2, b/test/corpus/default/cur/16:2,
similarity index 100%
rename from test/corpus/cur/16:2,
rename to test/corpus/default/cur/16:2,
diff --git a/test/corpus/cur/17:2, b/test/corpus/default/cur/17:2,
similarity index 100%
rename from test/corpus/cur/17:2,
rename to test/corpus/default/cur/17:2,
diff --git a/test/corpus/cur/18:2, b/test/corpus/default/cur/18:2,
similarity index 100%
rename from test/corpus/cur/18:2,
rename to test/corpus/default/cur/18:2,
diff --git a/test/corpus/cur/19:2, b/test/corpus/default/cur/19:2,
similarity index 100%
rename from test/corpus/cur/19:2,
rename to test/corpus/default/cur/19:2,
diff --git a/test/corpus/cur/20:2, b/test/corpus/default/cur/20:2,
similarity index 100%
rename from test/corpus/cur/20:2,
rename to test/corpus/default/cur/20:2,
diff --git a/test/corpus/cur/21:2, b/test/corpus/default/cur/21:2,
similarity index 100%
rename from test/corpus/cur/21:2,
rename to test/corpus/default/cur/21:2,
diff --git a/test/corpus/cur/22:2, b/test/corpus/default/cur/22:2,
similarity index 100%
rename from test/corpus/cur/22:2,
rename to test/corpus/default/cur/22:2,
diff --git a/test/corpus/cur/23:2, b/test/corpus/default/cur/23:2,
similarity index 100%
rename from test/corpus/cur/23:2,
rename to test/corpus/default/cur/23:2,
diff --git a/test/corpus/cur/24:2, b/test/corpus/default/cur/24:2,
similarity index 100%
rename from test/corpus/cur/24:2,
rename to test/corpus/default/cur/24:2,
diff --git a/test/corpus/cur/25:2, b/test/corpus/default/cur/25:2,
similarity index 100%
rename from test/corpus/cur/25:2,
rename to test/corpus/default/cur/25:2,
diff --git a/test/corpus/cur/26:2, b/test/corpus/default/cur/26:2,
similarity index 100%
rename from test/corpus/cur/26:2,
rename to test/corpus/default/cur/26:2,
diff --git a/test/corpus/cur/27:2, b/test/corpus/default/cur/27:2,
similarity index 100%
rename from test/corpus/cur/27:2,
rename to test/corpus/default/cur/27:2,
diff --git a/test/corpus/cur/28:2, b/test/corpus/default/cur/28:2,
similarity index 100%
rename from test/corpus/cur/28:2,
rename to test/corpus/default/cur/28:2,
diff --git a/test/corpus/cur/29:2, b/test/corpus/default/cur/29:2,
similarity index 100%
rename from test/corpus/cur/29:2,
rename to test/corpus/default/cur/29:2,
diff --git a/test/corpus/cur/30:2, b/test/corpus/default/cur/30:2,
similarity index 100%
rename from test/corpus/cur/30:2,
rename to test/corpus/default/cur/30:2,
diff --git a/test/corpus/cur/31:2, b/test/corpus/default/cur/31:2,
similarity index 100%
rename from test/corpus/cur/31:2,
rename to test/corpus/default/cur/31:2,
diff --git a/test/corpus/cur/32:2, b/test/corpus/default/cur/32:2,
similarity index 100%
rename from test/corpus/cur/32:2,
rename to test/corpus/default/cur/32:2,
diff --git a/test/corpus/cur/33:2, b/test/corpus/default/cur/33:2,
similarity index 100%
rename from test/corpus/cur/33:2,
rename to test/corpus/default/cur/33:2,
diff --git a/test/corpus/cur/34:2, b/test/corpus/default/cur/34:2,
similarity index 100%
rename from test/corpus/cur/34:2,
rename to test/corpus/default/cur/34:2,
diff --git a/test/corpus/cur/35:2, b/test/corpus/default/cur/35:2,
similarity index 100%
rename from test/corpus/cur/35:2,
rename to test/corpus/default/cur/35:2,
diff --git a/test/corpus/cur/36:2, b/test/corpus/default/cur/36:2,
similarity index 100%
rename from test/corpus/cur/36:2,
rename to test/corpus/default/cur/36:2,
diff --git a/test/corpus/cur/37:2, b/test/corpus/default/cur/37:2,
similarity index 100%
rename from test/corpus/cur/37:2,
rename to test/corpus/default/cur/37:2,
diff --git a/test/corpus/cur/38:2, b/test/corpus/default/cur/38:2,
similarity index 100%
rename from test/corpus/cur/38:2,
rename to test/corpus/default/cur/38:2,
diff --git a/test/corpus/cur/39:2, b/test/corpus/default/cur/39:2,
similarity index 100%
rename from test/corpus/cur/39:2,
rename to test/corpus/default/cur/39:2,
diff --git a/test/corpus/cur/40:2, b/test/corpus/default/cur/40:2,
similarity index 100%
rename from test/corpus/cur/40:2,
rename to test/corpus/default/cur/40:2,
diff --git a/test/corpus/cur/41:2, b/test/corpus/default/cur/41:2,
similarity index 100%
rename from test/corpus/cur/41:2,
rename to test/corpus/default/cur/41:2,
diff --git a/test/corpus/cur/42:2, b/test/corpus/default/cur/42:2,
similarity index 100%
rename from test/corpus/cur/42:2,
rename to test/corpus/default/cur/42:2,
diff --git a/test/corpus/cur/43:2, b/test/corpus/default/cur/43:2,
similarity index 100%
rename from test/corpus/cur/43:2,
rename to test/corpus/default/cur/43:2,
diff --git a/test/corpus/cur/44:2, b/test/corpus/default/cur/44:2,
similarity index 100%
rename from test/corpus/cur/44:2,
rename to test/corpus/default/cur/44:2,
diff --git a/test/corpus/cur/45:2, b/test/corpus/default/cur/45:2,
similarity index 100%
rename from test/corpus/cur/45:2,
rename to test/corpus/default/cur/45:2,
diff --git a/test/corpus/cur/46:2, b/test/corpus/default/cur/46:2,
similarity index 100%
rename from test/corpus/cur/46:2,
rename to test/corpus/default/cur/46:2,
diff --git a/test/corpus/cur/47:2, b/test/corpus/default/cur/47:2,
similarity index 100%
rename from test/corpus/cur/47:2,
rename to test/corpus/default/cur/47:2,
diff --git a/test/corpus/cur/48:2, b/test/corpus/default/cur/48:2,
similarity index 100%
rename from test/corpus/cur/48:2,
rename to test/corpus/default/cur/48:2,
diff --git a/test/corpus/cur/49:2, b/test/corpus/default/cur/49:2,
similarity index 100%
rename from test/corpus/cur/49:2,
rename to test/corpus/default/cur/49:2,
diff --git a/test/corpus/cur/50:2, b/test/corpus/default/cur/50:2,
similarity index 100%
rename from test/corpus/cur/50:2,
rename to test/corpus/default/cur/50:2,
diff --git a/test/corpus/cur/51:2, b/test/corpus/default/cur/51:2,
similarity index 100%
rename from test/corpus/cur/51:2,
rename to test/corpus/default/cur/51:2,
diff --git a/test/corpus/cur/52:2, b/test/corpus/default/cur/52:2,
similarity index 100%
rename from test/corpus/cur/52:2,
rename to test/corpus/default/cur/52:2,
diff --git a/test/corpus/cur/53:2, b/test/corpus/default/cur/53:2,
similarity index 100%
rename from test/corpus/cur/53:2,
rename to test/corpus/default/cur/53:2,
diff --git a/test/notmuch-test b/test/notmuch-test
index b8437127c01f..6598f428d14f 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -49,6 +49,6 @@ echo
 ev=$?
 
 # Clean up
-rm -rf test-results corpus.mail
+rm -rf test-results corpus.mail.*
 
 exit $ev
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 78af170fe739..69070f26e4fe 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -516,19 +516,24 @@ emacs_fcc_message ()
 
 # Generate a corpus of email and add it to the database.
 #
-# This corpus is fixed, (it happens to be 50 messages from early in
-# the history of the notmuch mailing list), which allows for reliably
-# testing commands that need to operate on a not-totally-trivial
-# number of messages.
+# The first parameter defines the corpus to pick under the corpus
+# directory, defaulting to "default".
+#
+# The default corpus is fixed, (it happens to be 50 messages from
+# early in the history of the notmuch mailing list), which allows for
+# reliably testing commands that need to operate on a
+# not-totally-trivial number of messages.
 add_email_corpus ()
 {
+    local corpus=${1:-default}
+
     rm -rf ${MAIL_DIR}
-    if [ -d $TEST_DIRECTORY/corpus.mail ]; then
-	cp -a $TEST_DIRECTORY/corpus.mail ${MAIL_DIR}
+    if [ -d $TEST_DIRECTORY/corpus.mail.${corpus} ]; then
+	cp -a $TEST_DIRECTORY/corpus.mail.${corpus} ${MAIL_DIR}
     else
-	cp -a $TEST_DIRECTORY/corpus ${MAIL_DIR}
+	cp -a $TEST_DIRECTORY/corpus/${corpus} ${MAIL_DIR}
 	notmuch new >/dev/null
-	cp -a ${MAIL_DIR} $TEST_DIRECTORY/corpus.mail
+	cp -a ${MAIL_DIR} $TEST_DIRECTORY/corpus.mail.${corpus}
     fi
 }
 
-- 
1.8.5.3



More information about the notmuch mailing list