From 8cf4e35b6521c9eec8919cf04d7c7428bb44c7d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Riedemann?= <38795484+longemen3000@users.noreply.github.com> Date: Thu, 22 Aug 2024 00:12:24 -0400 Subject: [PATCH 1/7] move Test into an extension --- Project.toml | 6 +++++ ext/SplittablesTestingExt.jl | 49 ++++++++++++++++++++++++++++++++++ src/SplittablesBase.jl | 10 ++++--- src/testing.jl | 51 +++++++----------------------------- 4 files changed, 71 insertions(+), 45 deletions(-) create mode 100644 ext/SplittablesTestingExt.jl diff --git a/Project.toml b/Project.toml index 4b6475b..63085cb 100644 --- a/Project.toml +++ b/Project.toml @@ -7,6 +7,12 @@ version = "0.1.16-DEV" Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +[weakdeps] +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[extensions] +SplittablesTestingExt = "Test" + [compat] Setfield = "0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1.0" julia = "1" diff --git a/ext/SplittablesTestingExt.jl b/ext/SplittablesTestingExt.jl new file mode 100644 index 0000000..fa66c28 --- /dev/null +++ b/ext/SplittablesTestingExt.jl @@ -0,0 +1,49 @@ +module SplittablesTestingExt +using SplittablesBase + +using Test: @test, @testset +using SplittablesBase: amount, halve +using SplittablesBase.Testing: getdata, countmap, recursive_vcat + + +function SplittablesBase.Testing.test_ordered(examples) + @testset "$(getlabel(x))" for x in enumerate(examples) + @debug "Testing `vcat`: $(getlabel(x))" + @testset "vcat" begin + data = getdata(x) + left, right = halve(getdata(x)) + @test isequal( + vcat(vec(collect(left)), vec(collect(right))), + vec(collect(getdata(x))), + ) + end + test_recursive_halving(x) + end +end + + +function SplittablesBase.Testing.test_unordered(examples) + @testset "$(getlabel(x))" for x in enumerate(examples) + @testset "concatenation" begin + data = getdata(x) + left, right = halve(getdata(x)) + @test isequal( + countmap(collect(data)), + merge(+, countmap(collect(left)), countmap(collect(right))), + ) + end + test_recursive_halving(x) + end +end + +function SplittablesBase.Testing.test_recursive_halving(x) + @debug "Testing _recursive halving_: $(getlabel(x))" + @testset "recursive halving" begin + if Base.IteratorSize(getdata(x)) isa Union{Base.HasLength,Base.HasShape} + @test isequal(recursive_vcat(getdata(x), length), vec(collect(getdata(x)))) + end + @test isequal(recursive_vcat(getdata(x)), vec(collect(getdata(x)))) + end +end + +end #module \ No newline at end of file diff --git a/src/SplittablesBase.jl b/src/SplittablesBase.jl index c89ec70..73398c7 100644 --- a/src/SplittablesBase.jl +++ b/src/SplittablesBase.jl @@ -11,9 +11,11 @@ include("implementations.jl") end # module module Testing -using Test: @test, @testset -using ..SplittablesBase: amount, halve -include("testing.jl") -end # module + include("testing.jl") +end + +if !isdefined(Base,:get_extension) + include("../ext/SplittablesTestingExt.jl") +end end # module diff --git a/src/testing.jl b/src/testing.jl index 1d6c86c..250fc89 100644 --- a/src/testing.jl +++ b/src/testing.jl @@ -1,3 +1,5 @@ +using ..SplittablesBase: halve + # Load docstring from markdown files: for (name, path) in [:test_ordered => joinpath(@__DIR__, "test_ordered.md")] try @@ -82,33 +84,6 @@ function recursive_vcat(data, _len, recursions, limit, err) ) end -function test_recursive_halving(x) - @debug "Testing _recursive halving_: $(getlabel(x))" - @testset "recursive halving" begin - if Base.IteratorSize(getdata(x)) isa Union{Base.HasLength,Base.HasShape} - @test isequal(recursive_vcat(getdata(x), length), vec(collect(getdata(x)))) - end - @test isequal(recursive_vcat(getdata(x)), vec(collect(getdata(x)))) - end -end - -function test_ordered(examples) - @testset "$(getlabel(x))" for x in enumerate(examples) - @debug "Testing `vcat`: $(getlabel(x))" - @testset "vcat" begin - data = getdata(x) - left, right = halve(getdata(x)) - @test isequal( - vcat(vec(collect(left)), vec(collect(right))), - vec(collect(getdata(x))), - ) - end - test_recursive_halving(x) - end -end - -@deprecate test test_ordered false - function countmap(xs) counts = Dict{Any,Int}() for x in xs @@ -117,27 +92,21 @@ function countmap(xs) return counts end +#the actual implementations are in ext/SplittablesTestingExt.jl +function test_recursive_halving end +function test_ordered end + +@deprecate test test_ordered false + """ SplittablesTesting.test_unordered(examples) See [`test_ordered`](@ref Main.SplittablesTesting.test_ordered). """ -function test_unordered(examples) - @testset "$(getlabel(x))" for x in enumerate(examples) - @testset "concatenation" begin - data = getdata(x) - left, right = halve(getdata(x)) - @test isequal( - countmap(collect(data)), - merge(+, countmap(collect(left)), countmap(collect(right))), - ) - end - test_recursive_halving(x) - end -end +function test_unordered end const _PUBLIC_API = [ # A list of public APIs to be picked by SplittablesTesting.jl :test_ordered, :test_unordered, -] +] \ No newline at end of file From 2506d7141824579a125765794d093680040e4f13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Riedemann?= <38795484+longemen3000@users.noreply.github.com> Date: Thu, 22 Aug 2024 00:20:51 -0400 Subject: [PATCH 2/7] update test flags --- .github/workflows/test.yml | 2 +- Project.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 647d034..40ac158 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - julia-version: ['~1.6.0-beta1', '1.5', '1.4', '1.0'] + julia-version: ['lts', '1', 'pre', 'nightly'] fail-fast: false name: Test Julia ${{ matrix.julia-version }} steps: diff --git a/Project.toml b/Project.toml index 63085cb..3fafffa 100644 --- a/Project.toml +++ b/Project.toml @@ -15,7 +15,7 @@ SplittablesTestingExt = "Test" [compat] Setfield = "0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1.0" -julia = "1" +julia = "1.6" [extras] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" From 252e4e062dd75ef72af7b04d559195bc0d434759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Riedemann?= <38795484+longemen3000@users.noreply.github.com> Date: Thu, 22 Aug 2024 00:30:31 -0400 Subject: [PATCH 3/7] update github actions for test --- .github/workflows/test.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 40ac158..634b317 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,15 +16,17 @@ jobs: fail-fast: false name: Test Julia ${{ matrix.julia-version }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup julia - uses: julia-actions/setup-julia@v1 + uses: julia-actions/setup-julia@v2 with: version: ${{ matrix.julia-version }} + - uses: julia-actions/cache@v2 + - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@latest - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v4 with: - file: ./lcov.info - flags: unittests - name: codecov-umbrella + files: lcov.info + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: false From 3ad62cab473ba8a22b7ad0ff4c26aa8d78849a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Riedemann?= <38795484+longemen3000@users.noreply.github.com> Date: Thu, 22 Aug 2024 00:35:04 -0400 Subject: [PATCH 4/7] trying to workaround the fact that SplittablesBase is a baremodule --- src/SplittablesBase.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/SplittablesBase.jl b/src/SplittablesBase.jl index 73398c7..f3d54cf 100644 --- a/src/SplittablesBase.jl +++ b/src/SplittablesBase.jl @@ -12,10 +12,11 @@ end # module module Testing include("testing.jl") + if !isdefined(Base,:get_extension) + include("../ext/SplittablesTestingExt.jl") + end end -if !isdefined(Base,:get_extension) - include("../ext/SplittablesTestingExt.jl") -end + end # module From 3c74f562eb112dbd017357238c8948963121a123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Riedemann?= <38795484+longemen3000@users.noreply.github.com> Date: Thu, 22 Aug 2024 00:42:06 -0400 Subject: [PATCH 5/7] typo --- ext/SplittablesTestingExt.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/SplittablesTestingExt.jl b/ext/SplittablesTestingExt.jl index fa66c28..17e588a 100644 --- a/ext/SplittablesTestingExt.jl +++ b/ext/SplittablesTestingExt.jl @@ -3,7 +3,7 @@ using SplittablesBase using Test: @test, @testset using SplittablesBase: amount, halve -using SplittablesBase.Testing: getdata, countmap, recursive_vcat +using SplittablesBase.Testing: getdata, getlabel, countmap, recursive_vcat function SplittablesBase.Testing.test_ordered(examples) From 7d26d7b74b34fb63d2f06616cc44da57225c6d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Riedemann?= <38795484+longemen3000@users.noreply.github.com> Date: Thu, 22 Aug 2024 00:44:04 -0400 Subject: [PATCH 6/7] another typo --- ext/SplittablesTestingExt.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/SplittablesTestingExt.jl b/ext/SplittablesTestingExt.jl index 17e588a..812eddd 100644 --- a/ext/SplittablesTestingExt.jl +++ b/ext/SplittablesTestingExt.jl @@ -17,7 +17,7 @@ function SplittablesBase.Testing.test_ordered(examples) vec(collect(getdata(x))), ) end - test_recursive_halving(x) + SplittablesBase.Testing.test_recursive_halving(x) end end @@ -32,7 +32,7 @@ function SplittablesBase.Testing.test_unordered(examples) merge(+, countmap(collect(left)), countmap(collect(right))), ) end - test_recursive_halving(x) + SplittablesBase.Testing.test_recursive_halving(x) end end From c4f0c69a19a1dcf62c81c0234b7bf4c9bdea52aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Riedemann?= <38795484+longemen3000@users.noreply.github.com> Date: Thu, 22 Aug 2024 00:49:22 -0400 Subject: [PATCH 7/7] missing `amount` inmport --- src/testing.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testing.jl b/src/testing.jl index 250fc89..8781516 100644 --- a/src/testing.jl +++ b/src/testing.jl @@ -1,4 +1,4 @@ -using ..SplittablesBase: halve +using ..SplittablesBase: halve, amount # Load docstring from markdown files: for (name, path) in [:test_ordered => joinpath(@__DIR__, "test_ordered.md")]