@@ -158,17 +158,24 @@ def should_generate(self, path):
158158
159159 def find_modules (self ):
160160 modules = []
161- for root , _ , files in os .walk (self .path ):
162- module_root = root [len (self .path ):]
163- module_root = [c for c in module_root .split (os .sep ) if c ]
164161
165- tests_in_module = fnmatch .filter (files , "*.c" )
162+ if os .path .isfile (self .path ):
163+ full_path = os .path .abspath (self .path )
164+ module_name = os .path .basename (self .path )
165+ module_name = os .path .splitext (module_name )[0 ]
166+ modules .append ((full_path , module_name ))
167+ else :
168+ for root , _ , files in os .walk (self .path ):
169+ module_root = root [len (self .path ):]
170+ module_root = [c for c in module_root .split (os .sep ) if c ]
166171
167- for test_file in tests_in_module :
168- full_path = os .path .join (root , test_file )
169- module_name = "_" .join (module_root + [test_file [:- 2 ]]).replace ("-" , "_" )
172+ tests_in_module = fnmatch .filter (files , "*.c" )
170173
171- modules .append ((full_path , module_name ))
174+ for test_file in tests_in_module :
175+ full_path = os .path .join (root , test_file )
176+ module_name = "_" .join (module_root + [test_file [:- 2 ]]).replace ("-" , "_" )
177+
178+ modules .append ((full_path , module_name ))
172179
173180 return modules
174181
@@ -217,6 +224,7 @@ def callback_count(self):
217224
218225 def write (self ):
219226 output = os .path .join (self .output , 'clar.suite' )
227+ os .makedirs (self .output , exist_ok = True )
220228
221229 if not self .should_generate (output ):
222230 return False
@@ -258,7 +266,11 @@ def write(self):
258266 sys .exit (1 )
259267
260268 path = args .pop () if args else '.'
269+ if os .path .isfile (path ) and not options .output :
270+ print ("Must provide --output when specifying a file" )
271+ sys .exit (1 )
261272 output = options .output or path
273+
262274 suite = TestSuite (path , output )
263275 suite .load (options .force )
264276 suite .disable (options .excluded )
0 commit comments