• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

data/H11-Apr-2021-1,9101,826

Makefile.amH A D14-Oct-20202.9 KiB147140

Makefile.inH A D11-Apr-202154.5 KiB1,6021,481

READMEH A D30-Jan-20204.8 KiB11791

appointment-001.shH A D30-Jan-2020406 2217

appointment-002.shH A D30-Jan-2020287 1713

appointment-003.shH A D30-Jan-2020287 1713

appointment-004.shH A D30-Jan-2020287 1713

appointment-005.shH A D30-Jan-2020287 1713

appointment-006.shH A D30-Jan-2020287 1713

appointment-007.shH A D30-Jan-2020287 1713

appointment-008.shH A D30-Jan-2020218 95

appointment-009.shH A D30-Jan-2020214 95

appointment-010.shH A D30-Jan-2020219 95

appointment-011.shH A D30-Jan-2020226 95

appointment-012.shH A D30-Jan-2020214 95

appointment-013.shH A D30-Jan-2020226 95

appointment-014.shH A D30-Jan-2020226 95

appointment-015.shH A D30-Jan-2020226 95

appointment-016.shH A D30-Jan-2020214 95

appointment-017.shH A D30-Jan-2020226 95

appointment-018.shH A D30-Jan-2020226 95

appointment-019.shH A D30-Jan-2020214 95

appointment-020.shH A D30-Jan-2020220 95

appointment-021.shH A D30-Jan-2020214 95

appointment-022.shH A D30-Jan-2020214 95

bug-002.shH A D30-Jan-2020317 1915

day-001.shH A D30-Jan-2020279 1713

day-002.shH A D30-Jan-2020732 4332

day-003.shH A D30-Jan-2020384 1813

event-001.shH A D30-Jan-2020259 1612

event-002.shH A D30-Jan-2020212 95

event-003.shH A D30-Jan-2020202 95

event-004.shH A D30-Jan-2020213 95

event-005.shH A D30-Jan-2020214 95

event-006.shH A D30-Jan-2020214 95

filter-001.shH A D30-Jan-2020414 2922

ical-001.shH A D14-Oct-2020582 2924

ical-002.shH A D14-Oct-2020727 3429

ical-003.shH A D14-Oct-20204 KiB241189

ical-004.shH A D14-Oct-2020582 2924

ical-005.shH A D14-Oct-2020578 3025

ical-006.shH A D14-Oct-2020840 4440

ical-007.shH A D14-Oct-2020576 3026

ical-008.shH A D14-Oct-2020582 2924

ical-009.shH A D10-Apr-20211.6 KiB4840

ical-010.shH A D14-Oct-2020954 3530

ical-011.shH A D14-Oct-2020627 2013

ical-012.shH A D14-Oct-20201.4 KiB6858

ical-013.shH A D14-Oct-202038.2 KiB1,8011,512

ical-014.shH A D14-Oct-2020524 2924

io-001.shH A D30-Jan-2020187 116

io-002.shH A D30-Jan-2020224 127

io-003.shH A D30-Jan-2020226 138

io-004.shH A D30-Jan-2020305 138

io-005.shH A D10-Apr-2021270 116

io-006.shH A D10-Apr-2021249 127

next-001.shH A D30-Jan-2020395 2015

next-002.shH A D30-Jan-2020395 2015

next-003.shH A D30-Jan-2020395 2015

range-001.shH A D30-Jan-2020407 2217

range-002.shH A D30-Jan-2020735 4130

range-003.shH A D30-Jan-2020386 1813

recur-001.shH A D30-Jan-20201.1 KiB5342

recur-002.shH A D30-Jan-2020345 1713

recur-003.shH A D30-Jan-2020471 2016

recur-004.shH A D30-Jan-2020407 2117

recur-005.shH A D30-Jan-2020407 2117

recur-006.shH A D30-Jan-2020968 5139

recur-007.shH A D12-Oct-2020633 3226

recur-008.shH A D14-Oct-20205.1 KiB309238

recur-009.shH A D14-Oct-2020193.2 KiB5,3433,921

recur-010.shH A D14-Oct-20202.2 KiB5946

regress-001.shH A D30-Jan-2020317 1612

run-test-001.shH A D30-Jan-2020131 106

run-test-002.shH A D30-Jan-2020154 128

run-test.cH A D18-Apr-20205.2 KiB236155

search-001.shH A D30-Jan-2020489 2922

test-init.shH A D10-Apr-2021148 106

todo-001.shH A D30-Jan-2020286 1511

todo-002.shH A D30-Jan-2020254 139

todo-003.shH A D30-Jan-2020299 1511

true-001.shH A D30-Jan-202050 62

README

1calcurse Test Suite
2===================
3
4This directory holds of a couple of test cases and some helpers to simplify the
5task of creating new tests. Test cases are intended to test a specified set of
6behaviors and to avoid reintroduction of bugs that have already been fixed. The
7idea is that a new test should be added for each bug report that is received
8and for each bug that is fixed in the development branch.
9
10Running tests
11-------------
12
13The easiest way to run tests is running `make check`. This will prepare and
14compile all needed components and start all test cases. A summary is displayed
15when all tests are finished.
16
17You can also run tests manually. Test cases are usually shell scripts or
18binaries. To run an individual test, just invoke the corresponding executable.
19The `CALCURSE` and `DATA_DIR` environment variables can be used to specify an
20alternative calcurse binary and data directory.
21
22Passing another data directory might cause some failures since many tests are
23adapted for the `test/` directory provided by the test suite:
24
25    $ CALCURSE=../src/calcurse DATA_DIR="$HOME/.local/share/calcurse/" ./next-001.sh
26    Running ./next-001.sh... FAIL
27
28Writing tests
29-------------
30
31Writing test cases is as simple as creating a new shell script and adding some
32test code. Success and failure are reported by setting the exit status. Setting
33the exit status to `0` indicates success, a non-zero value indicates failure
34(which reflects the usual exit code semantics of POSIX systems).
35
36To enable a test, just add it to the `TESTS` variable in `test/Makefile.am`. If
37your test case is written in a non-interpretable language, you may need to add
38some compilation directives as well. Please note that we only accept
39POSIX-compatible shell scripts and C in mainline, so please avoid using other
40languages if you plan to get your test case integrated upstream.
41
42If your test case invokes the calcurse binary, please continue reading the
43following sections, also.
44
45The `run-test` helper
46---------------------
47
48The `run-test` helper is a simple C program that makes writing script-based
49test cases much easier. Tests for the calcurse command line interface usually
50invoke the calcurse binary with some special command line options and compare
51the output with a hardcoded set of expected results. Unfortunately, comparing
52the output of two commands is not exactly easy in POSIX shell: this is where
53the `run-test` helper comes in handy.
54
55If you run the `run-test` helper, you can pass one or more executable files as
56parameters. The helper then invokes each of the specified scripts twice: Once
57passing `actual` as a command line parameter and once passing `expected`. It
58then compares the outputs of both invocations and checks if they are equal or
59not.  If the `actual`/`expected` outputs differ for one of the programs passed
60to `run-test`, if displays `FAIL` and exits with a non-zero exit status. It
61returns success otherwise.
62
63Here is a simple example on how to use `run-test`:
64
65    #!/bin/sh
66
67    if [ "$1" = 'actual' ]; then
68      echo 'obrocodobro' | sed 's/o/a/g'
69    elif [ "$1" = 'expected' ]; then
70      echo 'abracadabra'
71    else
72      ./run-test "$0"
73    fi
74
75If the script is run without any parameters, it simply invokes `run-test`,
76passing itself as a command line parameter (see the `else` branch). `run-test`
77then reruns the script, passing `actual` as the first parameter. This starts
78the actual test (see the `if` branch). It reruns the script a second time,
79passing `expected` as the first parameter which results in the script printing
80the expected result for this test (see the `elif` branch). Finally, `run-test`
81compares both outputs, prints a message indicating whether they are equal and
82sets the exit status accordingly. This exit status is then passed on to the
83original instance of the test script and returned since `./run-test "$0"` is
84the last command that is run if the script is invoked without any parameters.
85
86You should stick to this strategy whenever you want to check the output of a
87non-interactive calcurse instance in a test. Check the following tests for some
88more examples:
89
90* `todo-001.sh`
91* `todo-002.sh`
92* `todo-003.sh`
93
94Using libfaketime
95-----------------
96
97Some tests might require faking current date and time. We currently use
98libfaketime to achieve this. Check the following files for examples:
99
100* `appointment-001.sh`
101* `next-001.sh`
102* `range-001.sh`
103* `range-002.sh`
104* `range-003.sh`
105
106NOTE: Please do not forget to check for libfaketime presence at the beginning
107of your test. Otherwise, your test is likely to fail on systems that are not
108supported by libfaketime.
109
110Additional notes
111----------------
112
113Most tests, that invoke the calcurse binary, pass the `--read-only` parameter
114to make sure the data directory is not modified by calcurse, preventing
115unexpected side effects. Please follow this guideline if you plan to submit
116your patch upstream.
117