Skip to content

Commit 5532270

Browse files
authored
cleanup testing (#462)
1. Re-enable commented-out test from #456 2. Use separate test-specific Project.toml to allow for test-specific compat (and remove compat shim) 3. Replace testing println with testsets
1 parent 9f1d51a commit 5532270

File tree

8 files changed

+105
-61
lines changed

8 files changed

+105
-61
lines changed

Project.toml

-15
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,10 @@ CodecZstd = "0.7"
4545
ConcurrentUtilities = "2"
4646
DataAPI = "1"
4747
EnumX = "1"
48-
FilePathsBase = "0.9"
4948
LoggingExtras = "0.4, 1"
5049
PooledArrays = "0.5, 1.0"
5150
SentinelArrays = "1"
5251
Tables = "1.1"
5352
TimeZones = "1"
5453
TranscodingStreams = "0.9.12"
5554
julia = "1.6"
56-
57-
[extras]
58-
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
59-
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
60-
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"
61-
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
62-
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
63-
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
64-
StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
65-
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
66-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
67-
68-
[targets]
69-
test = ["CategoricalArrays", "DataFrames", "FilePathsBase", "JSON3", "Random", "StructTypes", "TOML", "Test", "Sockets"]

src/ArrowTypes/Project.toml

-9
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,3 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
2626

2727
[compat]
2828
julia = "1.0"
29-
30-
[extras]
31-
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
32-
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
33-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
34-
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
35-
36-
[targets]
37-
test = ["Test", "Random", "Sockets", "UUIDs"]

src/ArrowTypes/test/Project.toml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
[deps]
19+
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
20+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
21+
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

test/Project.toml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
[deps]
18+
ArrowTypes = "31f734f8-188a-4ce0-8406-c8a06bd891cd"
19+
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
20+
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
21+
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
22+
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
23+
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"
24+
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
25+
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
26+
PooledArrays = "2dfb63ee-cc39-5dd5-95bd-886bf059d720"
27+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
28+
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
29+
StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
30+
SentinelArrays = "91c51154-3ec4-41a3-a24f-3f23e20d615c"
31+
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
32+
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"
33+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
34+
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
35+
36+
[compat]
37+
ArrowTypes = "2.2.2"
38+
CategoricalArrays = "0.10"
39+
DataAPI = "1"
40+
DataFrames = "1"
41+
FilePathsBase = "0.9"
42+
JSON3 = "1"
43+
PooledArrays = "1"
44+
StructTypes = "1"
45+
SentinelArrays = "1"
46+
Tables = "1"
47+
TimeZones = "1"

test/pyarrow_roundtrip.jl

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ include(joinpath(dirname(pathof(Arrow)), "../test/testtables.jl"))
2121

2222
for (nm, t, writekw, readkw, extratests) in testtables
2323
nm == "unions" && continue
24-
println("pyarrow roundtrip: $nm")
24+
@testset "pyarrow roundtrip: $nm" begin
2525
io = IOBuffer()
2626
Arrow.write(io, t; writekw...)
2727
seekstart(io)
@@ -36,7 +36,8 @@ for (nm, t, writekw, readkw, extratests) in testtables
3636
buf = sink.getvalue()
3737
jbytes = copy(reinterpret(UInt8, buf))
3838
tt = Arrow.Table(jbytes)
39-
println("pyarrow roundtrip w/ compression: $nm")
39+
end
40+
@testset "pyarrow roundtrip w/ compression: $nm" begin
4041
io = IOBuffer()
4142
Arrow.write(io, t; compress=((:lz4, :zstd)[rand(1:2)]), writekw...)
4243
seekstart(io)
@@ -51,6 +52,7 @@ for (nm, t, writekw, readkw, extratests) in testtables
5152
buf = sink.getvalue()
5253
jbytes = copy(reinterpret(UInt8, buf))
5354
tt = Arrow.Table(jbytes)
55+
end
5456
end
5557

5658
f1 = pa.field("f1", pa.float64(), true)
@@ -71,4 +73,4 @@ writer.write_batch(batch)
7173
writer.close()
7274
buf = sink.getvalue()
7375
jbytes = copy(reinterpret(UInt8, buf))
74-
tt = Arrow.Table(jbytes)
76+
tt = Arrow.Table(jbytes)

test/runtests.jl

+28-31
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
using Test, Arrow, ArrowTypes, Tables, Dates, PooledArrays, TimeZones, UUIDs, Sockets,
18-
CategoricalArrays, DataAPI, FilePathsBase, DataFrames
19-
using Random: randstring
20-
21-
# Compat shim for pre-julia 1.9
22-
if !@isdefined(pkgversion)
23-
using TOML
24-
function pkgversion(m::Module)
25-
toml = TOML.parsefile(joinpath(pkgdir(m), "Project.toml"))
26-
return VersionNumber(toml["version"])
27-
end
28-
end
17+
using Test
18+
using Arrow
19+
using ArrowTypes
20+
using Tables
21+
using Dates
22+
using PooledArrays
23+
using TimeZones
24+
using UUIDs
25+
using Sockets
26+
using CategoricalArrays
27+
using DataAPI
28+
using FilePathsBase
29+
using DataFrames
30+
import Random: randstring
2931

3032
include(joinpath(dirname(pathof(ArrowTypes)), "../test/tests.jl"))
3133
include(joinpath(dirname(pathof(Arrow)), "../test/testtables.jl"))
@@ -72,11 +74,12 @@ end # @testset "table append"
7274

7375
for file in readdir(joinpath(dirname(pathof(Arrow)), "../test/arrowjson"))
7476
jsonfile = joinpath(joinpath(dirname(pathof(Arrow)), "../test/arrowjson"), file)
75-
println("integration test for $jsonfile")
77+
@testset "integration test for $jsonfile" begin
7678
df = ArrowJSON.parsefile(jsonfile);
7779
io = Arrow.tobuffer(df)
7880
tbl = Arrow.Table(io; convert=false);
7981
@test isequal(df, tbl)
82+
end
8083
end
8184

8285
end # @testset "arrow json integration tests"
@@ -605,21 +608,15 @@ table = Arrow.Table(joinpath(@__DIR__, "old_zdt.arrow"))
605608
end
606609

607610
@testset "# 243" begin
608-
if pkgversion(ArrowTypes) >= v"2.0.1" # need the ArrowTypes bugfix to pass this test
609-
# https://github.com/apache/arrow-julia/issues/243
610-
table = (; col = [(; v=v"1"), (; v=v"2"), missing])
611-
@test isequal(Arrow.Table(Arrow.tobuffer(table)).col, table.col)
612-
end
611+
table = (; col = [(; v=v"1"), (; v=v"2"), missing])
612+
@test isequal(Arrow.Table(Arrow.tobuffer(table)).col, table.col)
613613
end
614614

615615
@testset "# 367" begin
616-
# https://github.com/apache/arrow-julia/issues/367
617-
if pkgversion(ArrowTypes) >= v"2.0.2"
618-
t = (; x=Union{ZonedDateTime,Missing}[missing])
619-
a = Arrow.Table(Arrow.tobuffer(t))
620-
@test Tables.schema(a) == Tables.schema(t)
621-
@test isequal(a.x, t.x)
622-
end
616+
t = (; x=Union{ZonedDateTime,Missing}[missing])
617+
a = Arrow.Table(Arrow.tobuffer(t))
618+
@test Tables.schema(a) == Tables.schema(t)
619+
@test isequal(a.x, t.x)
623620
end
624621

625622
# https://github.com/apache/arrow-julia/issues/414
@@ -707,14 +704,14 @@ t = Arrow.Table(buf)
707704

708705
end
709706

710-
# @testset "# 456" begin
707+
@testset "# 456" begin
711708

712-
# NT = @NamedTuple{x::Int, y::Union{Missing,Int}}
713-
# data = NT[(x=1,y=2), (x=2,y=missing), (x=3,y=4), (x=4,y=5)]
714-
# t = [(a=1,b=view(data,1:2)), (a=2,b=view(data,3:4)), missing]
715-
# @test Arrow.toarrowvector(t) isa Arrow.Struct
709+
NT = @NamedTuple{x::Int, y::Union{Missing,Int}}
710+
data = NT[(x=1,y=2), (x=2,y=missing), (x=3,y=4), (x=4,y=5)]
711+
t = [(a=1,b=view(data,1:2)), (a=2,b=view(data,3:4)), missing]
712+
@test Arrow.toarrowvector(t) isa Arrow.Struct
716713

717-
# end
714+
end
718715

719716
end # @testset "misc"
720717

test/testappend.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# under the License.
1717

1818
function testappend(nm, t, writekw, readkw, extratests)
19-
println("testing append: $nm")
19+
@testset "append: $nm" begin
2020
io = Arrow.tobuffer(t; writekw...)
2121
bytes = read(io)
2222
mktemp() do path, io
@@ -33,6 +33,7 @@ function testappend(nm, t, writekw, readkw, extratests)
3333
end
3434
@test nparts == 2
3535
end
36+
end
3637
end
3738

3839
function testappend_compression(compression_option)

test/testtables.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ testtables = [
220220
];
221221

222222
function testtable(nm, t, writekw, readkw, extratests)
223-
println("testing: $nm")
223+
@testset "testing: $nm" begin
224224
io = Arrow.tobuffer(t; writekw...)
225225
tt = Arrow.Table(io; readkw...)
226226
@test length(tt) == length(t)
@@ -253,5 +253,5 @@ function testtable(nm, t, writekw, readkw, extratests)
253253
tt = first(str)
254254
@test length(tt) == length(t)
255255
@test all(isequal.(values(t), values(tt)))
256-
return
256+
end
257257
end

0 commit comments

Comments
 (0)