@@ -38,7 +38,7 @@ envfile=/tmp/env
3838noclean=
3939
4040function help() {
41- cat << EOF
41+ cat << EOF
4242Usage: $0 [options] [testcase]
4343
4444-h: this help
@@ -54,103 +54,103 @@ EOF
5454}
5555
5656while getopts " nE:fSldnk:p:h:" o; do
57- case " ${o} " in
58- n)
59- noclean=true
60- ;;
61- E)
62- [[ -z ${KUBECONFIG:- " " } ]] && {
63- echo " need -k set first"
64- exit 1
65- }
66- passprofile=${OPTARG}
67- vars=$( pass ls pac/vars/${passprofile} )
68- [[ -n ${vars} ]] || { echo " could not detect vars in pac/vars/${passprofile} " ; }
69- pass show pac/vars/${passprofile} | sed -e ' /#/d' -e ' /^$/d' -e ' s/export //' -e ' /^KUBECONFIG=/d' > ${envfile}
70- echo KUBECONFIG=$KUBECONFIG >> /tmp/env
71- echo " /tmp/env has been generated"
72- exit 0
73- ;;
74- d)
75- debug=yes
76- ;;
77- S)
78- nosnazy=yes
79- ;;
80- l)
81- [[ -e ${cachedir} /last ]] || {
82- echo " no last tests to run"
83- exit 1
84- }
85- testcases=$( cat ${cachedir} /last)
86- ;;
87- k)
88- export KUBECONFIG=$HOME /.kube/config.${OPTARG}
89- ;;
90- p)
91- passprofile=${OPTARG}
92- vars=$( pass show pac/vars/${passprofile} )
93- if [[ -n ${vars} ]]; then
94- eval ${vars}
95- else
96- echo " could not detect vars in pac/vars/${passprofile} "
97- fi
98- ;;
99- f)
100- fzf=" yes"
101- ;;
102- h)
103- help
104- exit 0
105- ;;
106- * )
107- echo " Invalid option"
108- exit 1
109- ;;
110- esac
57+ case " ${o} " in
58+ n)
59+ noclean=true
60+ ;;
61+ E)
62+ [[ -z ${KUBECONFIG:- " " } ]] && {
63+ echo " need -k set first"
64+ exit 1
65+ }
66+ passprofile=${OPTARG}
67+ vars=$( pass ls pac/vars/${passprofile} )
68+ [[ -n ${vars} ]] || { echo " could not detect vars in pac/vars/${passprofile} " ; }
69+ pass show pac/vars/${passprofile} | sed -e ' /#/d' -e ' /^$/d' -e ' s/export //' -e ' /^KUBECONFIG=/d' > ${envfile}
70+ echo KUBECONFIG=$KUBECONFIG >> /tmp/env
71+ echo " /tmp/env has been generated"
72+ exit 0
73+ ;;
74+ d)
75+ debug=yes
76+ ;;
77+ S)
78+ nosnazy=yes
79+ ;;
80+ l)
81+ [[ -e ${cachedir} /last ]] || {
82+ echo " no last tests to run"
83+ exit 1
84+ }
85+ testcases=$( cat ${cachedir} /last)
86+ ;;
87+ k)
88+ export KUBECONFIG=$HOME /.kube/config.${OPTARG}
89+ ;;
90+ p)
91+ passprofile=${OPTARG}
92+ vars=$( pass show pac/vars/${passprofile} )
93+ if [[ -n ${vars} ]]; then
94+ eval ${vars}
95+ else
96+ echo " could not detect vars in pac/vars/${passprofile} "
97+ fi
98+ ;;
99+ f)
100+ fzf=" yes"
101+ ;;
102+ h)
103+ help
104+ exit 0
105+ ;;
106+ * )
107+ echo " Invalid option"
108+ exit 1
109+ ;;
110+ esac
111111done
112112shift $(( OPTIND - 1 ))
113113
114114[[ -n ${debug} ]] && {
115- env | grep " ^TEST_"
115+ env | grep " ^TEST_"
116116}
117117
118118initial_query=
119119[[ -n $* ]] && initial_query=(-q " $@ " )
120120cd $( git rev-parse --show-toplevel) /test || exit
121121if [[ -n ${testcases:- " " } ]]; then
122- echo " Reusing last run runs: ${testcases} "
122+ echo " Reusing last run runs: ${testcases} "
123123elif [[ -z ${fzf} ]]; then
124- testcases=$*
124+ testcases=$*
125125else
126- testcases=$( rg --no-line-number --no-filename --no-heading ' ^func (Test[^(]+)' -o | sed ' s/^func //' |
127- sort | env fzf -m -1 -0 ${initial_query[@]} )
128- [[ -z ${testcases} ]] && exit 0
129- newt=
130- for t in ${testcases} ; do
131- newt=" ${newt} ^${t} $"
132- done
133- testcases=${newt}
126+ testcases=$( rg --no-line-number --no-filename --no-heading ' ^func (Test[^(]+)' -o | sed ' s/^func //' |
127+ sort | env fzf -m -1 -0 " ${initial_query[@]} " )
128+ [[ -z ${testcases} ]] && exit 0
129+ newt=
130+ for t in ${testcases} ; do
131+ newt=" ${newt} ^${t} $"
132+ done
133+ testcases=${newt}
134134fi
135135
136136[[ -d ${cachedir} ]] || mkdir -p ${cachedir}
137137echo ${testcases} > ${cachedir} /last
138138
139139if [[ -z ${noclean} ]]; then
140- e2e-cleanups || true
140+ e2e-cleanups || true
141141else
142- export TEST_NOCLEANUP=true
142+ export TEST_NOCLEANUP=true
143143fi
144144
145145[[ -z ${nosnazy} ]] && { type -p snazy > /dev/null 2> /dev/null || nosnazy=yes; }
146146
147147for testcase in ${testcases} ; do
148- echo " Running ${testcase} "
149- make -f ../Makefile test-clean
150- cmd=(go test -v -tags e2e -count=1 -failfast -run " ${testcase} " )
151- if [[ -z ${nosnazy} ]]; then
152- " ${cmd[@]} " | snazy
153- else
154- " ${cmd[@]} "
155- fi
148+ echo " Running ${testcase} "
149+ make -f ../Makefile test-clean
150+ cmd=(go test -v -tags e2e -count=1 -failfast -run " ${testcase} " )
151+ if [[ -z ${nosnazy} ]]; then
152+ " ${cmd[@]} " | snazy
153+ else
154+ " ${cmd[@]} "
155+ fi
156156done
0 commit comments