| 1 | #!/usr/bin/env bash |
| 2 | # Run test with different package options. |
| 3 | |
| 4 | # SPDX-FileCopyrightText: 2015-2023 Robin Schneider <[email protected]> |
| 5 | # |
| 6 | # SPDX-License-Identifier: AGPL-3.0-or-later |
| 7 | |
| 8 | function containsElement() { |
| 9 | local e match="$1" |
| 10 | shift |
| 11 | for e; do [[ "$e" == "$match" ]] && return 0; done |
| 12 | return 1 |
| 13 | } |
| 14 | |
| 15 | function main() { |
| 16 | test_only_those_options=( "$@" ) |
| 17 | |
| 18 | supported_licenses="$(grep '.*&.*&.*@nameuse{doclicense@lang' ./doclicense.dtx | sed 's/.*doclicense@lang@lic@\([^@]\+\)@\([^@]\+\)@\([^]]\+\)}.*/\1 \2 \3/' | sort -u)" |
| 19 | |
| 20 | echo "$supported_licenses" | \ |
| 21 | while read -r type modifier version; do |
| 22 | for imagemodifier in "" "-eu" "-80x15"; do |
| 23 | for lang in "ngerman" "english" "brazilian" "spanish" "french" "russian" "italian" "polish" "portuguese" "catalan" "galician" "croatian" "swedish" "esperanto" "ukrainian" "austrian" "naustrian" "swissgerman" "nswissgerman" "greek"; do |
| 24 | if [ "$lang" == "ngerman" ] && [ "$modifier" == "pd" ]; then |
| 25 | continue # Does not exist in Germany. |
| 26 | fi |
| 27 | if [ "$lang" == "ngerman" ] && [ "$modifier" == "pd" ]; then |
| 28 | continue # Does not exist in Germany. |
| 29 | fi |
| 30 | if [ "$imagemodifier" == "-eu" ] && [[ "$modifier" != *-nc-* ]]; then |
| 31 | continue # eu (Euro) does only exist for nc (non commercial). |
| 32 | fi |
| 33 | if [[ ${#test_only_those_options[@]} != 0 ]] && \ |
| 34 | ! containsElement "$lang" "${test_only_those_options[@]}"; then |
| 35 | |
| 36 | continue |
| 37 | fi |
| 38 | |
| 39 | ( |
| 40 | |
| 41 | echo " |
| 42 | \documentclass[$lang]{article} |
| 43 | \usepackage{ |
| 44 | iftex, |
| 45 | } |
| 46 | |
| 47 | \ifPDFTeX% |
| 48 | \usepackage[utf8]{inputenc} |
| 49 | \usepackage[T1]{fontenc} |
| 50 | \usepackage{babel} |
| 51 | \fi |
| 52 | \ifLuaTeX% |
| 53 | \usepackage{ |
| 54 | fontspec, |
| 55 | polyglossia, |
| 56 | } |
| 57 | \fi |
| 58 | |
| 59 | \usepackage{ |
| 60 | hyperref, |
| 61 | hyperxmp, |
| 62 | } |
| 63 | \ifLuaTeX% |
| 64 | \setdefaultlanguage{$lang} |
| 65 | \fi |
| 66 | \usepackage[ |
| 67 | type={$type}, |
| 68 | modifier={$modifier}, |
| 69 | version={$version}," |
| 70 | if [ "$imagemodifier" != "" ]; then |
| 71 | echo " imagemodifier={$imagemodifier},% chktex 29" |
| 72 | fi |
| 73 | echo " ]{doclicense} |
| 74 | \begin{document} |
| 75 | doclicenseType |
| 76 | \doclicenseType% |
| 77 | |
| 78 | doclicenseLongType |
| 79 | \doclicenseLongType% |
| 80 | |
| 81 | doclicenseModifier |
| 82 | \doclicenseModifier% |
| 83 | |
| 84 | doclicenseVersion |
| 85 | \doclicenseVersion% |
| 86 | |
| 87 | doclicenseURL |
| 88 | \doclicenseURL% |
| 89 | |
| 90 | doclicenseName |
| 91 | \doclicenseName% |
| 92 | |
| 93 | doclicenseLongName |
| 94 | \doclicenseLongName% |
| 95 | |
| 96 | doclicenseNameRef |
| 97 | \doclicenseNameRef% |
| 98 | |
| 99 | doclicenseLongNameRef |
| 100 | \doclicenseLongNameRef% |
| 101 | |
| 102 | doclicenseText |
| 103 | \doclicenseText% |
| 104 | |
| 105 | doclicenseLongText |
| 106 | \doclicenseLongText% |
| 107 | |
| 108 | doclicenseIcon |
| 109 | \doclicenseIcon% |
| 110 | |
| 111 | doclicenseTypeIcon |
| 112 | \doclicenseTypeIcon% |
| 113 | |
| 114 | doclicenseImage |
| 115 | \doclicenseImage% |
| 116 | |
| 117 | doclicenseImageFileName |
| 118 | \doclicenseImageFileName% |
| 119 | |
| 120 | doclicenseThis |
| 121 | \doclicenseThis% |
| 122 | |
| 123 | doclicensePlainFullText |
| 124 | \doclicensePlainFullText% |
| 125 | |
| 126 | doclicenseFullText |
| 127 | \doclicenseFullText% |
| 128 | \end{document}" |
| 129 | |
| 130 | ) > testing.tex |
| 131 | |
| 132 | echo "*** Testing variant: $lang $type $modifier $version $imagemodifier" |
| 133 | |
| 134 | # latexmk -c |
| 135 | rm -f testing.aux testing.log testing.out testing.pdf |
| 136 | |
| 137 | texfot pdflatex -no-shell-escape -interaction=nonstopmode -halt-on-error testing.tex | egrep --invert-match 'Overfull|Underfull' |
| 138 | done |
| 139 | done |
| 140 | done |
| 141 | } |
| 142 | |
| 143 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]] |
| 144 | then |
| 145 | PS4='+ $(date --rfc-3339=seconds), ${BASH_SOURCE-}:${LINENO-}: ' |
| 146 | export PS4 |
| 147 | trap 'echo Encountered an unexpected error. Exiting with exit code $? in ${BASH_SOURCE-}:${LINENO-}. >&2' ERR |
| 148 | set -o nounset -o pipefail -o errexit -o errtrace |
| 149 | |
| 150 | main "$@" |
| 151 | fi |