11#=
22Export Test Suite - Main Test Runner
33
4- This file orchestrates all export-related tests:
5- 1. Julia export functionality (model export, compilation, evaluation )
6- 2. ETACE export functionality (ETACE model export with solid harmonics )
7- 3. Python calculator integration
8- 4. LAMMPS plugin integration (serial)
9- 5. Multi-species model tests
4+ This file orchestrates all export-related tests for ETACE models :
5+ 1. ETACE export functionality (polynomial radial basis )
6+ 2. Hermite spline export (machine-precision splined radial basis )
7+ 3. Multi-species model tests
8+ 4. Python calculator integration
9+ 5. LAMMPS plugin integration (serial)
10106. MPI parallel tests
1111
1212Usage:
1313 julia --project=.. runtests.jl # Run all available tests
14- julia --project=.. runtests.jl export # Run only ACEModel export tests
15- julia --project=.. runtests.jl etace # Run only ETACE export tests
16- julia --project=.. runtests.jl python # Run only Python tests
17- julia --project=.. runtests.jl portable # Run only portable Python tests
18- julia --project=.. runtests.jl lammps # Run only LAMMPS tests
19- julia --project=.. runtests.jl multispecies # Run only multi-species tests
20- julia --project=.. runtests.jl mpi # Run only MPI tests
14+ julia --project=.. runtests.jl etace # Run ETACE polynomial export tests
15+ julia --project=.. runtests.jl hermite # Run Hermite spline export tests
16+ julia --project=.. runtests.jl multispecies # Run multi-species tests
17+ julia --project=.. runtests.jl python # Run Python tests
18+ julia --project=.. runtests.jl lammps # Run LAMMPS tests
19+ julia --project=.. runtests.jl mpi # Run MPI tests
2120=#
2221
2322using Test
@@ -36,59 +35,6 @@ const PROJECT_DIR = dirname(EXPORT_DIR)
3635# Global test artifacts (created once, reused across tests)
3736const TEST_ARTIFACTS = Dict {String, Any} ()
3837
39- """
40- setup_test_model()
41-
42- Fit a small Si model for testing. Returns (potential, test_data).
43- Caches the result for reuse across test files.
44- """
45- function setup_test_model ()
46- if haskey (TEST_ARTIFACTS, " potential" )
47- return TEST_ARTIFACTS[" potential" ], TEST_ARTIFACTS[" test_data" ]
48- end
49-
50- @info " Setting up test model (fitting Si potential)..."
51-
52- # Load training data using example_dataset
53- dataset = ACEpotentials. example_dataset (" Si_tiny" )
54- data = dataset. train
55-
56- # Create small model for fast testing
57- model = ACEpotentials. ace1_model (
58- elements = [:Si ],
59- order = 2 ,
60- totaldegree = 6 ,
61- rcut = 5.5 ,
62- )
63-
64- # Data keys matching Si_tiny dataset
65- data_keys = (
66- energy_key = " dft_energy" ,
67- force_key = " dft_force" ,
68- virial_key = " dft_virial" ,
69- )
70-
71- weights = Dict (" default" => Dict (" E" => 30.0 , " F" => 1.0 , " V" => 1.0 ))
72-
73- # Fit model
74- ACEpotentials. acefit! (data, model;
75- data_keys... ,
76- weights = weights,
77- solver = ACEfit. BLR (),
78- )
79-
80- # Get the fitted potential
81- potential = model
82-
83- # Store for reuse
84- TEST_ARTIFACTS[" potential" ] = potential
85- TEST_ARTIFACTS[" test_data" ] = data
86-
87- @info " Test model ready"
88-
89- return potential, data
90- end
91-
9238"""
9339 get_test_structure()
9440
@@ -160,58 +106,6 @@ function check_mpi_available()
160106 end
161107end
162108
163- """
164- get_compiled_library()
165-
166- Get path to compiled test library. Compiles if not exists.
167- """
168- function get_compiled_library ()
169- if haskey (TEST_ARTIFACTS, " lib_path" )
170- return TEST_ARTIFACTS[" lib_path" ]
171- end
172-
173- # Set up model first
174- potential, _ = setup_test_model ()
175-
176- # Export and compile
177- build_dir = joinpath (TEST_DIR, " build" )
178- mkpath (build_dir)
179-
180- @info " Exporting model to Julia code..."
181- include (joinpath (EXPORT_DIR, " src" , " export_ace_model.jl" ))
182- model_file = joinpath (build_dir, " test_ace_model.jl" )
183- export_ace_model (potential, model_file; for_library= true )
184-
185- @info " Compiling to shared library..."
186- lib_path = joinpath (build_dir, " libace_test.so" )
187-
188- # Run juliac
189- juliac_cmd = ` julia --project=$(EXPORT_DIR) -e "
190- using PackageCompiler
191- PackageCompiler.juliac(
192- \" $(model_file) \" ,
193- \" $(lib_path) \" ;
194- compile_library=true,
195- trim=true,
196- verbose=true
197- )
198- "`
199-
200- # Alternative: use juliac directly if available
201- # juliac_cmd = `juliac --output-lib $(lib_path) --trim=safe --project=$(EXPORT_DIR) $(model_file)`
202-
203- run (juliac_cmd)
204-
205- if ! isfile (lib_path)
206- error (" Compilation failed: $lib_path not created" )
207- end
208-
209- TEST_ARTIFACTS[" lib_path" ] = lib_path
210- TEST_ARTIFACTS[" model_file" ] = model_file
211-
212- return lib_path
213- end
214-
215109# Parse command line args for selective testing
216110function get_test_selection ()
217111 if length (ARGS ) == 0
@@ -229,27 +123,33 @@ end
229123function main ()
230124 selection = get_test_selection ()
231125
232- @info " ACE Export Test Suite"
233- @info " ====================="
126+ @info " ACE Export Test Suite (ETACE) "
127+ @info " ============================== "
234128 @info " Test selection: $selection "
235129 @info " Python available: $(check_python_available ()) "
236130 @info " LAMMPS available: $(check_lammps_available ()) "
237131 @info " MPI available: $(check_mpi_available ()) "
238132 @info " "
239133
240134 @testset " ACE Export Tests" verbose= true begin
241- # Julia export tests (ACEModel)
242- if should_run_test (selection, :export ) || should_run_test (selection, :all )
243- @info " Running Julia export tests (ACEModel)..."
244- include (joinpath (TEST_DIR, " test_export.jl" ))
245- end
246-
247- # ETACE export tests
135+ # ETACE export tests (polynomial radial basis)
248136 if should_run_test (selection, :etace ) || should_run_test (selection, :all )
249- @info " Running ETACE export tests..."
137+ @info " Running ETACE export tests (polynomial) ..."
250138 include (joinpath (TEST_DIR, " test_etace_export.jl" ))
251139 end
252140
141+ # Hermite spline export tests
142+ if should_run_test (selection, :hermite ) || should_run_test (selection, :all )
143+ @info " Running Hermite spline export tests..."
144+ include (joinpath (TEST_DIR, " test_hermite_spline_export.jl" ))
145+ end
146+
147+ # Multi-species tests
148+ if should_run_test (selection, :multispecies ) || should_run_test (selection, :all )
149+ @info " Running multi-species export tests..."
150+ include (joinpath (TEST_DIR, " test_multispecies.jl" ))
151+ end
152+
253153 # Python tests
254154 if should_run_test (selection, :python ) || should_run_test (selection, :all )
255155 if check_python_available ()
@@ -260,16 +160,6 @@ function main()
260160 end
261161 end
262162
263- # Portable Python tests (validates relocatable deployment)
264- if should_run_test (selection, :portable ) || should_run_test (selection, :all )
265- if check_python_available ()
266- @info " Running portable Python tests..."
267- include (joinpath (TEST_DIR, " test_portable_python.jl" ))
268- else
269- @warn " Skipping portable Python tests (Python/numpy/ase not available)"
270- end
271- end
272-
273163 # LAMMPS tests (serial)
274164 if should_run_test (selection, :lammps ) || should_run_test (selection, :all )
275165 if check_lammps_available ()
@@ -280,12 +170,6 @@ function main()
280170 end
281171 end
282172
283- # Multi-species tests
284- if should_run_test (selection, :multispecies ) || should_run_test (selection, :all )
285- @info " Running multi-species export tests..."
286- include (joinpath (TEST_DIR, " test_multispecies.jl" ))
287- end
288-
289173 # MPI tests
290174 if should_run_test (selection, :mpi ) || should_run_test (selection, :all )
291175 if check_mpi_available () && check_lammps_available ()
0 commit comments