99import sys
1010import subprocess
1111from pathlib import Path
12-
12+ import glob
1313
1414def get_dependencies (file : Path ) -> Set [str ]:
1515 file_dot_d = file .with_suffix (".d" )
@@ -36,6 +36,11 @@ def get_changed() -> Set[str]:
3636 return set (changed_files )
3737
3838
39+ def add_tests_from_hpp (tests_to_run , test ):
40+ pattern = str (test ).replace ("_test.hpp" , "_0*_test.cpp" )
41+ tests = glob .glob (pattern )
42+ tests_to_run .extend (tests )
43+
3944if __name__ == "__main__" :
4045 if Path ("makefile" ) not in Path ("." ).iterdir ():
4146 raise ValueError ("getDependencies must be ran from the top-level repository" )
@@ -47,12 +52,16 @@ def get_changed() -> Set[str]:
4752
4853 distribution_tests = Path ("test" , "prob" )
4954
55+ subprocess .run (["make" , "generate-tests" ], stdout = subprocess .DEVNULL )
56+
5057 for dist in distribution_tests .iterdir ():
5158 if not dist .is_dir ():
5259 continue
60+ print (f"Considering { dist } ." , file = sys .stderr )
5361 for test in dist .iterdir ():
62+ if test .suffix != ".hpp" : continue
5463 if pretend :
55- tests_to_run . append ( str ( test ). replace ( "_test.hpp" , "_0*_test.cpp" ) )
64+ add_tests_from_hpp ( tests_to_run , test )
5665 else :
5766 deps = get_dependencies (test )
5867 intersection = changed & deps
@@ -61,7 +70,6 @@ def get_changed() -> Set[str]:
6170 f"{ test } has { len (intersection )} changed dependencies out of { len (deps )} files #included." ,
6271 file = sys .stderr ,
6372 )
73+ add_tests_from_hpp (tests_to_run , test )
6474
65- tests_to_run .append (str (test ).replace ("_test.hpp" , "_0*_test.cpp" ))
66-
67- print ("\n " .join (tests_to_run ))
75+ print ("\n " .join (set (tests_to_run )))
0 commit comments