Skip to content

Commit

Permalink
Test method ambiguity
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Jan 3, 2019
1 parent 17287eb commit eb88ce0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/detect_ambiguities.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Test

_deps = quote
SparseArrays
LinearAlgebra
FillArrays
SIMD
end
deps = [x for x in _deps.args if x isa Symbol]
@debug "Loading dependencies:" deps
for m in deps
@eval using $m
end

modules = eval.(deps)
ambiguities = detect_ambiguities(modules..., imported=true, recursive=true)
if !isempty(ambiguities)
@error "Ambiguities found in dependencies." deps ambiguities
else
using SparseXX
@test detect_ambiguities(SparseXX, imported=true, recursive=true) == []
end
20 changes: 20 additions & 0 deletions test/test_ambiguity.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module TestAmbiguity
using Test

@testset "method ambiguity" begin
# Ambiguity test is run inside a clean process.
# https://github.com/JuliaLang/julia/issues/28804
script = joinpath(@__DIR__, "detect_ambiguities.jl")
code = """
$(Base.load_path_setup_code())
include($(repr(script)))
"""
cmd = Base.julia_cmd()
if Base.JLOptions().color == 1
cmd = `$cmd --color=yes`
end
cmd = `$cmd --startup-file=no -e $code`
@test success(pipeline(cmd; stdout=stdout, stderr=stderr))
end

end # module

0 comments on commit eb88ce0

Please sign in to comment.