File: make_tests.zsh

package info (click to toggle)
zplug 2.4.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,068 kB
  • sloc: sh: 1,504; awk: 235; makefile: 26
file content (42 lines) | stat: -rw-r--r-- 954 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env zsh

local arg="$1" fp ans

for fp in "${arg:-$ZPLUG_ROOT}/base"/*/*.zsh
do
    local parent="${fp:h:t}"
    local child="${fp:t:r}"
    local test_file="${arg:-$ZPLUG_ROOT}/test/base/$parent/$child.t"

    # Check if already exists
    if [[ -f $test_file ]]; then
        echo -en "$test_file: is already exists. Overwrite? y/N: "
        read -q ans && echo
        if [[ ! ${(L)ans} =~ ^y(es)?$ ]]; then
            continue
        fi
    fi

    # Update
    rm -f "$test_file"
    cat "$fp" \
        | grep "^__zplug::$parent::$child" \
        | awk '
    {
        gsub(/\(\)/, "")
        gsub(/ {/, "")
        print "T_SUB \"" $0 "\" (("
        print "  # skip"
        print "))"
    }
    ' >> "$test_file"
done

for fp in "${arg:-$ZPLUG_ROOT}"/autoload/{commands,options,tags}/__*__
do
    local dir="${fp:h}"
    local file="${fp:t}"
    local name="${file:gs:_:}"

    touch "${arg:-$ZPLUG_ROOT}/test/$dir/$name.t"
done