Skip to content

Commit 3db7ccc

Browse files
authored
Distinguish between with-sanitizer and without-sanitizer dependencies (#458)
* Distinguish between with-sanitizer and without-sanitizer dependencies * More filter_platform tests * Correct code * Correct `sanitize` keyword
1 parent 3fa89b9 commit 3db7ccc

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Dependencies.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,10 @@ getname(x::AbstractDependency) = getname(getpkg(x))
267267
filter_platforms(deps::AbstractVector{<:AbstractDependency}, p::AbstractPlatform)
268268
269269
Filter the dependencies `deps` which are compatible with platform `p`.
270+
Here "compatible" includes whether and which sanitizer is enabled.
270271
"""
271272
filter_platforms(deps::AbstractVector{<:AbstractDependency}, p::AbstractPlatform) =
272-
[dep for dep in deps if any(x -> platforms_match(x, p), dep.platforms)]
273+
[dep for dep in deps if any(x -> platforms_match_with_sanitize(x, p), dep.platforms)]
273274

274275
# Wrapper around `Pkg.Types.registry_resolve!` which keeps the type of the
275276
# dependencies. TODO: improve this

test/dependencies.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,19 @@ end
120120
top_level_dep = RuntimeDependency(PackageSpec(; name = top_level_name); top_level=true)
121121
@test is_top_level_dependency(top_level_dep)
122122

123+
plat_nosan = Platform("x86_64", "linux")
124+
plat_msan = Platform("x86_64", "linux"; sanitize="memory")
125+
plat_asan = Platform("x86_64", "linux"; sanitize="address")
126+
dep_nosan = Dependency(name; platforms=[plat_nosan])
127+
dep_msan = Dependency(name; platforms=[plat_msan])
128+
dep_asan = Dependency(name; platforms=[plat_asan])
129+
dep_allsans = Dependency(name; platforms=[plat_nosan, plat_msan, plat_asan])
123130
@testset "Filter dependencies by platform" begin
124131
@test filter_platforms([dep, dep_buildver, dep_compat], Platform("x86_64", "linux"; cxxstring_abi="cxx03")) == [dep_compat]
125132
@test filter_platforms([dep, dep_buildver, dep_compat], Platform("x86_64", "macos")) == [dep, dep_compat]
133+
@test filter_platforms([dep_nosan, dep_msan, dep_asan, dep_allsans], plat_nosan) == [dep_nosan, dep_allsans]
134+
@test filter_platforms([dep_nosan, dep_msan, dep_asan, dep_allsans], plat_msan) == [dep_msan, dep_allsans]
135+
@test filter_platforms([dep_nosan, dep_msan, dep_asan, dep_allsans], plat_asan) == [dep_asan, dep_allsans]
126136
end
127137

128138
@testset "JSON (de)serialization" begin

0 commit comments

Comments
 (0)