@@ -56,11 +56,28 @@ def _loadTestmeSchema(self) -> dict:
5656
5757 def _validateNaming (self , namings : str , autoExtracted : str , file : str ):
5858 names = namings .split ("," )
59- for n in autoExtracted .split ("," ):
60- if not n in names :
61- raise Exception (
62- f"Naming parameter list not match the auto-detectection, some are missinge. You gave : '{ names } ', detected '{ autoExtracted } ' into { file } "
63- )
59+ names_sorted = namings .split ("," )
60+ autoNames = autoExtracted .split ("," )
61+ autoNames_sorted = autoExtracted .split ("," )
62+
63+ # quick compare
64+ names_sorted .sort ()
65+ autoNames_sorted .sort ()
66+
67+ # check and if error check in details to report
68+ if names_sorted != autoNames_sorted :
69+ for n in autoNames :
70+ if n not in names :
71+ raise Exception (
72+ f"Naming parameter list not match the auto-detectection, some are missing : '{ n } '\n "
73+ f"You gave : '{ names } ', detected '{ autoNames } ' into { file } "
74+ )
75+ for n in names :
76+ if n not in autoNames :
77+ raise Exception (
78+ f"Naming parameter list not match the auto-detectection, some are missing : '{ n } '.\n "
79+ f"You gave : '{ names } ', detected '{ autoNames } ' into { file } "
80+ )
6481
6582 def _makeVariableArgAsList (self , namings : str , variants ) -> list :
6683 # make as a list
@@ -155,7 +172,7 @@ def genTests(self) -> list:
155172 )
156173 except Exception as e :
157174 raise Exception (
158- f"Fail to generate tests from { testfileRelPath } "
175+ f"Fail to generate tests from { testfileRelPath } . \n { e } "
159176 ) from e
160177
161178 # ok
@@ -448,7 +465,29 @@ def _runNonRegSingleRun(
448465 f"Dump file { file } was overwritten on restart"
449466 )
450467
468+ def validateTestmeJsons (self ) -> bool :
469+ try :
470+ self .genTests ()
471+ except Exception as e :
472+ print (f"{ e } " )
473+ return False
474+ return True
475+
451476 def main (self , all : bool = False ):
477+ # make testme.json validation for pre-commit
478+ if "--validate-testme-jsons" in sys .argv :
479+ try :
480+ tests = self .genTests ()
481+ for test in tests :
482+ testfile = test .values [0 ]["testfile" ]
483+ id = test .id
484+ print (f"{ testfile } => { id } " )
485+ except Exception as e :
486+ print (f"{ e } " )
487+ sys .exit (1 )
488+ return
489+
490+ # run
452491 if all :
453492 sys .argv .append ("-all" )
454493 idefixTest = tst .idfxTest (self .parentScritFile , name = "main" )
0 commit comments