From 998410aa7133510e3eaae1c7dcfa9a13aedfdc3e Mon Sep 17 00:00:00 2001 From: Parag Nemade Date: May 25 2019 03:48:13 +0000 Subject: Update the ansible role from upstream Signed-off-by: Parag Nemade --- diff --git a/tests/roles/custom-test-fonts/files/run-family-test b/tests/roles/custom-test-fonts/files/run-family-test index 9b5cc2c..e87cad0 100755 --- a/tests/roles/custom-test-fonts/files/run-family-test +++ b/tests/roles/custom-test-fonts/files/run-family-test @@ -83,7 +83,8 @@ debug "Family: $OPT_FAMILY" debug "Lang: $OPT_LANG" debug "Artifacts dir: $OPT_ARTIFACTS_DIR" debug "Package name: $OPT_PACKAGE" -STR_TEST_DASHED=$(echo "$OPT_ALIAS" | sed -e 's/\//-/g' -e 's/ /-/g') +STR_TEST_DASHED=$(echo "${OPT_PACKAGE}_${OPT_ALIAS}" | sed -e 's/\//-/g' -e 's/ /-/g') +debug "Log file: $STR_TEST_DASHED.log" clean_exit() { rc=$?; diff --git a/tests/roles/custom-test-fonts/files/run-lang-coverage-test b/tests/roles/custom-test-fonts/files/run-lang-coverage-test index cc102b2..81fefa8 100755 --- a/tests/roles/custom-test-fonts/files/run-lang-coverage-test +++ b/tests/roles/custom-test-fonts/files/run-lang-coverage-test @@ -18,8 +18,10 @@ Options: -v, --verbose Turn on debug -l, --lang=LANG Test LANG language coverage (default: en) -p, --path=PATH Test fonts on PATH +-n, --name=NAME Set NAME to store a log file. -a, --artifactsdir=DIR test environment dir to store artifacts --i, --ignore=FILE Ignore FILE to check. +-e, --exclude=FILE Exclude FILE to check. +-i, --include=FILE Include File to check. _EOF_ } @@ -28,14 +30,24 @@ DEBUG="${DEBUG:-}" OPT_LANG="${OPT_LANG:-en}" OPT_PATH="${OPT_PATH:-}" OPT_ARTIFACTS_DIR="${OPT_ARTIFACTS_DIR:-}" -OPT_IGNORE=() +OPT_EXCLUDE=() +OPT_INCLUDE=() +OPT_NAME="${OPT_NAME:-}" -opt=$(getopt -n "$0" --options "hvl:p:t:a:i:" --longoptions "help,verbose,lang:,path:,test:,artifactsdir:,ignore:" -- "$@") +opt=$(getopt -n "$0" --options "hvl:p:n:a:e:i:" --longoptions "help,verbose,lang:,path:,name:,artifactsdir:,exclude:,include:" -- "$@") eval set -- "$opt" while [[ $# -gt 0 ]]; do case "$1" in - -i|--ignore) - OPT_IGNORE+=("$2") + -n|--name) + OPT_NAME="$2" + shift 2 + ;; + -i|--include) + OPT_INCLUDE+=("$2") + shift 2 + ;; + -e|--exclude) + OPT_EXCLUDE+=("$2") shift 2 ;; -a|--artifactsdir) @@ -72,11 +84,31 @@ if [ -z "$OPT_ARTIFACTS_DIR" ] || [ -z "$OPT_LANG" ] || [ -z "$OPT_PATH" ]; then exit 0 fi +expand_regex() { + local e ret=() + local path="$1" + shift + (cd $path; + for e; do + debug "$e" + set +f + local x=$(find -regextype posix-egrep -regex "./$e" -print|sed -e 's,^\./,,g') + ret+=($x) + set -f + echo ${ret[@]} + done) + echo ${ret[@]} +} + +OPT_INCLUDE=($(expand_regex $OPT_PATH ${OPT_INCLUDE[@]})) +OPT_EXCLUDE=($(expand_regex $OPT_PATH ${OPT_EXCLUDE[@]})) + debug "Path: $OPT_PATH" debug "Lang: $OPT_LANG" debug "Artifacts dir: $OPT_ARTIFACTS_DIR" -debug "Ignore: ${OPT_IGNORE[@]}" -STR_TEST_DASHED=$(echo "$OPT_PATH" | sed -e 's/\//-/g') +debug "Exclude: ${OPT_EXCLUDE[@]}" +debug "Include: ${OPT_INCLUDE[@]}" +STR_TEST_DASHED=$(echo "${OPT_NAME:-${OPT_LANG}_${OPT_PATH}}" | sed -e 's/\//-/g') clean_exit() { rc=$?; @@ -130,19 +162,29 @@ contains() { debug "Check language coverage" set +f -for i in `find $OPT_PATH -regex '.*/*\.\(t1\)?\(ttf\)?\(otf\)?\(ttc\)?'`; do - set -f - echo $i +for i in `find $OPT_PATH -regex '.*/*\.\(t1\)?\(ttf\)?\(otf\)?\(ttc\)?\(pcf.*\)?\(pfa\)?'`; do +set -f + debug "$i" if test -f $i; then n=`basename $i` set +e - contains "$n" "${OPT_IGNORE[@]}" + contains "$n" "${OPT_EXCLUDE[@]}" ret=$? set -e if [ $ret -eq 1 ]; then debug "ignoring $i" continue fi + if [ ${#OPT_INCLUDE[@]} -ne 0 ]; then + set +e + contains "$n" "${OPT_INCLUDE[@]}" + ret=$? + set -e + if [ $ret -eq 0 ]; then + debug "$i isn't targeted file" + continue + fi + fi debug " $i" res=`fc-validate -l $OPT_LANG $i` if echo $res | grep -q Missing; then diff --git a/tests/roles/custom-test-fonts/tasks/main.yml b/tests/roles/custom-test-fonts/tasks/main.yml index 2f5f799..981d3aa 100644 --- a/tests/roles/custom-test-fonts/tasks/main.yml +++ b/tests/roles/custom-test-fonts/tasks/main.yml @@ -2,10 +2,11 @@ - block: - name: language coverage - script: run-lang-coverage-test --lang "{{ item }}" --path "{{ path_prefix }}" --artifactsdir "{{ remote_artifacts }}" {{ "" if coverage.values is not defined or coverage[item].ignore is not defined else "--ignore " + (coverage[item].ignore | join('--ignore ')) }} + script: run-lang-coverage-test --lang "{{ item }}" --path "{{ path_prefix }}" --artifactsdir "{{ remote_artifacts }}" {{ "" if coverage.values is not defined or coverage[item].name is not defined else "--name " + coverage[item].name }} {{ "" if coverage.values is not defined or coverage[item].exclude is not defined else '--exclude "' + (coverage[item].exclude | join('" --exclude "')) + '"'}} {{ "" if coverage.values is not defined or coverage[item].include is not defined else '--include "' + (coverage[item].include | join('" --include "')) + '"'}} with_items: - "{{ coverage if coverage.keys is not defined else coverage.keys()|list }}" - name: generic family assignment + when: families is defined script: run-family-test --lang {{ item.lang }} --family '{{ item.family }}' --alias {{ item.alias }} --artifactsdir {{ remote_artifacts }} --package {{ package if item.package is not defined else item.package }} with_items: - "{{ families }}"