Skip to content

Commit

Permalink
Merge pull request #72 from m3g/production_build_on_tests
Browse files Browse the repository at this point in the history
Production build on tests
  • Loading branch information
lmiq authored Feb 1, 2025
2 parents 6fe2349 + 88a978b commit 4a5ac12
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 32 deletions.
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

0 comments on commit 4a5ac12

Please sign in to comment.