Skip to content

Commit

Permalink
Add a basic runtests.jl and update travis
Browse files Browse the repository at this point in the history
Fix for some deprecations.
  • Loading branch information
hayd committed Sep 25, 2015
1 parent f9be349 commit 622c07a
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 25 deletions.
24 changes: 12 additions & 12 deletions .travis.yml
@@ -1,13 +1,13 @@
language: cpp
compiler:
- clang
notifications:
email: false
before_install:
- sudo add-apt-repository ppa:staticfloat/julia-deps -y
- sudo add-apt-repository ppa:staticfloat/julianightlies -y
- sudo apt-get update -qq -y
- sudo apt-get install libpcre3-dev julia -y
language: julia
os:
- linux
- osx
julia:
- 0.3
- 0.4
- nightly
script:
- julia -e 'Pkg.init(); run(`ln -s $(pwd()) $(Pkg.dir("Autoreload"))`); Pkg.pin("Autoreload"); Pkg.resolve()'
- julia -e 'using Autoreload; @assert isdefined(:Autoreload); @assert typeof(Autoreload) === Module'
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
- julia --check-bounds=yes -e 'Pkg.clone(pwd()); Pkg.build("Autoreload"); Pkg.test("Autoreload"; coverage=true)'
after_success:
- julia -e 'cd(Pkg.dir("Autoreload")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder()); Codecov.submit(process_folder())'
8 changes: 4 additions & 4 deletions src/Autoreload.jl
Expand Up @@ -42,23 +42,23 @@ function remove_file(filename)
pop!(files, filename)
end

function arequire(filename=""; command= :on, depends_on=String[])
function arequire(filename=""; command= :on, depends_on=UTF8String[])
if isempty(filename)
return collect(keys(files))
end
original_filename = filename
filename = find_file(standarize(filename), constants=options[:constants])
filename == nothing && error("File $original_filename not found")
if command in [:on, :on_depends]
if filename in files
if filename in keys(files)
remove_file(filename)
end
if command == :on
should_reload = true
else
should_reload = false
end
files[filename] = AFile(should_reload, reload_mtime(filename), String[])
files[filename] = AFile(should_reload, reload_mtime(filename), UTF8String[])
parsed_file = parse_file(filename)
auto_depends = extract_deps(parsed_file)
auto_depends = [_.name for _ in auto_depends] #todo respect reload flag
Expand Down Expand Up @@ -153,7 +153,7 @@ function areload(command= :force; kwargs...)
dependencies = get_dependency_graph()
file_order = topological_sort(dependencies)
should_reload = [filename=>false for filename in file_order]
marked_for_mtime_update = String[]
marked_for_mtime_update = UTF8String[]
for (i, file) in enumerate(file_order)
file_time = files[file].mtime
if reload_mtime(file) > file_time
Expand Down
6 changes: 3 additions & 3 deletions src/constants.jl
@@ -1,15 +1,15 @@
type AFile
should_reload::Bool
mtime::Float64
deps::Vector{String}
deps::Vector{UTF8String}
end

type Dep
should_reload::Bool
name::String
name::UTF8String
end
suppress_warnings = false
const files = Dict{String,AFile}()
const files = Dict{UTF8String,AFile}()
const options = @compat Dict{Symbol,Any}(:constants=>false, :strip_types=>true, :smart_types=>true, :verbose_level=>:warn, :state=>:on)
# verbose_level = :warn
# state = :on
4 changes: 2 additions & 2 deletions src/dependencies.jl
Expand Up @@ -50,11 +50,11 @@ end
function _extract_deps(e::Expr, deps::Vector{Dep})
if e.head == :call
if e.args[1] == :include
if isa(e.args[2], String)
if isa(e.args[2], AbstractString)
push!(deps, Dep(false, e.args[2]))
end
# elseif e.args[1] == :require
# if isa(e.args[2], String)
# if isa(e.args[2], AbstractString)
# push!(deps, Dep(true, e.args[2]))
# end
end
Expand Down
2 changes: 1 addition & 1 deletion src/files.jl
@@ -1,4 +1,4 @@
function find_in_path(name::String; constants::Bool=true)
function find_in_path(name::AbstractString; constants::Bool=true)
isabspath(name) && return name
isfile(name) && return abspath(name)
base = name
Expand Down
6 changes: 3 additions & 3 deletions src/smart_types.jl
@@ -1,5 +1,5 @@
function should_symbol_recurse(var)
taboo = [Module, String, Dict, Array, Tuple, DataType, Function]
taboo = [Module, AbstractString, Dict, Array, Tuple, DataType, Function]
for datatype in taboo
if isa(var, datatype)
return false
Expand Down Expand Up @@ -120,7 +120,7 @@ function eval_includes(e_block)
e.head == :call &&
e.args[1] == :include
local f
if isa(e.args[2], String)
if isa(e.args[2], AbstractString)
f = e.args[2]
elseif isa(e.args[2], Expr)
try
Expand Down Expand Up @@ -286,7 +286,7 @@ function _collect_symbols(m, vars, depth)
end

function unsafe_alter_type!(x, T::DataType)
ptr = convert(Ptr{Uint64}, pointer_from_objref(x))
ptr = convert(Ptr{@compat UInt64}, pointer_from_objref(x))
ptr_array = pointer_to_array(ptr, 1)
ptr_array[1] = pointer_from_objref(T)
x
Expand Down
40 changes: 40 additions & 0 deletions test/runtests.jl
@@ -0,0 +1,40 @@
using Base.Test
using Autoreload

m1_before = """
module M
type MyType
x::Int
end
f(var::MyType) = 1
end
"""

m1_after = """
module M
type MyType
x::Int
end
f(var::MyType) = 2
end
"""

open(joinpath(dirname(@__FILE__), "M.jl"), "w") do f
write(f, m1_before)
end

using Autoreload
arequire("M")
my_var = M.MyType(5)
M.f(my_var)

open(joinpath(dirname(@__FILE__), "M.jl"), "w") do f
write(f, m1_after)
end

areload()
@test M.f(my_var) == 2

rm(joinpath(dirname(@__FILE__), "M.jl"))

0 comments on commit 622c07a

Please sign in to comment.