27 lines
		
	
	
		
			660 B
		
	
	
	
		
			Plaintext
		
	
	
	
		
		
			
		
	
	
			27 lines
		
	
	
		
			660 B
		
	
	
	
		
			Plaintext
		
	
	
	
|  | #!/usr/bin/env python3 | ||
|  | # checks if every desired package has test files | ||
|  | 
 | ||
|  | import os | ||
|  | import re | ||
|  | import sys | ||
|  | 
 | ||
|  | source_re = re.compile(".*\.go") | ||
|  | test_re   = re.compile(".*_test\.go") | ||
|  | missing   = False | ||
|  | 
 | ||
|  | for root, dirs, files in os.walk("."): | ||
|  |   # ignore some paths | ||
|  |   if root == "." or root.startswith("./vendor") or root.startswith("./.") or root.startswith("./docs"): | ||
|  |     continue | ||
|  | 
 | ||
|  |   # source files but not test files? | ||
|  |   if len([f for f in files if source_re.match(f)]) > 0 and len([f for f in files if test_re.match(f)]) == 0: | ||
|  |     print("no test files for {}".format(root)) | ||
|  |     missing = True | ||
|  | 
 | ||
|  | if missing: | ||
|  |   sys.exit(1) | ||
|  | else: | ||
|  |   print("every package has test files") | ||
|  | 
 |