Skip to content

Commit

Permalink
Update CI and avoid eval in _ispath.
Browse files Browse the repository at this point in the history
  • Loading branch information
rofinn committed Jul 15, 2019
1 parent 2f09ec9 commit 020b620
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
URIParser = "30578b45-9adc-5946-b283-645ec420af67"

[compat]
FilePathsBase = "0.5"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

Expand Down
12 changes: 12 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ platform:
- x86 # 32-bit
- x64 # 64-bit

## uncomment the following lines to allow failures on nightly julia
## (tests will run but not make your overall status red)
matrix:
allow_failures:
- julia_version: nightly

branches:
only:
- master
Expand All @@ -28,3 +34,9 @@ build_script:
test_script:
- echo "%JL_TEST_SCRIPT%"
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"

# Uncomment to support code coverage upload. Should only be enabled for packages
# which would have coverage gaps without running on Windows
on_success:
- echo "%JL_CODECOV_SCRIPT%"
- C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"
19 changes: 10 additions & 9 deletions src/compat.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
macro compat(ex)
new_ex = compat_exp(deepcopy(ex))
mod = @__MODULE__
new_ex = compat_exp(mod, deepcopy(ex))

return quote
$ex
$new_ex
end |> esc
end

function compat_exp(ex::Expr)
function compat_exp(mod::Module, ex::Expr)
fdef = splitdef(ex)
args = Symbol[]
kwargs = Expr[]
Expand All @@ -20,7 +21,7 @@ function compat_exp(ex::Expr)
for (i, p) in enumerate(fdef[:whereparams])
# If the param is a subtype of AbstracPath
# then we store the lookup symbol in the params array
if _ispath(p.args[2])
if _ispath(mod, p.args[2])
p.args[2] = :(Union{AbstractString, $(p.args[2])})
push!(params, p.args[1])
end
Expand All @@ -35,7 +36,7 @@ function compat_exp(ex::Expr)
T = a.args[1]
if T.args[2] in params
push!(convert_vars, T.args[1])
elseif _ispath(T.args[2])
elseif _ispath(mod, T.args[2])
T.args[2] = :(Union{AbstractString, $(T.args[2])})
push!(convert_vars, T.args[1])
end
Expand All @@ -44,7 +45,7 @@ function compat_exp(ex::Expr)
else
if a.args[2] in params
push!(convert_vars, a.args[1])
elseif _ispath(a.args[2])
elseif _ispath(mod, a.args[2])
a.args[2] = :(Union{AbstractString, $(a.args[2])})
push!(convert_vars, a.args[1])
end
Expand All @@ -64,7 +65,7 @@ function compat_exp(ex::Expr)
T = k.args[1]
if T.args[2] in params
push!(convert_vars, T.args[1])
elseif _ispath(T.args[2])
elseif _ispath(mod, T.args[2])
T.args[2] = :(Union{AbstractString, $(T.args[2])})
push!(convert_vars, T.args[1])
end
Expand All @@ -80,7 +81,7 @@ function compat_exp(ex::Expr)

push!(body, :(result = $(fdef[:name])($(args...); $(kwargs...))))

if haskey(fdef, :rtype) && (fdef[:rtype] in params || _ispath(fdef[:rtype]))
if haskey(fdef, :rtype) && (fdef[:rtype] in params || _ispath(mod, fdef[:rtype]))
push!(body, :(result = string(result)))
# push!(body, :(println(typeof(result))))
fdef[:rtype] = :String
Expand All @@ -93,7 +94,7 @@ function compat_exp(ex::Expr)
return MacroTools.combinedef(fdef)
end

function _ispath(t::Symbol)
T = eval(t)
function _ispath(mod::Module, t::Symbol)
T = getfield(mod, t)
return T <: AbstractPath
end

0 comments on commit 020b620

Please sign in to comment.