From f76e1cce404418cef74772536f2f5ac3a79b7b99 Mon Sep 17 00:00:00 2001
From: Lukas Fleischer <calcurse@cryptocrack.de>
Date: Wed, 22 Feb 2012 09:09:50 +0100
Subject: test/: Use correct calcurse binary and data dir

We really don't want to use the calcurse(1) binary from "$PATH" here.
Introduce an environment variable "$CALCURSE" which can be used specify
the binary to use and set this variable to the binary located in the
build directory by default. Similarly, add another environment variable
"$DATA_DIR" that can be used to specify a data directory.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
---
 test/Makefile.am        | 4 ++++
 test/appointment-001.sh | 2 +-
 test/day-001.sh         | 2 +-
 test/day-002.sh         | 2 +-
 test/day-003.sh         | 4 ++--
 test/next-001.sh        | 2 +-
 test/range-001.sh       | 2 +-
 test/range-002.sh       | 2 +-
 test/range-003.sh       | 4 ++--
 test/search-001.sh      | 2 +-
 test/todo-001.sh        | 4 ++--
 test/todo-002.sh        | 4 ++--
 test/todo-003.sh        | 4 ++--
 13 files changed, 21 insertions(+), 17 deletions(-)

(limited to 'test')

diff --git a/test/Makefile.am b/test/Makefile.am
index 5036478..85c8a1d 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -17,6 +17,10 @@ TESTS = \
 	next-001.sh \
 	search-001.sh
 
+TESTS_ENVIRONMENT = \
+	CALCURSE='$(top_builddir)/src/calcurse' \
+	DATA_DIR='$(top_srcdir)/test/data/'
+
 AM_CFLAGS = -std=c99 -pedantic -D_POSIX_C_SOURCE=200809L
 
 check_PROGRAMS = run-test
diff --git a/test/appointment-001.sh b/test/appointment-001.sh
index 18d5368..d103acc 100755
--- a/test/appointment-001.sh
+++ b/test/appointment-001.sh
@@ -6,7 +6,7 @@ if [ ! -x "$(command -v faketime)" ]; then
 fi
 
 if [ "$1" = 'actual' ]; then
-  faketime '2011-02-25 23:42' calcurse -D data -a
+  faketime '2011-02-25 23:42' "$CALCURSE" -D "$DATA_DIR" -a
 elif [ "$1" = 'expected' ]; then
   cat <<EOD
 02/25/11:
diff --git a/test/day-001.sh b/test/day-001.sh
index 6868b7a..ef5c212 100755
--- a/test/day-001.sh
+++ b/test/day-001.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 if [ "$1" = 'actual' ]; then
-  calcurse -D data/ -d02/25/2011
+  "$CALCURSE" -D "$DATA_DIR"/ -d02/25/2011
 elif [ "$1" = 'expected' ]; then
   cat <<EOD
 02/25/11:
diff --git a/test/day-002.sh b/test/day-002.sh
index ae1e191..ff0e2a6 100755
--- a/test/day-002.sh
+++ b/test/day-002.sh
@@ -6,7 +6,7 @@ if [ ! -x "$(command -v faketime)" ]; then
 fi
 
 if [ "$1" = 'actual' ]; then
-  faketime '1912-06-23' calcurse -D data/ -d42
+  faketime '1912-06-23' "$CALCURSE" -D "$DATA_DIR"/ -d42
 elif [ "$1" = 'expected' ]; then
   cat <<EOD
 06/24/12:
diff --git a/test/day-003.sh b/test/day-003.sh
index c63d7f6..25fca7d 100755
--- a/test/day-003.sh
+++ b/test/day-003.sh
@@ -6,9 +6,9 @@ if [ ! -x "$(command -v faketime)" ]; then
 fi
 
 if [ "$1" = 'actual' ]; then
-  faketime '1912-06-23' calcurse -D data/ -d42
+  faketime '1912-06-23' "$CALCURSE" -D "$DATA_DIR"/ -d42
 elif [ "$1" = 'expected' ]; then
-  calcurse -D data/ -s06/23/1912 -r42
+  "$CALCURSE" -D "$DATA_DIR"/ -s06/23/1912 -r42
 else
   ./run-test "$0"
 fi
diff --git a/test/next-001.sh b/test/next-001.sh
index 124b47b..5232272 100755
--- a/test/next-001.sh
+++ b/test/next-001.sh
@@ -6,7 +6,7 @@ if [ ! -x "$(command -v faketime)" ]; then
 fi
 
 if [ "$1" = 'actual' ]; then
-  faketime '1912-07-10 04:10' calcurse -D data -n
+  faketime '1912-07-10 04:10' "$CALCURSE" -D "$DATA_DIR" -n
 elif [ "$1" = 'expected' ]; then
   cat <<EOD
 next appointment:
diff --git a/test/range-001.sh b/test/range-001.sh
index 4932a4f..20afc9e 100755
--- a/test/range-001.sh
+++ b/test/range-001.sh
@@ -6,7 +6,7 @@ if [ ! -x "$(command -v faketime)" ]; then
 fi
 
 if [ "$1" = 'actual' ]; then
-  faketime '2011-02-25 00:00:00' calcurse -D data/ -r
+  faketime '2011-02-25 00:00:00' "$CALCURSE" -D "$DATA_DIR"/ -r
 elif [ "$1" = 'expected' ]; then
   cat <<EOD
 02/25/11:
diff --git a/test/range-002.sh b/test/range-002.sh
index 3685340..c3cf112 100755
--- a/test/range-002.sh
+++ b/test/range-002.sh
@@ -6,7 +6,7 @@ if [ ! -x "$(command -v faketime)" ]; then
 fi
 
 if [ "$1" = 'actual' ]; then
-  faketime '2000-01-01 00:00:00' calcurse -D data/ -r400
+  faketime '2000-01-01 00:00:00' "$CALCURSE" -D "$DATA_DIR"/ -r400
 elif [ "$1" = 'expected' ]; then
   cat <<EOD
 04/07/00:
diff --git a/test/range-003.sh b/test/range-003.sh
index e3768c0..df68437 100755
--- a/test/range-003.sh
+++ b/test/range-003.sh
@@ -6,9 +6,9 @@ if [ ! -x "$(command -v faketime)" ]; then
 fi
 
 if [ "$1" = 'actual' ]; then
-  faketime '2000-01-01 00:00:00' calcurse -D data/ -r400
+  faketime '2000-01-01 00:00:00' "$CALCURSE" -D "$DATA_DIR"/ -r400
 elif [ "$1" = 'expected' ]; then
-  calcurse -D data/ -s01/01/2000 -r400
+  "$CALCURSE" -D "$DATA_DIR"/ -s01/01/2000 -r400
 else
   ./run-test "$0"
 fi
diff --git a/test/search-001.sh b/test/search-001.sh
index d56fab5..c625286 100755
--- a/test/search-001.sh
+++ b/test/search-001.sh
@@ -6,7 +6,7 @@ if [ ! -x "$(command -v faketime)" ]; then
 fi
 
 if [ "$1" = 'actual' ]; then
-  calcurse -D data/ -s01/01/1902 -r36500 -S '^[KMS]an.*or'
+  "$CALCURSE" -D "$DATA_DIR"/ -s01/01/1902 -r36500 -S '^[KMS]an.*or'
 elif [ "$1" = 'expected' ]; then
   cat <<EOD
 12/06/42:
diff --git a/test/todo-001.sh b/test/todo-001.sh
index f607b30..d1c7433 100755
--- a/test/todo-001.sh
+++ b/test/todo-001.sh
@@ -1,11 +1,11 @@
 #!/bin/sh
 
 if [ "$1" = 'actual' ]; then
-  calcurse -D data/ -t | sort
+  "$CALCURSE" -D "$DATA_DIR"/ -t | sort
 elif [ "$1" = 'expected' ]; then
   (
     echo 'to do:'
-    sed '/^\[-/d; s/^\[\([0-9]\)\] \(.*\)/\1. \2/' data/todo
+    sed '/^\[-/d; s/^\[\([0-9]\)\] \(.*\)/\1. \2/' "$DATA_DIR"/todo
   ) | sort
 else
   ./run-test "$0"
diff --git a/test/todo-002.sh b/test/todo-002.sh
index c2718a9..8609e22 100755
--- a/test/todo-002.sh
+++ b/test/todo-002.sh
@@ -1,10 +1,10 @@
 #!/bin/sh
 
 if [ "$1" = 'actual' ]; then
-  calcurse -D data/ -t3
+  "$CALCURSE" -D "$DATA_DIR"/ -t3
 elif [ "$1" = 'expected' ]; then
   echo 'to do:'
-  sed -n 's/^\[3\] \(.*\)/3. \1/p' data/todo
+  sed -n 's/^\[3\] \(.*\)/3. \1/p' "$DATA_DIR"/todo
 else
   ./run-test "$0"
 fi
diff --git a/test/todo-003.sh b/test/todo-003.sh
index ecec032..ff8f8e6 100755
--- a/test/todo-003.sh
+++ b/test/todo-003.sh
@@ -1,11 +1,11 @@
 #!/bin/sh
 
 if [ "$1" = 'actual' ]; then
-  calcurse -D data/ -t0 | sort -n
+  "$CALCURSE" -D "$DATA_DIR"/ -t0 | sort -n
 elif [ "$1" = 'expected' ]; then
   (
     echo 'completed tasks:'
-    sed -n 's/^\[-\([0-9]\)\] \(.*\)/\1. \2/p' data/todo
+    sed -n 's/^\[-\([0-9]\)\] \(.*\)/\1. \2/p' "$DATA_DIR"/todo
   ) | sort -n
 else
   ./run-test "$0"
-- 
cgit v1.2.3-70-g09d2