Debian Codegraph @

3rdparty/catch2/tools/scripts/approve.py

raw symbols SCIP
1 #!/usr/bin/env python3
2
3 import os
4 import sys
5 import shutil
6 import glob
7 from scriptCommon import catchPath
8
9 rootPath = os.path.join( catchPath, 'tests/SelfTest/Baselines' )
10
11 if len(sys.argv) > 1:
12 files = [os.path.join( rootPath, f ) for f in sys.argv[1:]]
13 else:
14 files = glob.glob( os.path.join( rootPath, "*.unapproved.txt" ) )
15
16
17 def approveFile( approvedFile, unapprovedFile ):
18 justFilename = unapprovedFile[len(rootPath)+1:]
19 if os.path.exists( unapprovedFile ):
20 if os.path.exists( approvedFile ):
21 os.remove( approvedFile )
22 os.rename( unapprovedFile, approvedFile )
23 print( "approved " + justFilename )
24 else:
25 print( "approval file " + justFilename + " does not exist" )
26
27 if files:
28 for unapprovedFile in files:
29 approveFile( unapprovedFile.replace( "unapproved.txt", "approved.txt" ), unapprovedFile )
30 else:
31 print( "no files to approve" )