Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Dependencies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,10 @@ getname(x::AbstractDependency) = getname(getpkg(x))
filter_platforms(deps::AbstractVector{<:AbstractDependency}, p::AbstractPlatform)

Filter the dependencies `deps` which are compatible with platform `p`.
Here "compatible" includes whether and which sanitizer is enabled.
"""
filter_platforms(deps::AbstractVector{<:AbstractDependency}, p::AbstractPlatform) =
[dep for dep in deps if any(x -> platforms_match(x, p), dep.platforms)]
[dep for dep in deps if any(x -> platforms_match_with_sanitize(x, p), dep.platforms)]

# Wrapper around `Pkg.Types.registry_resolve!` which keeps the type of the
# dependencies. TODO: improve this
Expand Down
10 changes: 10 additions & 0 deletions test/dependencies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,19 @@ end
top_level_dep = RuntimeDependency(PackageSpec(; name = top_level_name); top_level=true)
@test is_top_level_dependency(top_level_dep)

plat_nosan = Platform("x86_64", "linux")
plat_msan = Platform("x86_64", "linux"; sanitize="memory")
plat_asan = Platform("x86_64", "linux"; sanitize="address")
dep_nosan = Dependency(name; platforms=[plat_nosan])
dep_msan = Dependency(name; platforms=[plat_msan])
dep_asan = Dependency(name; platforms=[plat_asan])
dep_allsans = Dependency(name; platforms=[plat_nosan, plat_msan, plat_asan])
@testset "Filter dependencies by platform" begin
@test filter_platforms([dep, dep_buildver, dep_compat], Platform("x86_64", "linux"; cxxstring_abi="cxx03")) == [dep_compat]
@test filter_platforms([dep, dep_buildver, dep_compat], Platform("x86_64", "macos")) == [dep, dep_compat]
@test filter_platforms([dep_nosan, dep_msan, dep_asan, dep_allsans], plat_nosan) == [dep_nosan, dep_allsans]
@test filter_platforms([dep_nosan, dep_msan, dep_asan, dep_allsans], plat_msan) == [dep_msan, dep_allsans]
@test filter_platforms([dep_nosan, dep_msan, dep_asan, dep_allsans], plat_asan) == [dep_asan, dep_allsans]
Comment on lines +123 to +135
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

end

@testset "JSON (de)serialization" begin
Expand Down