[notmuch] [PATCH 1/4] Copy test framework from Git
Git uses a simple and yet powerfull test framework, written in shell. The framework is easy to use for both users and developers so I thing it would help if it is used in notmuch as well. This is a copy of Git's test framework from commit b8bba419250711a69e09e7648e5c991f4847a127. Signed-off-by: Michal Sojka --- test/Makefile | 46 +++ test/README | 297 + test/aggregate-results.sh | 34 ++ test/t-basic.sh | 368 + test/test-lib.sh | 787 + 5 files changed, 1532 insertions(+), 0 deletions(-) create mode 100644 test/Makefile create mode 100644 test/README create mode 100755 test/aggregate-results.sh create mode 100755 test/t-basic.sh create mode 100644 test/test-lib.sh diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 000..bd09390 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,46 @@ +# Run tests +# +# Copyright (c) 2005 Junio C Hamano +# + +-include ../config.mak + +#GIT_TEST_OPTS=--verbose --debug +SHELL_PATH ?= $(SHELL) +TAR ?= $(TAR) +RM ?= rm -f + +# Shell quote; +SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) + +T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh) +TSVN = $(wildcard t91[0-9][0-9]-*.sh) + +all: pre-clean + $(MAKE) aggregate-results-and-cleanup + +$(T): + @echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS) + +pre-clean: + $(RM) -r test-results + +clean: + $(RM) -r 'trash directory'.* test-results + +aggregate-results-and-cleanup: $(T) + $(MAKE) aggregate-results + $(MAKE) clean + +aggregate-results: + '$(SHELL_PATH_SQ)' ./aggregate-results.sh test-results/t*-* + +# we can test NO_OPTIMIZE_COMMITS independently of LC_ALL +full-svn-test: + $(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=1 LC_ALL=C + $(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=0 LC_ALL=en_US.UTF-8 + +valgrind: + GIT_TEST_OPTS=--valgrind $(MAKE) + +.PHONY: pre-clean $(T) aggregate-results clean valgrind diff --git a/test/README b/test/README new file mode 100644 index 000..dcd3ebb --- /dev/null +++ b/test/README @@ -0,0 +1,297 @@ +Core GIT Tests +== + +This directory holds many test scripts for core GIT tools. The +first part of this short document describes how to run the tests +and read their output. + +When fixing the tools or adding enhancements, you are strongly +encouraged to add tests in this directory to cover what you are +trying to fix or enhance. The later part of this short document +describes how your test scripts should be organized. + + +Running Tests +- + +The easiest way to run tests is to say "make". This runs all +the tests. + +*** t-basic.sh *** +* ok 1: .git/objects should be empty after git-init in an empty repo. +* ok 2: .git/objects should have 256 subdirectories. +* ok 3: git-update-index without --add should fail adding. +... +* ok 23: no diff after checkout and git-update-index --refresh. +* passed all 23 test(s) +*** t0100-environment-names.sh *** +* ok 1: using old names should issue warnings. +* ok 2: using old names but having new names should not issue warnings. +... + +Or you can run each test individually from command line, like +this: + +$ sh ./t3001-ls-files-killed.sh +* ok 1: git-update-index --add to add various paths. +* ok 2: git-ls-files -k to show killed files. +* ok 3: validate git-ls-files -k output. +* passed all 3 test(s) + +You can pass --verbose (or -v), --debug (or -d), and --immediate +(or -i) command line argument to the test, or by setting GIT_TEST_OPTS +appropriately before running "make". + +--verbose:: + This makes the test more verbose. Specifically, the + command being run and their output if any are also + output. + +--debug:: + This may help the person who is developing a new test. + It causes the command defined with test_debug to run. + +--immediate:: + This causes the test to immediately exit upon the first + failed test. + +--long-tests:: + This causes additional long-running tests to be run (where + available), for more exhaustive testing. + +--valgrind:: + Execute all Git binaries with valgrind and exit with status + 126 on errors (just like regular tests, this will only stop + the test script when running under -i). Valgrind errors + go to stderr, so you might want to pass the -v option, too. + + Since it makes no sense to run the tests with --valgrind and + not see any output, this option implies --verbose. For + convenience, it also implies --tee. + +--tee:: + In addition to printing the test output to the terminal, + write it to files named 't/test-results/$TEST_NAME.out'. + As the names depend on the tests' file names, it is safe to + run the tests with this option in parallel. + +-
[notmuch] [PATCH 1/4] Copy test framework from Git
Git uses a simple and yet powerfull test framework, written in shell. The framework is easy to use for both users and developers so I thing it would help if it is used in notmuch as well. This is a copy of Git's test framework from commit b8bba419250711a69e09e7648e5c991f4847a127. Signed-off-by: Michal Sojka --- test/Makefile | 46 +++ test/README | 297 + test/aggregate-results.sh | 34 ++ test/t-basic.sh | 368 + test/test-lib.sh | 787 + 5 files changed, 1532 insertions(+), 0 deletions(-) create mode 100644 test/Makefile create mode 100644 test/README create mode 100755 test/aggregate-results.sh create mode 100755 test/t-basic.sh create mode 100644 test/test-lib.sh diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 000..bd09390 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,46 @@ +# Run tests +# +# Copyright (c) 2005 Junio C Hamano +# + +-include ../config.mak + +#GIT_TEST_OPTS=--verbose --debug +SHELL_PATH ?= $(SHELL) +TAR ?= $(TAR) +RM ?= rm -f + +# Shell quote; +SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) + +T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh) +TSVN = $(wildcard t91[0-9][0-9]-*.sh) + +all: pre-clean + $(MAKE) aggregate-results-and-cleanup + +$(T): + @echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS) + +pre-clean: + $(RM) -r test-results + +clean: + $(RM) -r 'trash directory'.* test-results + +aggregate-results-and-cleanup: $(T) + $(MAKE) aggregate-results + $(MAKE) clean + +aggregate-results: + '$(SHELL_PATH_SQ)' ./aggregate-results.sh test-results/t*-* + +# we can test NO_OPTIMIZE_COMMITS independently of LC_ALL +full-svn-test: + $(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=1 LC_ALL=C + $(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=0 LC_ALL=en_US.UTF-8 + +valgrind: + GIT_TEST_OPTS=--valgrind $(MAKE) + +.PHONY: pre-clean $(T) aggregate-results clean valgrind diff --git a/test/README b/test/README new file mode 100644 index 000..dcd3ebb --- /dev/null +++ b/test/README @@ -0,0 +1,297 @@ +Core GIT Tests +== + +This directory holds many test scripts for core GIT tools. The +first part of this short document describes how to run the tests +and read their output. + +When fixing the tools or adding enhancements, you are strongly +encouraged to add tests in this directory to cover what you are +trying to fix or enhance. The later part of this short document +describes how your test scripts should be organized. + + +Running Tests +- + +The easiest way to run tests is to say "make". This runs all +the tests. + +*** t-basic.sh *** +* ok 1: .git/objects should be empty after git-init in an empty repo. +* ok 2: .git/objects should have 256 subdirectories. +* ok 3: git-update-index without --add should fail adding. +... +* ok 23: no diff after checkout and git-update-index --refresh. +* passed all 23 test(s) +*** t0100-environment-names.sh *** +* ok 1: using old names should issue warnings. +* ok 2: using old names but having new names should not issue warnings. +... + +Or you can run each test individually from command line, like +this: + +$ sh ./t3001-ls-files-killed.sh +* ok 1: git-update-index --add to add various paths. +* ok 2: git-ls-files -k to show killed files. +* ok 3: validate git-ls-files -k output. +* passed all 3 test(s) + +You can pass --verbose (or -v), --debug (or -d), and --immediate +(or -i) command line argument to the test, or by setting GIT_TEST_OPTS +appropriately before running "make". + +--verbose:: + This makes the test more verbose. Specifically, the + command being run and their output if any are also + output. + +--debug:: + This may help the person who is developing a new test. + It causes the command defined with test_debug to run. + +--immediate:: + This causes the test to immediately exit upon the first + failed test. + +--long-tests:: + This causes additional long-running tests to be run (where + available), for more exhaustive testing. + +--valgrind:: + Execute all Git binaries with valgrind and exit with status + 126 on errors (just like regular tests, this will only stop + the test script when running under -i). Valgrind errors + go to stderr, so you might want to pass the -v option, too. + + Since it makes no sense to run the tests with --valgrind and + not see any output, this option implies --verbose. For + convenience, it also implies --tee. + +--tee:: + In addition to printing the test output to the terminal, + write it to files named 't/test-results/$TEST_NAME.out'. + As the names depend on the tests' file names, it is safe to + run the tests with this option in parallel. + +-