Skip to content

Commit

Permalink
Fix Unit Test Python script error if a file is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
darksylinc committed Jul 16, 2022
1 parent 1200627 commit 1faa806
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions Scripts/UnitTesting/RunUnitTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,25 @@

def compareResults( oldFolder, newFolder ):
global g_hasDifferentFiles
cmpResult = filecmp.dircmp( oldFolder, newFolder )
if len( cmpResult.left_only ) > 0:
try:
cmpResult = filecmp.dircmp( oldFolder, newFolder )
if len( cmpResult.left_only ) > 0:
g_hasDifferentFiles = True
print( 'WARNING: these files were not generated by this unit test but should have been:' )
print( str( cmpResult.left_only ) )
if len( cmpResult.right_only ) > 0:
g_hasDifferentFiles = True
print( 'WARNING: these files were not in the original cmp folder:' )
print( str( cmpResult.right_only ) )

if len( cmpResult.diff_files ) == 0:
print( 'All files equal' )
else:
g_hasDifferentFiles = True
print( 'ERROR: Different files: ' + str( cmpResult.diff_files ) )
except FileNotFoundError as err:
g_hasDifferentFiles = True
print( 'WARNING: these files were not generated by this unit test but should have been:' )
print( str( cmpResult.left_only ) )
if len( cmpResult.right_only ) > 0:
g_hasDifferentFiles = True
print( 'WARNING: these files were not in the original cmp folder:' )
print( str( cmpResult.right_only ) )

if len( cmpResult.diff_files ) == 0:
print( 'All files equal' )
else:
g_hasDifferentFiles = True
print( 'ERROR: Different files: ' + str( cmpResult.diff_files ) )
print( 'ERROR: {0}'.format( err ) )

def runUnitTest( exeName, jsonName ):
exeFullpath = os.path.abspath( os.path.join( g_exeFolder, exeName ) )
Expand Down Expand Up @@ -126,4 +130,4 @@ def runUnitTest( exeName, jsonName ):
else:
print( 'All files in all tests were equal' )
else:
print( 'No comparison was made as the script was run in generation mode' )
print( 'No comparison was made as the script was run in generation mode' )

0 comments on commit 1faa806

Please sign in to comment.