mirror of
https://github.com/holub/mame
synced 2025-06-22 20:38:50 +03:00
chdtest.py:
- fixed check for output folder existence - clear temp folder before running tests - log which test failed
This commit is contained in:
parent
766a73b041
commit
286110939d
@ -2,6 +2,7 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import shutil
|
||||||
|
|
||||||
def runProcess(cmd):
|
def runProcess(cmd):
|
||||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
@ -52,17 +53,21 @@ if not os.path.exists(inputPath):
|
|||||||
print inputPath + " does not exist"
|
print inputPath + " does not exist"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if not os.path.exists(inputPath):
|
if not os.path.exists(outputPath):
|
||||||
print inputPath + " does not exist"
|
print outputPath + " does not exist"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
failure = False
|
shutil.rmtree(tempPath)
|
||||||
|
|
||||||
|
total_failure = False
|
||||||
|
|
||||||
for root, dirs, files in os.walk(inputPath):
|
for root, dirs, files in os.walk(inputPath):
|
||||||
for d in dirs:
|
for d in dirs:
|
||||||
if d.startswith("."):
|
if d.startswith("."):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
failure = False
|
||||||
|
|
||||||
command = ext = d.split("_", 2)[0]
|
command = ext = d.split("_", 2)[0]
|
||||||
inFile = os.path.join(root, d, "in")
|
inFile = os.path.join(root, d, "in")
|
||||||
# TODO: make this better
|
# TODO: make this better
|
||||||
@ -96,14 +101,19 @@ for root, dirs, files in os.walk(inputPath):
|
|||||||
cmd = [chdmanBin, command, "-f", "-i", inFile, "-o", tempFile] + params
|
cmd = [chdmanBin, command, "-f", "-i", inFile, "-o", tempFile] + params
|
||||||
else:
|
else:
|
||||||
cmd = [chdmanBin, command, "-f", "-o", tempFile] + params
|
cmd = [chdmanBin, command, "-f", "-o", tempFile] + params
|
||||||
|
|
||||||
exitcode, stdout, stderr = runProcess(cmd)
|
exitcode, stdout, stderr = runProcess(cmd)
|
||||||
if not exitcode == 0:
|
if not exitcode == 0:
|
||||||
print d + " - command failed with " + str(exitcode) + " (" + stderr + ")"
|
print d + " - command failed with " + str(exitcode) + " (" + stderr + ")"
|
||||||
failure = True
|
failure = True
|
||||||
|
|
||||||
|
# verify
|
||||||
exitcode, stdout, stderr = runProcess([chdmanBin, "verify", "-i", tempFile])
|
exitcode, stdout, stderr = runProcess([chdmanBin, "verify", "-i", tempFile])
|
||||||
if not exitcode == 0:
|
if not exitcode == 0:
|
||||||
print d + " - verify failed with " + str(exitcode) + " (" + stderr + ")"
|
print d + " - verify failed with " + str(exitcode) + " (" + stderr + ")"
|
||||||
failure = True
|
failure = True
|
||||||
|
|
||||||
|
# compare info
|
||||||
# TODO: store expected output of reference file as well and compare
|
# TODO: store expected output of reference file as well and compare
|
||||||
exitcode, info1, stderr = runProcess([chdmanBin, "info", "-v", "-i", tempFile])
|
exitcode, info1, stderr = runProcess([chdmanBin, "info", "-v", "-i", tempFile])
|
||||||
if not exitcode == 0:
|
if not exitcode == 0:
|
||||||
@ -123,5 +133,9 @@ for root, dirs, files in os.walk(inputPath):
|
|||||||
failure = True
|
failure = True
|
||||||
# TODO: extract and compare
|
# TODO: extract and compare
|
||||||
|
|
||||||
if not failure:
|
if failure:
|
||||||
|
print d + " failed"
|
||||||
|
total_failure = True
|
||||||
|
|
||||||
|
if not total_failure:
|
||||||
print "All tests finished successfully"
|
print "All tests finished successfully"
|
Loading…
Reference in New Issue
Block a user