File: run-tests

package info (click to toggle)
rolo 014-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 336 kB
  • sloc: ansic: 2,643; sh: 33; makefile: 24
file content (71 lines) | stat: -rwxr-xr-x 2,206 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh

# rolo - contact management software
# Copyright (C) 2019  Rafael Laboissière

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

### Redirect standard error into stadard output
exec 2>&1

### Exit immediately if a command exits with a non-zero status
set -e

### Get the directory of this script (for accessing congure.ac and
### contacts.vcf
CURDIR=$(dirname $0)
CONFIGURE_AC=$CURDIR/../configure.ac
CONTACTS=$CURDIR/contacts.vcf

### Rolo command.  Can be set as an environment variable when
### launching this script.  Defaults to the compiled version in ../src.
ROLO=${ROLO:-$CURDIR/../src/rolo}

### Test whether the -v option works
test_rolo_version() {
    command="$ROLO -v"
    output="$($command)"
    prog=$(grep AC_INIT\( $CONFIGURE_AC | cut -d[ -f2 | cut -d] -f1)
    version=$(grep AC_INIT\( $CONFIGURE_AC | cut -d[ -f3 | cut -d] -f1)
    assertEquals "$prog $version" "$output"
}

### Simple test for testing the help screen
test_rolo_startup_and_help() {
    echo hqq | TERM=dumb $ROLO -f $CONTACTS > /dev/null
}

### Test the search and the deletion commands
test_rolo_search_and_delete() {
    vcf=$(tempfile)
    cp $CONTACTS $vcf
    name=Burger
    echo "/$name
dyq" | TERM=dumb $ROLO -f $vcf > /dev/null
    assertEquals "" "$(grep $name $vcf || true)"
    rm -f $vcf
}

### Test the edit command via $ROLO_EDITOR
test_rolo_move_and_edit() {
    vcf=$(tempfile)
    cp $CONTACTS $vcf
    name="Alex Winter"
    output=$(echo Geq | ROLO_EDITOR=cat TERM=dumb $ROLO -f $vcf | grep "$name" || true)
    assertEquals "FN:$name" "$output"
    rm -f $vcf
}

### Launch the unit tests
. shunit2