• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CyberShadow / aconfmgr / 470

26 Mar 2024 06:13PM UTC coverage: 80.669% (-13.0%) from 93.672%
470

push

github

CyberShadow-Renovate
Update dependency paru to v20240326042315

0 of 1 new or added line in 1 file covered. (0.0%)

464 existing lines in 23 files now uncovered.

3209 of 3978 relevant lines covered (80.67%)

140.08 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.22
/test/t/lib-matrix-packages.bash
1
# Common code for package matrix tests.
2

3
package_kinds=(
2✔
4
        [1]=native
2✔
5
        [2]=foreign
2✔
6
)
2✔
7

8
package_kind_switch=(
2✔
9
        [1]=''
2✔
10
        [2]=' --foreign'
2✔
11
)
2✔
12

13
package_dependences=(
2✔
14
        [1]=orphan
2✔
15
        [2]=dependency
2✔
16
        [3]=explicit
2✔
17
)
2✔
18

19
function TestMatrixPackageSetup() {
20
        if ((${ACONFMGR_INTEGRATION:-0}))
2✔
21
        then
UNCOV
22
                TestNeedAUR
×
23
        fi
24

25
        LogEnter 'Expanding specs...\n'
2✔
26
        declare -ag specs
2✔
27
        # shellcheck disable=SC2191
28
        specs=("
2✔
29
                "ignored={0..2}"
2✔
30

2✔
31
                "s_present={0..1}"
2✔
32
                "s_kind={1..2}"
2✔
33
                "s_dependence={1..3}"
2✔
34

2✔
35
                "c_present={0..1}"
2✔
36
                "c_kind={1..2}"
2✔
37
        ")
2✔
38
        LogLeave 'Done (%s specs).\n' "$(Color G "${#specs[@]}")"
4✔
39

40
        LogEnter 'Filtering specs...\n'
2✔
41
        [[ -v BASH_XTRACEFD ]] && set +x
4✔
42
        local specs2=()
43
        local spec
×
44
        # shellcheck disable=SC2154
45
        for spec in "${specs[@]}"
×
46
        do
47
                local ignored s_present s_kind s_dependence c_present c_kind name
×
48
                eval "$spec"
×
49

50
                # Cull varying properties of absent packages
51
                [[ "$s_present" == 1 || ( "$s_dependence" == 1 ) ]] || continue
×
52

53
                # Installing foreign packages is not mocked yet
54
                if [[ "$c_kind" == 2 && ${ACONFMGR_INTEGRATION:-0} -eq 0 ]] ; then continue ; fi
×
55

56
                # Cull bad config: configurations should not both ignore and install a package
57
                if [[ "$c_present" != 0 && "$ignored" != 0 ]] ; then continue ; fi
×
58

59
                # Cull bad config: installing mismatched package kind
60
                if [[ "$s_present" == 0 && "$c_present" == 1 && "$s_kind" != "$c_kind" ]] ; then continue ; fi
×
61

62
                name="$ignored-$s_present$s_kind$s_dependence-$c_present$c_kind"
×
63

64
                specs2+=("$spec name=$name")
65
        done
66
        specs=("${specs2[@]}")
67
        unset specs2
×
68
        [[ -v BASH_XTRACEFD ]] && set -x
×
69
        LogLeave 'Done (%s specs).\n' "$(Color G "${#specs[@]}")"
4✔
70

71
        LogEnter 'Configuring packages...\n'
2✔
72
        # shellcheck disable=SC2154
73
        for spec in "${specs[@]}"
62✔
74
        do
75
                local ignored s_present s_kind s_dependence c_present c_kind name
62✔
76
                eval "$spec"
62✔
77

62✔
78
                local kind
62✔
79
                for kind in 1 2
186✔
80
                do
62✔
81
                        TestAddPackageFile "$name" /"$name"/kind "$kind"
186✔
82
                        TestCreatePackage "$name" "${package_kinds[$kind]}"
124✔
83
                done
62✔
84

62✔
85
                if ((s_present))
124✔
86
                then
87
                        TestInstallPackage "$name" "${package_kinds[$s_kind]}" "${package_dependences[$s_dependence]}"
48✔
88
                fi
89

90
                if ((ignored))
62✔
91
                then
UNCOV
92
                        TestAddConfig "$(printf 'IgnorePackage%s %q' \
×
93
                                                "${package_kind_switch[$ignored]}" "$name")"
64✔
94
                fi
95

96
                if ((c_present))
62✔
97
                then
UNCOV
98
                        TestAddConfig "$(printf 'AddPackage%s %q' \
×
99
                                                "${package_kind_switch[$c_kind]}" "$name")"
28✔
100
                fi
101

102
                for kind in 1 2
124✔
103
                do
104
                        if [[ "$kind" -ne "$c_kind" ]]
124✔
105
                        then
106
                                TestDeletePackage "$name" "${package_kinds[$kind]}"
62✔
107
                        fi
108
                done
109
        done
110
        LogLeave
2✔
111
}
112

113
# shellcheck disable=SC2030,SC2031
114
function TestMatrixPackageCheck() {
115
        local test_kind=$1
2✔
116

117
        local -a packages=()
4✔
118
        ( "$PACMAN" --query --quiet || true ) | mapfile -t packages
4✔
119
        local -A package_present
2✔
120
        local package
2✔
121
        for package in "${packages[@]}"
31✔
122
        do
123
                package_present[$package]=1
31✔
124
        done
125

126
        local spec
2✔
127
        for spec in "${specs[@]}"
62✔
128
        do
129
                local ignored s_present s_kind s_dependence c_present c_kind name
62✔
130
                eval "$spec"
62✔
131

62✔
132
                LogEnter '%s\n' "$name"
62✔
133

62✔
134
                local x_present x_kind
124✔
135
                if [[ "$test_kind" == apply ]]
124✔
136
                then
137
                        if ((c_present)) # In config
93✔
138
                        then
62✔
139
                                x_present=1
69✔
140
                                if ((s_present))
7✔
141
                                then
142
                                        # aconfmgr will currently not reinstall a package if its kind changes.
143
                                        x_kind=$s_kind
6✔
144
                                else
145
                                        x_kind=$c_kind
1✔
146
                                fi
147
                        elif ((s_dependence==1)) # Orphan
24✔
148
                        then
149
                                x_present=0
12✔
150
                        elif ((s_present && ignored && c_kind == ignored)) # On system, but ignored (and ignoring the right kind)
12✔
151
                        then
152
                                x_present=1
4✔
153
                                x_kind=$s_kind
4✔
154
                        elif ((s_present && s_dependence == 2)) # Dependency of pinned
8✔
155
                        then
156
                                x_present=1
4✔
157
                                x_kind=$s_kind
4✔
158
                        else
159
                                x_present=0
4✔
160
                        fi
161
                elif [[ "$test_kind" == roundtrip ]]
31✔
162
                then
163
                        if ((s_present && s_dependence > 1))
31✔
164
                        then
165
                                x_present=1
16✔
166
                                x_kind=$s_kind
16✔
167
                        else
168
                                x_present=0
15✔
169
                        fi
170
                else
171
                        false
×
172
                fi
173

174
                local r_present="${package_present[$name]:-0}"
62✔
175
                [[ "$r_present" == "$x_present" ]] || \
62✔
176
                        FatalError 'Wrong package installation state: expected %s, result %s\n' "$x_present" "$r_present"
×
177

178
                if (( r_present ))
62✔
179
                then
180
                        local r_kind
31✔
181
                        r_kind=$(cat /"$name"/kind)
62✔
182
                        [[ "$r_kind" == "$x_kind" ]] || \
31✔
183
                                FatalError 'Wrong package installation kind: expected %s, result %s\n' "$x_kind" "$r_kind"
×
184
                fi
185

186
                LogLeave 'OK!\n'
62✔
187
        done
188

189
        unset specs package_kinds package_kind_switch package_dependences
2✔
190
}
191

192
function TestMatrixPackageCheckApply() {
193
        TestMatrixPackageCheck apply
1✔
194
}
195

196
function TestMatrixPackageCheckRoundtrip() {
197
        TestMatrixPackageCheck roundtrip
1✔
198
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc