Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use TestFunctionRunner #28

Merged
merged 12 commits into from
Jan 30, 2022
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ julia = "1"
[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestFunctionRunner = "792026f5-ac9a-4a19-adcb-47b0ce2deb5d"

[targets]
test = ["Aqua", "Test"]
test = ["Aqua", "Test", "TestFunctionRunner"]
15 changes: 15 additions & 0 deletions test/UnionArraysCUDATests/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name = "UnionArraysCUDATests"
uuid = "8106f4ae-0388-4bd1-9e3f-399fe7ea23bc"
authors = ["Takafumi Arakaki <aka.tkf@gmail.com> and contributors"]
version = "0.0.1"

[deps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Folds = "41a02a25-b8f0-4f67-bc48-60067656b558"
FoldsCUDA = "6cd66ae4-5932-4b96-926d-e73e578e42cc"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UnionArrays = "d6dd79e4-993b-11e9-1366-0de1c9fe1122"

[compat]
julia = "1"
24 changes: 24 additions & 0 deletions test/UnionArraysCUDATests/src/UnionArraysCUDATests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module UnionArraysCUDATests

import CUDA

function include_tests(m = @__MODULE__, dir = @__DIR__)
for file in readdir(dir)
if match(r"^test_.*\.jl$", file) !== nothing
Base.include(m, joinpath(dir, file))
end
end
end

include_tests()

function before_test_module()
CUDA.allowscalar(false)

if lowercase(get(ENV, "CI", "false")) == "true"
CUDA.versioninfo()
println()
end
end

end # module UnionArraysCUDATests
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using UnionArrays: unionof

const ==′ = isequal

@testset "UnionVector" begin
function test_unionvector()
xs = UnionVector(undef, CuVector, unionof(Float32, Missing), 3)
fill!(xs, 1)
CUDA.@allowscalar xs[2] = missing
Expand All @@ -17,7 +17,7 @@ const ==′ = isequal
@test collect(xs) ==′ [1.0f0, missing, 1.0f0]
end

@testset "UnionMatrix" begin
function test_unionmatrix()
A = UnionArray(undef, CuVector, unionof(Float32, Missing), (3, 2))
fill!(A, 1)
CUDA.@allowscalar A[2, 2] = missing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ using UnionArrays
using Documenter: doctest
using Test

@testset begin
function test()
doctest(UnionArrays)
end

should_test_module() = VERSION >= v"1.6-"

end # module
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using UnionArrays

const ==′ = isequal

@testset "UnionVector" begin
function test_unionvector()
xs = UnionVector(undef, CuVector, Union{Float32, Missing}, 3)
fill!(xs, 1)
CUDA.@allowscalar xs[2] = missing
Expand All @@ -25,7 +25,7 @@ const ==′ = isequal
end
end

@testset "UnionMatrix" begin
function test_unionmatrix()
A = UnionArray(undef, CuVector, Union{Float32, Missing}, (3, 2))
fill!(A, 1)
CUDA.@allowscalar A[2, 2] = missing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function host_test_shmem()
return ys
end

@testset "shmem" begin
function test_shmem()
xs = collect(Union{Nothing,Float32}, 1:8 * 3)
xs[2:2:end] .= nothing
for block in Iterators.partition(eachindex(xs), 8)
Expand All @@ -45,4 +45,6 @@ end
@test collect(host_test_shmem()) == xs
end

should_test_module() = VERSION >= v"1.6-"

end # module
13 changes: 13 additions & 0 deletions test/UnionArraysTests/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name = "UnionArraysTests"
uuid = "a66ddc63-82b4-4fd3-8fb7-6a8ed6db2f9a"
authors = ["Takafumi Arakaki <aka.tkf@gmail.com> and contributors"]
version = "0.0.1"

[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Transducers = "28d57a85-8fef-5791-bfe6-a80928e7c999"
UnionArrays = "d6dd79e4-993b-11e9-1366-0de1c9fe1122"

[compat]
julia = "1"
15 changes: 15 additions & 0 deletions test/UnionArraysTests/src/UnionArraysTests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module UnionArraysTests

include("utils.jl")

function include_tests(m = @__MODULE__, dir = @__DIR__)
for file in readdir(dir)
if match(r"^test_.*\.jl$", file) !== nothing
Base.include(m, joinpath(dir, file))
end
end
end

include_tests()

end # module UnionArraysTests
6 changes: 4 additions & 2 deletions test/test_aqua.jl → test/UnionArraysTests/src/test_aqua.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ using Test

# Default `Aqua.test_all(UnionArrays)` does not work due to ambiguities
# in upstream packages.
Aqua.test_all(UnionArrays; ambiguities = false)
function test_aqua()
Aqua.test_all(UnionArrays; ambiguities = false)
end

@testset "Method ambiguity" begin
function test_method_ambiguity()
Aqua.test_ambiguities(UnionArrays)
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module TestArrays

include("preamble.jl")
using UnionArrays
using Test

@testset begin
function test()
A = reshape(UnionVector(Any[1, 2.0]), 1, :)
@test A isa UnionArray
@test A[1] === 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module TestPadded

include("preamble.jl")
using UnionArrays
using UnionArrays.Impl: ofsamesize, unpad, Padded
using Test

@testset "ofsamesize" begin
function test_ofsamesize()
@testset "bigger = $bigger" for (bigger, value) in [
(Float64, UInt8(0)),
(NTuple{7, UInt8}, UInt8(0)),
Expand All @@ -16,7 +17,7 @@ using UnionArrays.Impl: ofsamesize, unpad, Padded
end
end

@testset "convert" begin
function test_convert()
xs = ofsamesize.(Float64, UInt8.(1:10)) :: Vector
@test eltype(xs) <: Padded
@test unpad(xs[1]) === UInt8(1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
module TestTransducers

include("preamble.jl")
using Test
using Transducers
using UnionArrays

@testset begin
using ..Utils: compile_enabled

function test()
xs = UnionVector(Any[1, 2.0])
@test foldl(+, Map(x -> 2x), xs) == 6

ys = eduction(Map(x -> 2x), xs)
if COMPILE_ENABLED
if compile_enabled()
@test (@inferred foldl(+, ys, init=0.0)) == 6
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
module TestVectors

include("preamble.jl")
using UnionArrays
using Test

@testset "homogeneous size" begin
function test_homogeneous_size()
xs = UnionVector(Any[1, 2.0])
@test xs[1] === 1
@test xs[2] === 2.0
@test (xs[1] = 3.0) isa Any
@test xs[1] === 3.0
end

@testset "heterogeneous size" begin
function test_heterogeneous_size()
xs = UnionVector(Any[UInt8(1), 2.0, (a=1, b=2)])
@test xs[1] === UInt8(1)
@test xs[2] === 2.0
Expand Down
6 changes: 6 additions & 0 deletions test/UnionArraysTests/src/utils.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Utils

compile_enabled() = Base.JLOptions().compile_enabled == 1
# allow `== 2` (`--compile=all`) as well?

end # module
12 changes: 0 additions & 12 deletions test/cuda/test_foldscudatests.jl

This file was deleted.

26 changes: 23 additions & 3 deletions test/environments/cuda-jl16/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ uuid = "1457febb-a09b-4652-98c9-46b8ccd8ff53"
version = "0.1.0"

[[FoldsCUDATests]]
deps = ["Adapt", "Aqua", "CUDA", "Documenter", "FLoops", "Folds", "FoldsCUDA", "FoldsCUDABenchmarks", "GPUArrays", "InitialValues", "LiterateTest", "Random", "Random123", "Referenceables", "Setfield", "SplittablesBase", "Test", "Transducers"]
git-tree-sha1 = "1554efa25546512b0e1ac876f93b66d430548eea"
repo-rev = "master"
deps = ["Adapt", "Aqua", "CUDA", "Documenter", "FLoops", "Folds", "FoldsCUDA", "FoldsCUDABenchmarks", "GPUArrays", "InitialValues", "LiterateTest", "Random", "Random123", "Referenceables", "Setfield", "SplittablesBase", "Test", "TestFunctionRunner", "Transducers"]
git-tree-sha1 = "099b24b043e683b121609325d8d6e77ceb7bd2ff"
repo-rev = "TestFunctionRunner"
repo-subdir = "test/FoldsCUDATests"
repo-url = "https://github.com/JuliaFolds/FoldsCUDA.jl.git"
uuid = "d11caea5-3c98-4cd5-8a56-9589fe6662ee"
Expand Down Expand Up @@ -318,6 +318,12 @@ git-tree-sha1 = "f10e6f4d46da26a33e9cea7a5aed3476b592bbfb"
uuid = "d77d25b0-90d3-4a16-b10a-412a9d48f625"
version = "0.1.4"

[[LoadAllPackages]]
deps = ["Pkg"]
git-tree-sha1 = "de9eababca8fdc9b6b207ed05f99693faa608230"
uuid = "b37bcd2d-1570-475d-a8c6-9b4fae6d0ba9"
version = "0.1.0"

[[LogExpFunctions]]
deps = ["ChainRulesCore", "ChangesOfVariables", "DocStringExtensions", "InverseFunctions", "IrrationalConstants", "LinearAlgebra"]
git-tree-sha1 = "e5718a00af0ab9756305a0392832c8952c7426c1"
Expand Down Expand Up @@ -506,6 +512,14 @@ uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[TestFunctionRunner]]
deps = ["Distributed", "LoadAllPackages", "Pkg", "Test"]
git-tree-sha1 = "960d1c79fdf61ce63826c161e87ccbb589e460b5"
repo-rev = "master"
repo-url = "https://github.com/tkf/TestFunctionRunner.jl"
uuid = "792026f5-ac9a-4a19-adcb-47b0ce2deb5d"
version = "0.1.0"

[[TimerOutputs]]
deps = ["ExprTools", "Printf"]
git-tree-sha1 = "97e999be94a7147d0609d0b9fc9feca4bf24d76b"
Expand All @@ -531,6 +545,12 @@ path = "../../.."
uuid = "d6dd79e4-993b-11e9-1366-0de1c9fe1122"
version = "0.1.3-DEV"

[[UnionArraysCUDATests]]
deps = ["CUDA", "Documenter", "Folds", "FoldsCUDA", "Test", "UnionArrays"]
path = "../../UnionArraysCUDATests"
uuid = "8106f4ae-0388-4bd1-9e3f-399fe7ea23bc"
version = "0.0.1"

[[Zlib_jll]]
deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
Expand Down
6 changes: 2 additions & 4 deletions test/environments/cuda-jl16/Project.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
[deps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Folds = "41a02a25-b8f0-4f67-bc48-60067656b558"
FoldsCUDA = "6cd66ae4-5932-4b96-926d-e73e578e42cc"
FoldsCUDABenchmarks = "1457febb-a09b-4652-98c9-46b8ccd8ff53"
FoldsCUDATests = "d11caea5-3c98-4cd5-8a56-9589fe6662ee"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Transducers = "28d57a85-8fef-5791-bfe6-a80928e7c999"
TestFunctionRunner = "792026f5-ac9a-4a19-adcb-47b0ce2deb5d"
UnionArrays = "d6dd79e4-993b-11e9-1366-0de1c9fe1122"
UnionArraysCUDATests = "8106f4ae-0388-4bd1-9e3f-399fe7ea23bc"
20 changes: 20 additions & 0 deletions test/environments/jl10/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
deps = ["Libdl"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[LoadAllPackages]]
deps = ["Pkg"]
git-tree-sha1 = "de9eababca8fdc9b6b207ed05f99693faa608230"
uuid = "b37bcd2d-1570-475d-a8c6-9b4fae6d0ba9"
version = "0.1.0"

[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

Expand Down Expand Up @@ -194,6 +200,14 @@ version = "1.6.1"
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[TestFunctionRunner]]
deps = ["Distributed", "LoadAllPackages", "Pkg", "Test"]
git-tree-sha1 = "78a77e769b8e10276da5b68eff22232449de8766"
repo-rev = "master"
repo-url = "https://github.com/tkf/TestFunctionRunner.jl"
uuid = "792026f5-ac9a-4a19-adcb-47b0ce2deb5d"
version = "0.1.0"

[[Transducers]]
deps = ["Adapt", "ArgCheck", "BangBang", "Baselet", "CompositionsBase", "DefineSingletons", "Distributed", "InitialValues", "Logging", "Markdown", "MicroCollections", "Requires", "Setfield", "SplittablesBase", "Tables"]
git-tree-sha1 = "a34f53c9e14d131b0ce114f591d3c5d428431ba0"
Expand All @@ -213,6 +227,12 @@ path = "../../.."
uuid = "d6dd79e4-993b-11e9-1366-0de1c9fe1122"
version = "0.1.3-DEV"

[[UnionArraysTests]]
deps = ["Aqua", "Test", "Transducers", "UnionArrays"]
path = "../../UnionArraysTests"
uuid = "a66ddc63-82b4-4fd3-8fb7-6a8ed6db2f9a"
version = "0.0.1"

[[ZygoteRules]]
deps = ["MacroTools"]
git-tree-sha1 = "8c1a8e4dfacb1fd631745552c8db35d0deb09ea0"
Expand Down
5 changes: 2 additions & 3 deletions test/environments/jl10/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Transducers = "28d57a85-8fef-5791-bfe6-a80928e7c999"
TestFunctionRunner = "792026f5-ac9a-4a19-adcb-47b0ce2deb5d"
UnionArrays = "d6dd79e4-993b-11e9-1366-0de1c9fe1122"
UnionArraysTests = "a66ddc63-82b4-4fd3-8fb7-6a8ed6db2f9a"
Loading