@@ -84,27 +84,87 @@ function reprexclude(exspecs::Vector{ExcludeSpec})
84
84
return string (" Aqua.ExcludeSpec[" , join (itemreprs, " , " ), " ]" )
85
85
end
86
86
87
- function _test_ambiguities (packages:: Vector{PkgId} ; broken:: Bool = false , kwargs... )
88
- num_ambiguities, strout, strerr = _find_ambiguities (packages; kwargs... )
87
+ function _test_ambiguities (
88
+ packages:: Vector{PkgId} ;
89
+ broken:: Bool = false ,
90
+ extension_combinations = :default ,
91
+ kwargs... ,
92
+ )
93
+ if extension_combinations == :default
94
+ extension_combinations = Vector{String}[]
95
+ push! (extension_combinations, String[])
96
+ @static if JULIA_HAS_EXTENSIONS
97
+ all_exts = String[]
98
+ for pkg in setdiff (packages, [PkgId (Base), PkgId (Core)])
99
+ exts, _, _ = get_extension_data_from_toml (pkg)
100
+ for e in keys (exts)
101
+ push! (extension_combinations, [e])
102
+ end
103
+ push! (extension_combinations, collect (keys (exts)))
104
+ append! (all_exts, collect (keys (exts)))
105
+ end
106
+ push! (extension_combinations, all_exts)
107
+ end
108
+ unique! (extension_combinations)
109
+ end
110
+ for extensions in extension_combinations
111
+ @info " Testing ambiguities with extensions: $extensions "
112
+ num_ambiguities, strout, strerr =
113
+ _find_ambiguities (packages; extensions = extensions, kwargs... )
89
114
90
- print (stderr , strerr)
91
- print (stdout , strout)
115
+ print (stderr , strerr)
116
+ print (stdout , strout)
92
117
93
- if broken
94
- @test_broken num_ambiguities == 0
95
- else
96
- @test num_ambiguities == 0
118
+ if broken
119
+ @test_broken num_ambiguities == 0
120
+ else
121
+ @test num_ambiguities == 0
122
+ end
97
123
end
124
+
98
125
end
99
126
100
127
function _find_ambiguities (
101
128
packages:: Vector{PkgId} ;
102
129
color:: Union{Bool,Nothing} = nothing ,
103
130
exclude:: AbstractVector = [],
131
+ extensions:: AbstractVector = [],
104
132
# Options to be passed to `Test.detect_ambiguities`:
105
133
detect_ambiguities_options... ,
106
134
)
135
+ packages = copy (packages)
136
+ extdeppackages = PkgId[]
137
+ @static if JULIA_HAS_EXTENSIONS
138
+ extensions = String .(extensions)
139
+ for ext in extensions
140
+ found = false
141
+ for pkg in setdiff (packages, [PkgId (Base), PkgId (Core)])
142
+ exts, weakdeps, deps = get_extension_data_from_toml (pkg)
143
+ if haskey (exts, ext)
144
+ found = true
145
+ extdeps = exts[ext] isa String ? [exts[ext]] : exts[ext]
146
+ for extdepname in extdeps
147
+ if haskey (deps, extdepname)
148
+ push! (extdeppackages, deps[extdepname])
149
+ elseif haskey (weakdeps, extdepname)
150
+ push! (extdeppackages, weakdeps[extdepname])
151
+ else
152
+ error (
153
+ " Extension $ext depends on $extdepname , but it is not found." ,
154
+ )
155
+ end
156
+ end
157
+ push! (packages, PkgId (Base. uuid5 (pkg. uuid, ext), ext))
158
+ break
159
+ end
160
+ end
161
+ found && continue
162
+ error (" Extension $ext is not found." )
163
+ end
164
+ end
165
+
107
166
packages_repr = reprpkgids (collect (packages))
167
+ extdeppackages_repr = reprpkgids (collect (extdeppackages))
108
168
options_repr = checked_repr ((; recursive = true , detect_ambiguities_options... ))
109
169
exclude_repr = reprexclude (normalize_and_check_exclude (exclude))
110
170
@@ -115,6 +175,7 @@ function _find_ambiguities(
115
175
using Aqua
116
176
Aqua.test_ambiguities_impl(
117
177
$packages_repr ,
178
+ $extdeppackages_repr ,
118
179
$options_repr ,
119
180
$exclude_repr ,
120
181
) || exit(1)
143
204
144
205
function reprpkgids (packages:: Vector{PkgId} )
145
206
packages_repr = sprint () do io
146
- println (io, ' [ ' )
207
+ println (io, " Base.PkgId[ " )
147
208
for pkg in packages
148
209
println (io, reprpkgid (pkg))
149
210
end
200
261
201
262
function test_ambiguities_impl (
202
263
packages:: Vector{PkgId} ,
264
+ extdeppackages:: Vector{PkgId} ,
203
265
options:: NamedTuple ,
204
266
exspecs:: Vector{ExcludeSpec} ,
205
267
)
268
+ deps = map (Base. require, extdeppackages)
206
269
modules = map (Base. require, packages)
207
270
@debug " Testing method ambiguities" modules
208
271
ambiguities = detect_ambiguities (modules... ; options... )
0 commit comments