File: bash_tap_ti.sh

package info (click to toggle)
timew 1.1.1%2Bds.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,348 kB
  • sloc: cpp: 22,428; python: 3,612; sh: 111; makefile: 15
file content (59 lines) | stat: -rw-r--r-- 1,953 bytes parent folder | download
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
#!/usr/bin/env bash
# This file only contains helper functions for making Timewarrior testing
# easier. The magic happens in bash_tap.sh sourced at the end of this file.
#
# "timew" is a bash function calling "TIMEWARRIORDB=dir /path/to/compiled/timew"
# Only local paths are searched, see bash_tap_tw.sh:find_timew_binary().
#
# "timewarrior.cfg" is a file set up in bash_tap_ti.sh:setup_cfg(), and can be
# appended to or changed as needed.
#
# Subject to the MIT License. See LICENSE file or http://opensource.org/licenses/MIT
# Copyright (c) 2015-2018 Wilhelm Schürmann

function setup_cfg {
    # Configuration
    for i in data/*.data timewarrior.cfg; do
       if [ -f "$i" ]; then
           rm "$i" 2>&1 >/dev/null
       fi
    done

    export TIMEWARRIORDB=.

    #echo 'foo'  >> timewarrior.cfg
}

function find_timew_binary {
    # $bashtap_org_pwd is set in bash_tap.sh. It is the directory the parent script is
    # run from. Check for the timew binary relative to that directory.
    # Do not use the system "timew" if no local one is found, error out instead.
    for t in "${bashtap_org_pwd}/timew" "${bashtap_org_pwd}/src/timew" "${bashtap_org_pwd}/../timew" "${bashtap_org_pwd}/../src/timew" "${bashtap_org_pwd}/../build/src/timew"; do
        if [ -f "$t" ] && [ -x "$t" ]; then
            t_abs=$(bashtap_get_absolute_path "$t")
            eval "function timew { ${t_abs} \"\$@\"; }"
            return 0
        fi
    done

    echo "# ERROR: Could not find timew binary!"

    # Needed for normal, i.e. "non-test" mode.
    eval "function timew { exit; }"

    # Set $line so we can have useful TAP output.
    line="bash_tap.sh:find_timew_binary()"

    return 1
}

function bashtap_setup {
    # This function is called by bash_tap.sh before running tests, or before
    # running the parent script normally.
    find_timew_binary
    setup_cfg
}


# Include the base script that does the actual work.
source bash_tap.sh