Skip to content

Commit 23fc627

Browse files
committed
Unbreak Julia 1.0
Version 0.4 got released claiming to support Julia 1.0 (the [compat] is `julia = "1"`) but 1.0 was dropped from CI. Unfortunately, not only doesn't the package run on 1.0, it doesn't even parse. This means that every package that wants to update their AbstractTrees dependency might try this [compat] AbstractTrees = "0.3, 0.4" and while this works fine on Julia 1.6, it breaks on Julia 1.0. Had AbstractTrees 0.4 merely declared incompatibility with Julia 1.0, the package manager would have handled everything for us---it would install AbstractTrees 0.3.x on Julia 1.0, and 0.4.x on 1.6 and higher. Now we are a bit stuck. One option is to see if General would accept a PR retrospectively making AbstractTrees 0.4 uninstallable on 1.0. The alternative is to provide at least minimal support for 1.0. I've taken that route here, but I'd be equally fine with the idea of making a PR to General.
1 parent 8970a89 commit 23fc627

File tree

9 files changed

+20
-10
lines changed

9 files changed

+20
-10
lines changed

Project.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
name = "AbstractTrees"
22
uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
3-
version = "0.4.1"
43
authors = ["Keno Fischer <[email protected]>"]
5-
6-
[deps]
4+
version = "0.4.2"
75

86
[compat]
97
julia = "1"

src/AbstractTrees.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ include("iteration.jl")
1919
include("builtins.jl")
2020
include("printing.jl")
2121

22+
# Julia 1.0 support (delete when we no longer support it)
23+
if !isdefined(Base, :isnothing)
24+
isnothing(x) = x === nothing
25+
end
26+
2227

2328
#interface
2429
export ParentLinks, StoredParents, ImplicitParents

src/base.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function is not available.
130130
Equivalence is established with the `equiv` function. Note that new methods should also define `equiv` or calls
131131
may fall back to the default method.
132132
"""
133-
isdescendant(node1, node2; equiv=()) = !equiv(node1, node2) && intree(node1, node2; equiv)
133+
isdescendant(node1, node2; equiv=()) = !equiv(node1, node2) && intree(node1, node2; equiv=equiv)
134134

135135

136136
"""

src/printing.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ function print_tree(printnode::Function, io::IO, node;
259259
end
260260

261261
print_tree(printnode, io, child;
262-
maxdepth, indicate_truncation, charset, printkeys,
263-
depth=depth+1, prefix=child_prefix
262+
maxdepth=maxdepth, indicate_truncation=indicate_truncation, charset=charset,
263+
printkeys=printkeys, depth=depth+1, prefix=child_prefix
264264
)
265265
end
266266
end

test/examples.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Ensure that we can run all files in the examples directory with no errors.
2+
# Note: fstree doesn't work on Julia 1.0
23

34
exampledir = joinpath(dirname(@__DIR__), "examples")
45
examples = readdir(exampledir)

test/examples/binarytree.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using AbstractTrees
22

3+
if !isdefined(Base, :isnothing) # Julia 1.0 support
4+
using AbstractTrees: isnothing
5+
end
36

47
mutable struct BinaryNode{T}
58
data::T

test/examples/fstree.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ AbstractTrees.printnode(io::IO, d::Directory) = print(io, basename(d.path))
2929
AbstractTrees.printnode(io::IO, f::File) = print(io, basename(f.path))
3030

3131
function mk_tree_test_dir(f, parentdir=tempdir(); prefix="jl_")
32-
mktempdir(parentdir; prefix) do path
32+
# While Julia 1.0 can parse this, `mktempdir` does not support the `prefix` kw
33+
mktempdir(parentdir; prefix=prefix) do path
3334
cd(path) do
3435
open(io -> write(io, "test1"), "f1"; write=true)
3536
mkdir("A")

test/runtests.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ using AbstractTrees, Test
33

44
@testset "Builtins" begin include("builtins.jl") end
55
@testset "Custom tree types" begin include("trees.jl") end
6-
@testset "Printing" begin include("printing.jl") end
7-
6+
if Base.VERSION >= v"1.6"
7+
# Printing tests use `findall` variants that are not supported on Julia 1.0
8+
@testset "Printing" begin include("printing.jl") end
9+
end

test/trees.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ end
8888
include(joinpath(@__DIR__,"examples","fstree.jl"))
8989

9090
@testset "FSNode" begin
91-
mk_tree_test_dir() do path
91+
Base.VERSION >= v"1.6" && mk_tree_test_dir() do path
9292
tree = Directory(".")
9393

9494
ls = nodevalue.((collect Leaves)(tree))

0 commit comments

Comments
 (0)