1717lib_dir = os .path .join (dirname , "lib" )
1818
1919lib_ext = {
20- "Darwin" : "dylib " ,
21- "Linux" : "so "
20+ "Darwin" : "a " ,
21+ "Linux" : "a "
2222}[platform .system ()]
2323libraffle_path = os .path .join (lib_dir , f"libraffle.{ lib_ext } " )
2424
@@ -46,6 +46,20 @@ def uses_openmp(lib_path):
4646 except Exception :
4747 return False
4848
49+ def copy_data_files ():
50+ # copy test/data directory to .temp_test/test/data
51+
52+ data_dir = os .path .join (os .path .dirname (__file__ ), "data" )
53+ os .makedirs (os .path .join (temp_test_dir , "test/data" ), exist_ok = True )
54+ for file in os .listdir (data_dir ):
55+ if file .endswith (".cif" ) or file .endswith (".xyz" ) or file .endswith (".vasp" ) or file .startswith ("POSCAR" ):
56+ src = os .path .join (data_dir , file )
57+ dst = os .path .join (temp_test_dir , "test/data" , file )
58+ print (f"Copying { src } to { dst } " )
59+ with open (src , "rb" ) as fsrc :
60+ with open (dst , "wb" ) as fdst :
61+ fdst .write (fsrc .read ())
62+
4963def build_fortran_test (test_name ):
5064 os .makedirs (temp_test_dir , exist_ok = True )
5165 # make using a fortran compiler
@@ -58,13 +72,13 @@ def build_fortran_test(test_name):
5872
5973 compile_list = [
6074 fc , "-o" , test_name + ".o" ,
61- "../../test/test_io_utils.f90" ,
62- " " .join (compile_args ),
75+ "../../test/test_" + test_name + ".f90" ,
6376 "-I" , include_dir ,
6477 "-I" , etc_dir ,
6578 "-L" , lib_dir ,
66- "-lraffle"
79+ "-lraffle" ,
6780 ]
81+ compile_list += compile_args
6882 build_result = subprocess .run (
6983 compile_list ,
7084 cwd = temp_test_dir
@@ -285,6 +299,7 @@ def test_print_settings(self):
285299
286300class TestFortranUnits (unittest .TestCase ):
287301
302+ copy_data_files ()
288303 @parameterized .expand ([(test_name ) for test_name in test_names ])
289304 def test_fortran (self , test_name ):
290305 build_result = build_fortran_test (test_name )
0 commit comments