summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/doclicense/test-package-option-matrix
blob: 7b110b005c3ec802fc7f7f3972734ab5ab698cd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env bash
# Run test with different package options.

# SPDX-FileCopyrightText: 2015-2023 Robin Schneider <ypid@riseup.net>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

function containsElement() {
    local e match="$1"
    shift
    for e; do [[ "$e" == "$match" ]] && return 0; done
    return 1
}

function main() {
    test_only_those_options=( "$@" )

    supported_licenses="$(grep '.*&.*&.*@nameuse{doclicense@lang' ./doclicense.dtx | sed 's/.*doclicense@lang@lic@\([^@]\+\)@\([^@]\+\)@\([^]]\+\)}.*/\1 \2 \3/' | sort -u)"

    echo "$supported_licenses" | \
        while read -r type modifier version; do
        for imagemodifier in "" "-eu" "-80x15"; do
            for lang in "ngerman" "english" "brazilian" "spanish" "french" "russian" "italian" "polish" "portuguese" "catalan" "galician" "croatian" "swedish" "esperanto" "ukrainian" "austrian" "naustrian" "swissgerman" "nswissgerman" "greek"; do
                if [ "$lang" == "ngerman" ] && [ "$modifier" == "pd" ]; then
                    continue # Does not exist in Germany.
                fi
                if [ "$lang" == "ngerman" ] && [ "$modifier" == "pd" ]; then
                    continue # Does not exist in Germany.
                fi
                if [ "$imagemodifier" == "-eu" ] && [[ "$modifier" != *-nc-* ]]; then
                    continue # eu (Euro) does only exist for nc (non commercial).
                fi
                if [[ ${#test_only_those_options[@]} != 0 ]] && \
                    ! containsElement "$lang" "${test_only_those_options[@]}"; then

                    continue
                fi

                (

                echo "
                    \documentclass[$lang]{article}
                    \usepackage{
                      iftex,
                    }

                    \ifPDFTeX%
                      \usepackage[utf8]{inputenc}
                      \usepackage[T1]{fontenc}
                      \usepackage{babel}
                    \fi
                    \ifLuaTeX%
                      \usepackage{
                        fontspec,
                        polyglossia,
                      }
                    \fi

                    \usepackage{
                        hyperref,
                        hyperxmp,
                    }
                    \ifLuaTeX%
                      \setdefaultlanguage{$lang}
                    \fi
                    \usepackage[
                        type={$type},
                        modifier={$modifier},
                        version={$version},"
                if [ "$imagemodifier" != "" ]; then
                    echo "                    imagemodifier={$imagemodifier},% chktex 29"
                fi
                echo "                ]{doclicense}
                    \begin{document}
                    doclicenseType
                    \doclicenseType%

                    doclicenseLongType
                    \doclicenseLongType%

                    doclicenseModifier
                    \doclicenseModifier%

                    doclicenseVersion
                    \doclicenseVersion%

                    doclicenseURL
                    \doclicenseURL%

                    doclicenseName
                    \doclicenseName%

                    doclicenseLongName
                    \doclicenseLongName%

                    doclicenseNameRef
                    \doclicenseNameRef%

                    doclicenseLongNameRef
                    \doclicenseLongNameRef%

                    doclicenseText
                    \doclicenseText%

                    doclicenseLongText
                    \doclicenseLongText%

                    doclicenseIcon
                    \doclicenseIcon%

                    doclicenseTypeIcon
                    \doclicenseTypeIcon%

                    doclicenseImage
                    \doclicenseImage%

                    doclicenseImageFileName
                    \doclicenseImageFileName%

                    doclicenseThis
                    \doclicenseThis%

                    doclicensePlainFullText
                    \doclicensePlainFullText%

                    doclicenseFullText
                    \doclicenseFullText%
                    \end{document}"

                ) > testing.tex

                echo "*** Testing variant: $lang $type $modifier $version $imagemodifier"

                # latexmk -c
                rm -f testing.aux testing.log testing.out testing.pdf

                texfot pdflatex -no-shell-escape -interaction=nonstopmode -halt-on-error testing.tex | egrep --invert-match 'Overfull|Underfull'
            done
        done
    done
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]
then
    PS4='+ $(date --rfc-3339=seconds), ${BASH_SOURCE-}:${LINENO-}: '
    export PS4
    trap 'echo Encountered an unexpected error. Exiting with exit code $? in ${BASH_SOURCE-}:${LINENO-}. >&2' ERR
    set -o nounset -o pipefail -o errexit -o errtrace

    main "$@"
fi