diff options
author | Lukas Fleischer <calcurse@cryptocrack.de> | 2013-02-26 23:34:29 +0100 |
---|---|---|
committer | Lukas Fleischer <calcurse@cryptocrack.de> | 2013-02-27 11:36:28 +0100 |
commit | ba2c5c14f6408872ec34a223d131266ab83e4b7d (patch) | |
tree | 1eaf195f841fb7fa70e2f4cf729dd841292651f6 | |
parent | 5501dae32874bf3f65f7619aa76c6a213bbce321 (diff) | |
download | calcurse-ba2c5c14f6408872ec34a223d131266ab83e4b7d.tar.gz calcurse-ba2c5c14f6408872ec34a223d131266ab83e4b7d.zip |
test/: Add default values for configuration variables
Add a small helper script called "test-init.sh" that is sourced in each
test case and initializes the CALCURSE and DATA_DIR environment
variables.
Update the test suite README to point out that setting these environment
variables is no longer required.
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
50 files changed, 102 insertions, 7 deletions
diff --git a/test/README b/test/README index f0fd06a..f45fd0b 100644 --- a/test/README +++ b/test/README @@ -16,13 +16,8 @@ when all tests are finished. You can also run tests manually. Test cases are usually shell scripts or binaries. To run an individual test, just invoke the corresponding executable. -Note that some tests require the `CALCURSE` and `DATA_DIR` environment -variables to be set, where `CALCURSE` should point to a valid calcurse binary -and `DATA_DIR` should point to a valid data directory. We usually use the data -directory `data/`, which is contained in the `test/` directory, for test cases: - - $ CALCURSE=../src/calcurse DATA_DIR=data/ ./next-001.sh - Running ./next-001.sh... ok +The `CALCURSE` and `DATA_DIR` environment variables can be used to specify an +alternative calcurse binary and data directory. Passing another data directory might cause some failures since many tests are adapted for the `test/` directory provided by the test suite: diff --git a/test/appointment-001.sh b/test/appointment-001.sh index c0f60c7..6b70ff6 100755 --- a/test/appointment-001.sh +++ b/test/appointment-001.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ ! -x "$(command -v faketime)" ]; then echo "libfaketime not found - skipping $0..." exit 0 diff --git a/test/appointment-002.sh b/test/appointment-002.sh index 5a85c6a..316373a 100755 --- a/test/appointment-002.sh +++ b/test/appointment-002.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' ]; then "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-002" \ -d02/23/2013 diff --git a/test/appointment-003.sh b/test/appointment-003.sh index 389fa13..840823f 100755 --- a/test/appointment-003.sh +++ b/test/appointment-003.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' ]; then "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-003" \ -d02/23/2013 diff --git a/test/appointment-004.sh b/test/appointment-004.sh index cbab131..a24b2a8 100755 --- a/test/appointment-004.sh +++ b/test/appointment-004.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' ]; then "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-004" \ -d02/23/2013 diff --git a/test/appointment-005.sh b/test/appointment-005.sh index 54a0acc..6ebdc5e 100755 --- a/test/appointment-005.sh +++ b/test/appointment-005.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' ]; then "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-005" \ -d02/23/2013 diff --git a/test/appointment-006.sh b/test/appointment-006.sh index 3746f5a..3e5d1a4 100755 --- a/test/appointment-006.sh +++ b/test/appointment-006.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' ]; then "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-006" \ -d02/23/2013 diff --git a/test/appointment-007.sh b/test/appointment-007.sh index a097e02..fdad766 100755 --- a/test/appointment-007.sh +++ b/test/appointment-007.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' ]; then "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-007" \ -d02/23/2013 diff --git a/test/appointment-008.sh b/test/appointment-008.sh index b50c200..9f1fcff 100755 --- a/test/appointment-008.sh +++ b/test/appointment-008.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-008" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'syntax error in the item date' errors diff --git a/test/appointment-009.sh b/test/appointment-009.sh index 0e7bd33..42caf0e 100755 --- a/test/appointment-009.sh +++ b/test/appointment-009.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-009" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'date error in appointment' errors diff --git a/test/appointment-010.sh b/test/appointment-010.sh index 20b7b48..a3bd080 100755 --- a/test/appointment-010.sh +++ b/test/appointment-010.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-010" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'no event nor appointment found' errors diff --git a/test/appointment-011.sh b/test/appointment-011.sh index 94098fb..120388e 100755 --- a/test/appointment-011.sh +++ b/test/appointment-011.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-011" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'syntax error in item time or duration' errors diff --git a/test/appointment-012.sh b/test/appointment-012.sh index 9cf80b6..5b635ef 100755 --- a/test/appointment-012.sh +++ b/test/appointment-012.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-012" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'date error in appointment' errors diff --git a/test/appointment-013.sh b/test/appointment-013.sh index 5ab608f..b820a31 100755 --- a/test/appointment-013.sh +++ b/test/appointment-013.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-013" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'syntax error in item time or duration' errors diff --git a/test/appointment-014.sh b/test/appointment-014.sh index ba67f41..ef25059 100755 --- a/test/appointment-014.sh +++ b/test/appointment-014.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-014" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'syntax error in item time or duration' errors diff --git a/test/appointment-015.sh b/test/appointment-015.sh index be59baa..5b18044 100755 --- a/test/appointment-015.sh +++ b/test/appointment-015.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-015" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'syntax error in item time or duration' errors diff --git a/test/appointment-016.sh b/test/appointment-016.sh index 9103b50..791ba86 100755 --- a/test/appointment-016.sh +++ b/test/appointment-016.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-016" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'date error in appointment' errors diff --git a/test/appointment-017.sh b/test/appointment-017.sh index 274e9a1..58355b8 100755 --- a/test/appointment-017.sh +++ b/test/appointment-017.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-017" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'syntax error in item time or duration' errors diff --git a/test/appointment-018.sh b/test/appointment-018.sh index 2124074..814b410 100755 --- a/test/appointment-018.sh +++ b/test/appointment-018.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-018" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'syntax error in item time or duration' errors diff --git a/test/appointment-019.sh b/test/appointment-019.sh index d29fa8f..d946e88 100755 --- a/test/appointment-019.sh +++ b/test/appointment-019.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-019" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'date error in appointment' errors diff --git a/test/appointment-020.sh b/test/appointment-020.sh index 78e4db6..abb2c76 100755 --- a/test/appointment-020.sh +++ b/test/appointment-020.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-020" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'syntax error in item repetition' errors diff --git a/test/appointment-021.sh b/test/appointment-021.sh index f0db9b8..214d3ec 100755 --- a/test/appointment-021.sh +++ b/test/appointment-021.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-021" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'date error in appointment' errors diff --git a/test/appointment-022.sh b/test/appointment-022.sh index 4e72b73..8ff0f81 100755 --- a/test/appointment-022.sh +++ b/test/appointment-022.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-appointment-022" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'date error in appointment' errors diff --git a/test/bug-002.sh b/test/bug-002.sh index 4784b59..c52f744 100755 --- a/test/bug-002.sh +++ b/test/bug-002.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' ]; then "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-bug-002" \ -d05/03/2012 diff --git a/test/day-001.sh b/test/day-001.sh index 614f6e3..da8a192 100755 --- a/test/day-001.sh +++ b/test/day-001.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' ]; then "$CALCURSE" --read-only -D "$DATA_DIR"/ -d02/25/2011 elif [ "$1" = 'expected' ]; then diff --git a/test/day-002.sh b/test/day-002.sh index a9ac2c4..c46da32 100755 --- a/test/day-002.sh +++ b/test/day-002.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ ! -x "$(command -v faketime)" ]; then echo "libfaketime not found - skipping $0..." exit 0 diff --git a/test/day-003.sh b/test/day-003.sh index 63df45a..619c8e6 100755 --- a/test/day-003.sh +++ b/test/day-003.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ ! -x "$(command -v faketime)" ]; then echo "libfaketime not found - skipping $0..." exit 0 diff --git a/test/event-001.sh b/test/event-001.sh index 6496309..aa5e50d 100755 --- a/test/event-001.sh +++ b/test/event-001.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' ]; then "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-event-001" \ -d02/23/2013 diff --git a/test/event-002.sh b/test/event-002.sh index 0a101e2..730f432 100755 --- a/test/event-002.sh +++ b/test/event-002.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-event-002" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'syntax error in the item date' errors diff --git a/test/event-003.sh b/test/event-003.sh index 2e18b0c..f4cfafe 100755 --- a/test/event-003.sh +++ b/test/event-003.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-event-003" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'date error in event' errors diff --git a/test/event-004.sh b/test/event-004.sh index cb4d036..c38374b 100755 --- a/test/event-004.sh +++ b/test/event-004.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-event-004" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'no event nor appointment found' errors diff --git a/test/event-005.sh b/test/event-005.sh index 5504973..38d4108 100755 --- a/test/event-005.sh +++ b/test/event-005.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-event-005" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'syntax error in item identifier' errors diff --git a/test/event-006.sh b/test/event-006.sh index 329a16e..a0ca115 100755 --- a/test/event-006.sh +++ b/test/event-006.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-event-006" \ -d02/23/2013 2>errors && exit 1 grep -Fq 'syntax error in item identifier' errors diff --git a/test/next-001.sh b/test/next-001.sh index 98002ba..4c9ab95 100755 --- a/test/next-001.sh +++ b/test/next-001.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ ! -x "$(command -v faketime)" ]; then echo "libfaketime not found - skipping $0..." exit 0 diff --git a/test/range-001.sh b/test/range-001.sh index 116b846..91f3c0f 100755 --- a/test/range-001.sh +++ b/test/range-001.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ ! -x "$(command -v faketime)" ]; then echo "libfaketime not found - skipping $0..." exit 0 diff --git a/test/range-002.sh b/test/range-002.sh index 55d057d..8703f3a 100755 --- a/test/range-002.sh +++ b/test/range-002.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ ! -x "$(command -v faketime)" ]; then echo "libfaketime not found - skipping $0..." exit 0 diff --git a/test/range-003.sh b/test/range-003.sh index 027937f..4716d00 100755 --- a/test/range-003.sh +++ b/test/range-003.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ ! -x "$(command -v faketime)" ]; then echo "libfaketime not found - skipping $0..." exit 0 diff --git a/test/recur-001.sh b/test/recur-001.sh index 307c174..ae4e025 100755 --- a/test/recur-001.sh +++ b/test/recur-001.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' ]; then "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-recur" \ -s01/01/2000 -r8 --format-recur-apt='' diff --git a/test/recur-002.sh b/test/recur-002.sh index d302971..f22bd5e 100755 --- a/test/recur-002.sh +++ b/test/recur-002.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' ]; then "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-recur" \ -d02/01/2000 --format-recur-apt='' diff --git a/test/recur-003.sh b/test/recur-003.sh index fadaea0..7e91cd6 100755 --- a/test/recur-003.sh +++ b/test/recur-003.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' ]; then "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-recur" \ -d01/01/2001 --format-recur-apt='' diff --git a/test/recur-004.sh b/test/recur-004.sh index 39ea193..d218b21 100755 --- a/test/recur-004.sh +++ b/test/recur-004.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' ]; then "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-recur" \ -d01/01/2000 --format-recur-event='' diff --git a/test/recur-005.sh b/test/recur-005.sh index 6f9d4c3..25b8ce5 100755 --- a/test/recur-005.sh +++ b/test/recur-005.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' ]; then "$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/apts-recur" \ -d01/10/2000 --format-recur-event='' diff --git a/test/run-test-001.sh b/test/run-test-001.sh index 9c1a962..580e64c 100755 --- a/test/run-test-001.sh +++ b/test/run-test-001.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' -o "$1" = 'expected' ]; then echo 42 else diff --git a/test/run-test-002.sh b/test/run-test-002.sh index 6a10101..0c40419 100755 --- a/test/run-test-002.sh +++ b/test/run-test-002.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' ]; then echo 23 elif [ "$1" = 'expected' ]; then diff --git a/test/search-001.sh b/test/search-001.sh index cd0a7ff..9be0a3b 100755 --- a/test/search-001.sh +++ b/test/search-001.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ ! -x "$(command -v faketime)" ]; then echo "libfaketime not found - skipping $0..." exit 0 diff --git a/test/test-init.sh b/test/test-init.sh new file mode 100644 index 0000000..c95c884 --- /dev/null +++ b/test/test-init.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +CALCURSE=${CALCURSE:-../src/calcurse} +DATA_DIR=${DATA_DIR:-data/} diff --git a/test/todo-001.sh b/test/todo-001.sh index db6b6ca..013e130 100755 --- a/test/todo-001.sh +++ b/test/todo-001.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' ]; then "$CALCURSE" --read-only -D "$DATA_DIR"/ -t | sort elif [ "$1" = 'expected' ]; then diff --git a/test/todo-002.sh b/test/todo-002.sh index a91d06d..b62b60e 100755 --- a/test/todo-002.sh +++ b/test/todo-002.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' ]; then "$CALCURSE" --read-only -D "$DATA_DIR"/ -t3 elif [ "$1" = 'expected' ]; then diff --git a/test/todo-003.sh b/test/todo-003.sh index 2dcb2d3..3f18288 100755 --- a/test/todo-003.sh +++ b/test/todo-003.sh @@ -1,5 +1,7 @@ #!/bin/sh +. ./test-init.sh + if [ "$1" = 'actual' ]; then "$CALCURSE" --read-only -D "$DATA_DIR"/ -t0 | sort -n elif [ "$1" = 'expected' ]; then diff --git a/test/true-001.sh b/test/true-001.sh index 296ef78..b69e4bd 100755 --- a/test/true-001.sh +++ b/test/true-001.sh @@ -1,3 +1,5 @@ #!/bin/sh +. ./test-init.sh + true |