Adds bash completion
Change-Id: I4d427cd89e20e62d6c197e3f098cf4b1502b373b
This commit is contained in:
parent
cc4847dfdf
commit
bb6e3d02fd
69
tools/cover.sh
Executable file
69
tools/cover.sh
Executable file
@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
ALLOWED_EXTRA_MISSING=0
|
||||
|
||||
show_diff () {
|
||||
head -1 $1
|
||||
diff -U 0 $1 $2 | sed 1,2d
|
||||
}
|
||||
|
||||
if ! git diff --exit-code || ! git diff --cached --exit-code
|
||||
then
|
||||
echo "There are uncommitted changes!"
|
||||
echo "Please clean git working directory and try again"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Checkout master and save coverage report
|
||||
git checkout HEAD^
|
||||
|
||||
baseline_report=$(mktemp -t gyanclient_coverageXXXXXXX)
|
||||
find . -type f -name "*.pyc" -delete && python setup.py testr --coverage --testr-args="$*"
|
||||
coverage report > $baseline_report
|
||||
mv cover cover-master
|
||||
cat $baseline_report
|
||||
baseline_missing=$(awk 'END { print $3 }' $baseline_report)
|
||||
|
||||
# Checkout back and save coverage report
|
||||
git checkout -
|
||||
|
||||
current_report=$(mktemp -t gyanclient_coverageXXXXXXX)
|
||||
find . -type f -name "*.pyc" -delete && python setup.py testr --coverage --testr-args="$*"
|
||||
coverage report > $current_report
|
||||
current_missing=$(awk 'END { print $3 }' $current_report)
|
||||
|
||||
# Show coverage details
|
||||
allowed_missing=$((baseline_missing+ALLOWED_EXTRA_MISSING))
|
||||
|
||||
echo "Allowed to introduce missing lines : ${ALLOWED_EXTRA_MISSING}"
|
||||
echo "Missing lines in master : ${baseline_missing}"
|
||||
echo "Missing lines in proposed change : ${current_missing}"
|
||||
|
||||
if [ $allowed_missing -ge $current_missing ]; then
|
||||
if [ $baseline_missing -lt $current_missing ]; then
|
||||
show_diff $baseline_report $current_report
|
||||
echo "We believe you can test your code with 100% coverage!"
|
||||
else
|
||||
echo "Thank you! You are awesome! Keep writing unit tests! :)"
|
||||
fi
|
||||
exit_code=0
|
||||
else
|
||||
show_diff $baseline_report $current_report
|
||||
echo "Please write more unit tests, we must maintain our test coverage :( "
|
||||
exit_code=1
|
||||
fi
|
||||
|
||||
rm $baseline_report $current_report
|
||||
exit $exit_code
|
16
tools/fast8.sh
Normal file
16
tools/fast8.sh
Normal file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd $(dirname "$0")/..
|
||||
CHANGED=$(git diff --name-only HEAD~1 | tr '\n' ' ')
|
||||
|
||||
# Skip files that don't exist
|
||||
# (have been git rm'd)
|
||||
CHECK=""
|
||||
for FILE in $CHANGED; do
|
||||
if [ -f "$FILE" ]; then
|
||||
CHECK="$CHECK $FILE"
|
||||
fi
|
||||
done
|
||||
|
||||
diff -u --from-file /dev/null $CHECK | flake8 --diff
|
||||
|
20
tools/flake8wrap.sh
Executable file
20
tools/flake8wrap.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# A simple wrapper around flake8 which makes it possible
|
||||
# to ask it to only verify files changed in the current
|
||||
# git HEAD patch.
|
||||
#
|
||||
# Intended to be invoked via tox:
|
||||
#
|
||||
# tox -epep8 -- -HEAD
|
||||
#
|
||||
|
||||
if test "x$1" = "x-HEAD" ; then
|
||||
shift
|
||||
files=$(git diff --name-only HEAD~1 | tr '\n' ' ')
|
||||
echo "Running flake8 on ${files}"
|
||||
diff -u --from-file /dev/null ${files} | flake8 --max-complexity 10 --diff "$@"
|
||||
else
|
||||
echo "Running flake8 on all files"
|
||||
exec flake8 --max-complexity 10 "$@"
|
||||
fi
|
3
tools/gen-config
Executable file
3
tools/gen-config
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
oslo-config-generator --config-file=tools/gyan-config-generator.conf
|
27
tools/gyan.bash_completion
Normal file
27
tools/gyan.bash_completion
Normal file
@ -0,0 +1,27 @@
|
||||
_gyan_opts="" # lazy init
|
||||
_gyan_flags="" # lazy init
|
||||
_gyan_opts_exp="" # lazy init
|
||||
_gyan()
|
||||
{
|
||||
local cur prev nbc cflags
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
if [ "x$_gyan_opts" == "x" ] ; then
|
||||
nbc="`gyan bash-completion | sed -e "s/ *-h */ /" -e "s/ *-i */ /"`"
|
||||
_gyan_opts="`echo "$nbc" | sed -e "s/--[a-z0-9_-]*//g" -e "s/ */ /g"`"
|
||||
_gyan_flags="`echo " $nbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/ */ /g"`"
|
||||
_gyan_opts_exp="`echo "$_gyan_opts" | tr ' ' '|'`"
|
||||
fi
|
||||
|
||||
if [[ " ${COMP_WORDS[@]} " =~ " "($_gyan_opts_exp)" " && "$prev" != "help" ]] ; then
|
||||
COMPLETION_CACHE=~/.gyanclient/*/*-cache
|
||||
cflags="$_gyan_flags "$(cat $COMPLETION_CACHE 2> /dev/null | tr '\n' ' ')
|
||||
COMPREPLY=($(compgen -W "${cflags}" -- ${cur}))
|
||||
else
|
||||
COMPREPLY=($(compgen -W "${_gyan_opts}" -- ${cur}))
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
complete -F _gyan gyan
|
29
tools/gyan.zsh_completion
Normal file
29
tools/gyan.zsh_completion
Normal file
@ -0,0 +1,29 @@
|
||||
#compdef gyan
|
||||
|
||||
local -a nbc _gyan_opts _gyan_flags _gyan_opts_exp cur prev
|
||||
|
||||
nbc=(${(ps: :)$(_call_program options "$service bash-completion" 2>/dev/null)})
|
||||
_gyan_opts=(${nbc:#-*})
|
||||
_gyan_flags=(${(M)nbc:#-*})
|
||||
_gyan_opt_exp=${${nbc:#-*}// /|}
|
||||
cur=$words[CURRENT]
|
||||
prev=$words[(( CURRENT - 1 ))]
|
||||
|
||||
_checkcomp(){
|
||||
for word in $words[@]; do
|
||||
if [[ -n ${_gyan_opts[(r)$word]} ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
echo $_gyan_opts[@] |grep --color gyan
|
||||
if [[ "$prev" != "help" ]] && _checkcomp; then
|
||||
COMPLETION_CACHE=(~/.gyanclient/*/*-cache)
|
||||
cflags=($_gyan_flags[@] ${(ps: :)$(cat $COMPLETION_CACHE 2>/dev/null)})
|
||||
compadd "$@" -d $cflags[@]
|
||||
else
|
||||
compadd "$@" -d $_gyan_opts[@]
|
||||
fi
|
||||
|
29
tools/run_functional.sh
Executable file
29
tools/run_functional.sh
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
FUNC_TEST_DIR=$(dirname $0)/../gyanclient/tests/functional/
|
||||
CONFIG_FILE=$FUNC_TEST_DIR/test.conf
|
||||
|
||||
if [[ -n "$OS_AUTH_TOKEN" ]] && [[ -n "$GYAN_URL" ]]; then
|
||||
cat <<END >$CONFIG_FILE
|
||||
[functional]
|
||||
api_version = 1
|
||||
auth_strategy=noauth
|
||||
os_auth_token=$OS_AUTH_TOKEN
|
||||
gyan_url=$GYAN_URL
|
||||
END
|
||||
else
|
||||
cat <<END >$CONFIG_FILE
|
||||
[functional]
|
||||
api_version = 1
|
||||
os_auth_url=$OS_AUTH_URL
|
||||
os_identity_api_version = $OS_IDENTITY_API_VERSION
|
||||
os_username=$OS_USERNAME
|
||||
os_password=$OS_PASSWORD
|
||||
os_project_name=$OS_PROJECT_NAME
|
||||
os_user_domain_id=$OS_USER_DOMAIN_ID
|
||||
os_project_domain_id=$OS_PROJECT_DOMAIN_ID
|
||||
os_service_type=container
|
||||
os_endpoint_type=public
|
||||
END
|
||||
fi
|
||||
tox -e functional -- --concurrency=1
|
Loading…
Reference in New Issue
Block a user