diff --git a/Project.toml b/Project.toml index 838f525f..1b70660d 100644 --- a/Project.toml +++ b/Project.toml @@ -32,7 +32,7 @@ Plotting = "Plots" [compat] Aqua = "0.8.9" BenchmarkTools = "1" -CellListMap = "0.8.30, 0.9" +CellListMap = "0.9.7" Chemfiles = "0.10.3" ChunkSplitters = "3.1" DelimitedFiles = "1.9" @@ -43,7 +43,7 @@ JSON3 = "1.11.1" LinearAlgebra = "1.9" PDBTools = "1.8.1, 2" Plots = "1.39" -PrecompileTools = "1" +PrecompileTools = "1.2.1" Printf = "1.9" ProgressMeter = "1.10.1" Random = "1.9" @@ -54,8 +54,8 @@ StaticArrays = "1.6" Statistics = "1.9" StructTypes = "1.10" Test = "1.9" -TestItemRunner = "0.2" -TestItems = "0.1, 1" +TestItemRunner = "1.1" +TestItems = "1" julia = "1.9" [extras] diff --git a/src/ComplexMixtures.jl b/src/ComplexMixtures.jl index 00072df9..22eb18cf 100644 --- a/src/ComplexMixtures.jl +++ b/src/ComplexMixtures.jl @@ -16,7 +16,7 @@ using Printf: @sprintf using ProgressMeter: Progress, next! using StaticArrays: SVector, SMatrix, @SMatrix, MMatrix using Statistics: mean, std -using TestItems: @testitem +using TestItems: @testitem, @testmodule # Data types diff --git a/src/Trajectory.jl b/src/Trajectory.jl index d806a4e4..4c6d1d04 100644 --- a/src/Trajectory.jl +++ b/src/Trajectory.jl @@ -76,21 +76,11 @@ end convert_unitcell(::SVector, unitcell::AbstractMatrix) = SVector{3}(unitcell[1, 1], unitcell[2, 2], unitcell[3, 3]) convert_unitcell(::SMatrix, unitcell::AbstractMatrix) = SMatrix{3,3}(unitcell) -@testitem "convert_unitcell" begin +@testitem "convert_unitcell" setup=[AllocTest] begin using ComplexMixtures: convert_unitcell using StaticArrays: SVector, SMatrix using BenchmarkTools: @benchmark - - @kwdef struct Allocs - prodbuild::Bool = haskey(ENV, "BUILD_IS_PRODUCTION_BUILD") && ENV["BUILD_IS_PRODUCTION_BUILD"] == "true" - allocs::Int - end - Allocs(allocs::Int) = Allocs(; allocs) - import Base: ==, >, < - ==(a::Int, b::Allocs) = b.prodbuild ? a == b.allocs : true - <(a::Int, b::Allocs) = b.prodbuild ? a < b.allocs : true - ==(a::Allocs, b::Int) = a.prodbuild ? a.allocs == b : true - <(a::Allocs, b::Int) = a.prodbuild ? a.allocs < b : true + using .AllocTest: Allocs m = [1.0 0.0 0.0; 0.0 1.0 0.0; 0.0 0.0 1.0] @test convert_unitcell(m) isa SVector diff --git a/test/allocations.jl b/test/allocations.jl index 0a69e43d..5c270293 100644 --- a/test/allocations.jl +++ b/test/allocations.jl @@ -1,25 +1,13 @@ -@testitem "Allocations" begin +@testitem "Allocations" setup=[AllocTest] begin using PDBTools using ComplexMixtures using ComplexMixtures.Testing using BenchmarkTools - - @kwdef struct Allocs - prodbuild::Bool = haskey(ENV, "BUILD_IS_PRODUCTION_BUILD") && ENV["BUILD_IS_PRODUCTION_BUILD"] == "true" - allocs::Int - end - Allocs(allocs::Int) = Allocs(; allocs) - import Base: ==, >, < - ==(a::Int, b::Allocs) = b.prodbuild ? a == b.allocs : true - <(a::Int, b::Allocs) = b.prodbuild ? a < b.allocs : true - ==(a::Allocs, b::Int) = a.prodbuild ? a.allocs == b : true - <(a::Allocs, b::Int) = a.prodbuild ? a.allocs < b : true - + using .AllocTest: Allocs dir = "$(Testing.data_dir)/NAMD" atoms = readPDB("$dir/structure.pdb") - options = Options( lastframe=1, nthreads=1, diff --git a/test/runtests.jl b/test/runtests.jl index e1d87ee5..840f728b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,21 @@ -using TestItemRunner: @run_package_tests, @testitem +using TestItemRunner + +@testmodule AllocTest begin + # This module defines the Allocs struct and the comparison operators + # to conditionally compare the number of allocations based on the + # BUILD_IS_PRODUCTION_BUILD environment variable. + export Allocs + @kwdef struct Allocs + prodbuild::Bool = haskey(ENV, "BUILD_IS_PRODUCTION_BUILD") && ENV["BUILD_IS_PRODUCTION_BUILD"] == "true" + allocs::Int + end + Allocs(allocs::Int) = Allocs(; allocs) + import Base: ==, >, < + ==(a::Int, b::Allocs) = b.prodbuild ? a == b.allocs : true + <(a::Int, b::Allocs) = b.prodbuild ? a < b.allocs : true + ==(a::Allocs, b::Int) = a.prodbuild ? a.allocs == b : true + <(a::Allocs, b::Int) = a.prodbuild ? a.allocs < b : true +end @run_package_tests