13 Commits

Author SHA1 Message Date
Lukas Fleischer
80d882d03d test/: Run calcurse in read-only mode
We don't change any configuration nor do we modify items here, so we can
safely invoke calcurse in read-only mode. Fixes a couple of permission
errors seen with `make distcheck`.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-02-24 22:48:26 +01:00
Lukas Fleischer
f76e1cce40 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>
2012-02-24 22:48:26 +01:00
Lukas Fleischer
423bfcc9ac test/Makefile.am: Add tests to "EXTRA_DIST"
Add tests and the dummy data directory to "EXTRA_DIST" since we want
these to be shipped in distribution tarballs. Spotted with `make
distcheck`.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-02-24 22:48:25 +01:00
Lukas Fleischer
7c91248629 {src,test}/Makefile.am: Enable pedantic warnings
Now that we're fully POSIX compliant and fixed up some minor issues with
ISO C99, use "-std=c99 -pedantic -D_POSIX_C_SOURCE=200809L" as default
build flags for calcurse and the test suite.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-02-19 03:23:26 +01:00
Lukas Fleischer
030db26ad3 test/run-test.c: Check fgets() return value properly
Not sure what we were doing here. fgets() returns a pointer, not an
integer!

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-02-19 03:18:10 +01:00
Lukas Fleischer
dfc98b5fa1 test/: Add test case for "-S" (pattern search)
* search-001.sh: Compare the output of "-S <regex>" (using a regular
  expression) with hardcoded data.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-01-22 17:00:19 +01:00
Lukas Fleischer
cb69a4c087 test/: Add test cases for "-a" and "-n"
* appointment-001.sh: Compare output of "-a" with hardcoded data.
* next-001.sh: Compare output of "-n" with hardcoded data.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-01-22 16:40:00 +01:00
Lukas Fleischer
dbb19b7c25 test/: Add test cases for "-d" and "-s"/"-r"
* day-001.sh: Compare output of "-d<date>" with hardcoded data.
* day-002.sh: Compare output of "-d<num>" with hardcoded data.
* day-003.sh: Compare output of "-d<num>" with "-s<date> -r<num>".
* range-001.sh: Compare output of "-r" with hardcoded data.
* range-002.sh: Compare output of "-r<num>" with hardcoded data.
* range-003.sh: Compare output of "-r<num>" with "-s<date> -r<num>".

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-01-22 01:03:31 +01:00
Lukas Fleischer
32530f0e50 test/: Add generic tests for todo operations
* todo-001.sh: Tests the "-t" command line option (calculates expected
  output by parsing the todo data file).

* todo-002.sh: Tests "-t<num>" in a way similar to todo-001.sh.

* todo-003.sh: Tests "-t0" in a way similar to todo-001.sh.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-01-22 00:13:35 +01:00
Lukas Fleischer
31b4c71eb2 test/: Add three basic self tests
* true-001.sh: Always returns true - this should never ever fail.

* run-test-001.sh: Invokes run-test, passing itself as a parameter.
  Subsequently, it outputs the very same (hardcoded) expected and actual
  values.

* run-test-002.sh: Tests run-test's negative assertion feature in a way
  similar to run-test-001.sh. However, output different (hardcoded)
  expected and actual values and invoke run-test with the negative test
  prefix ('!').

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-01-22 00:13:35 +01:00
Lukas Fleischer
d34e6502e9 test/: Add initial configuration file
As a preparation for our test cases (needed for date formatting etc.)

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-01-22 00:13:35 +01:00
Lukas Fleischer
9cba56ac0a test/run-test.c: Support negative assertions
Sometimes, we might want to make negative assertions (tests where
expected and actual output are expected/known to be different). A test
can be marked negative by prefixing it with an exclamation mark ('!'):

    $ ./run-test !test-negative
    Running test-negative... ok

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-01-21 23:06:32 +01:00
Lukas Fleischer
e66e2d4277 Add a minimal test suite
Introduce a new "test/" sub-directory that contains tests for calcurse.
Right now, it only includes the quick-and-dirty "run-test" helper that
can be used to run and verify tests:

    $ ./run-test test-1 test-2 test-3 test-4
    Running test-1... ok
    Running test-2... ok
    Running test-3... FAIL

Each argument passed to run-test must be a test script located in the
current directory. run-test invokes each script twice and passes the
command line argument "expected" and "actual", respectively. A test case
succeeds if both "expected" and "actual" instances return with a zero
exit status and produce exactly the same output. It fails otherwise.

run-test terminates with a non-zero exit status as soon as one of the
test fails.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-01-21 23:06:32 +01:00