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

Production build on tests #72

Merged
merged 9 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/ComplexMixtures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 2 additions & 12 deletions src/Trajectory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 2 additions & 14 deletions test/allocations.jl
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
19 changes: 18 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Loading