|
|
|
@ -6,7 +6,7 @@ set -eu
|
|
|
|
|
verbosity=0
|
|
|
|
|
|
|
|
|
|
# default to silent output for naked grep; -vvv+ will adjust this
|
|
|
|
|
export GREP_OPTS=-q
|
|
|
|
|
GREP_OPTS=(-q)
|
|
|
|
|
|
|
|
|
|
# shell tracing output is very large from this script; only enable if >= -vvv was passed
|
|
|
|
|
while getopts :v opt
|
|
|
|
@ -18,17 +18,17 @@ done
|
|
|
|
|
|
|
|
|
|
if (( verbosity >= 3 ));
|
|
|
|
|
then
|
|
|
|
|
set -x;
|
|
|
|
|
export GREP_OPTS= ;
|
|
|
|
|
set -x
|
|
|
|
|
GREP_OPTS=()
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "running playbook-backed docs tests"
|
|
|
|
|
ansible-playbook test.yml -i inventory "$@"
|
|
|
|
|
|
|
|
|
|
# test keyword docs
|
|
|
|
|
ansible-doc -t keyword -l | grep $GREP_OPTS 'vars_prompt: list of variables to prompt for.'
|
|
|
|
|
ansible-doc -t keyword vars_prompt | grep $GREP_OPTS 'description: list of variables to prompt for.'
|
|
|
|
|
ansible-doc -t keyword asldkfjaslidfhals 2>&1 | grep $GREP_OPTS 'Skipping Invalid keyword'
|
|
|
|
|
ansible-doc -t keyword -l | grep "${GREP_OPTS[@]}" 'vars_prompt: list of variables to prompt for.'
|
|
|
|
|
ansible-doc -t keyword vars_prompt | grep "${GREP_OPTS[@]}" 'description: list of variables to prompt for.'
|
|
|
|
|
ansible-doc -t keyword asldkfjaslidfhals 2>&1 | grep "${GREP_OPTS[@]}" 'Skipping Invalid keyword'
|
|
|
|
|
|
|
|
|
|
# collections testing
|
|
|
|
|
(
|
|
|
|
@ -55,10 +55,10 @@ expected_out="$(sed '1 s/\(^> TESTNS\.TESTCOL\.YOLO\).*(.*)$/\1/' yolo-text.outp
|
|
|
|
|
test "$current_out" == "$expected_out"
|
|
|
|
|
|
|
|
|
|
echo "ensure we do work with valid collection name for list"
|
|
|
|
|
ansible-doc --list testns.testcol --playbook-dir ./ 2>&1 | grep $GREP_OPTS -v "Invalid collection name"
|
|
|
|
|
ansible-doc --list testns.testcol --playbook-dir ./ 2>&1 | grep "${GREP_OPTS[@]}" -v "Invalid collection name"
|
|
|
|
|
|
|
|
|
|
echo "ensure we dont break on invalid collection name for list"
|
|
|
|
|
ansible-doc --list testns.testcol.fakemodule --playbook-dir ./ 2>&1 | grep $GREP_OPTS "Invalid collection name"
|
|
|
|
|
ansible-doc --list testns.testcol.fakemodule --playbook-dir ./ 2>&1 | grep "${GREP_OPTS[@]}" "Invalid collection name"
|
|
|
|
|
|
|
|
|
|
echo "filter list with more than one collection (1/2)"
|
|
|
|
|
output=$(ansible-doc --list testns.testcol3 testns.testcol4 --playbook-dir ./ 2>&1 | wc -l)
|
|
|
|
@ -96,12 +96,12 @@ do
|
|
|
|
|
list_result=$(ansible-doc -l -t ${ptype} --playbook-dir ./ testns.testcol)
|
|
|
|
|
metadata_result=$(ansible-doc --metadata-dump --no-fail-on-errors -t ${ptype} --playbook-dir ./ testns.testcol)
|
|
|
|
|
for name in "${expected_names[@]}"; do
|
|
|
|
|
echo "${list_result}" | grep $GREP_OPTS "testns.testcol.${name}"
|
|
|
|
|
echo "${metadata_result}" | grep $GREP_OPTS "testns.testcol.${name}"
|
|
|
|
|
echo "${list_result}" | grep "${GREP_OPTS[@]}" "testns.testcol.${name}"
|
|
|
|
|
echo "${metadata_result}" | grep "${GREP_OPTS[@]}" "testns.testcol.${name}"
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# ensure we get error if passing invalid collection, much less any plugins
|
|
|
|
|
ansible-doc -l -t ${ptype} bogus.boguscoll 2>&1 | grep $GREP_OPTS "unable to locate collection"
|
|
|
|
|
ansible-doc -l -t ${ptype} bogus.boguscoll 2>&1 | grep "${GREP_OPTS[@]}" "unable to locate collection"
|
|
|
|
|
|
|
|
|
|
# TODO: do we want per namespace?
|
|
|
|
|
# ensure we get 1 plugins when restricting namespace
|
|
|
|
@ -230,7 +230,7 @@ echo "testing sidecar docs for jinja plugins"
|
|
|
|
|
[ "$(ansible-doc -t filter --playbook-dir ./ ansible.legacy.donothing| wc -l)" -gt "0" ]
|
|
|
|
|
|
|
|
|
|
echo "testing no docs and no sidecar"
|
|
|
|
|
ansible-doc -t filter --playbook-dir ./ nodocs 2>&1| grep $GREP_OPTS -c 'missing documentation' || true
|
|
|
|
|
ansible-doc -t filter --playbook-dir ./ nodocs 2>&1| grep "${GREP_OPTS[@]}" -c 'missing documentation' || true
|
|
|
|
|
|
|
|
|
|
echo "testing sidecar docs for module"
|
|
|
|
|
[ "$(ansible-doc -M ./library test_win_module| wc -l)" -gt "0" ]
|
|
|
|
@ -249,7 +249,7 @@ echo "testing no duplicates for plugins that only exist in ansible.builtin when
|
|
|
|
|
[ "$(ansible-doc -l -t filter --playbook-dir ./ |grep -c 'b64encode')" -eq "1" ]
|
|
|
|
|
|
|
|
|
|
echo "testing with playbook dir, legacy should override"
|
|
|
|
|
ansible-doc -t filter split --playbook-dir ./ |grep $GREP_OPTS histerical
|
|
|
|
|
ansible-doc -t filter split --playbook-dir ./ |grep "${GREP_OPTS[@]}" histerical
|
|
|
|
|
|
|
|
|
|
pyc_src="$(pwd)/filter_plugins/other.py"
|
|
|
|
|
pyc_1="$(pwd)/filter_plugins/split.pyc"
|
|
|
|
@ -258,11 +258,11 @@ trap 'rm -rf "$pyc_1" "$pyc_2"' EXIT
|
|
|
|
|
|
|
|
|
|
echo "testing pyc files are not used as adjacent documentation"
|
|
|
|
|
python -c "import py_compile; py_compile.compile('$pyc_src', cfile='$pyc_1')"
|
|
|
|
|
ansible-doc -t filter split --playbook-dir ./ |grep $GREP_OPTS histerical
|
|
|
|
|
ansible-doc -t filter split --playbook-dir ./ |grep "${GREP_OPTS[@]}" histerical
|
|
|
|
|
|
|
|
|
|
echo "testing pyc files are not listed as plugins"
|
|
|
|
|
python -c "import py_compile; py_compile.compile('$pyc_src', cfile='$pyc_2')"
|
|
|
|
|
test "$(ansible-doc -l -t module --playbook-dir ./ 2>&1 1>/dev/null |grep -c "notaplugin")" == 0
|
|
|
|
|
|
|
|
|
|
echo "testing without playbook dir, builtin should return"
|
|
|
|
|
ansible-doc -t filter split 2>&1 |grep $GREP_OPTS -v histerical
|
|
|
|
|
ansible-doc -t filter split 2>&1 |grep "${GREP_OPTS[@]}" -v histerical
|
|
|
|
|