- retrace = [options.retrace] + args
- sys.stdout.write(' '.join(retrace) + '\n')
- sys.stdout.flush()
- returncode = subprocess.call(retrace)
- if returncode:
- # TODO: allow other criterias here, such as, snapshot comparison or performance threshold
- bad()
+
+ retracer = retracediff.Retracer(options.retrace, args)
+
+ if options.compare_prefix:
+ refImages = {}
+ callNos = []
+
+ images = snapdiff.find_images(options.compare_prefix)
+ images.sort()
+ for image in images:
+ imageName, ext = os.path.splitext(image)
+ try:
+ callNo = int(imageName)
+ except ValueError:
+ continue
+ refImages[callNo] = options.compare_prefix + image
+ callNos.append(callNo)
+
+ run = retracer.snapshot(','.join(map(str, callNos)))
+ while True:
+ srcImage, callNo = run.nextSnapshot()
+ if srcImage is None:
+ break
+
+ refImage = refImages[callNo]
+
+ # Compare the two images
+ comparer = snapdiff.Comparer(refImage, srcImage)
+ precision = comparer.precision()
+
+ mismatch = precision < options.precision_threshold
+ if mismatch:
+ bad()
+ run.process.wait()
+ if run.process.returncode:
+ skip()
+ else:
+ returncode = retracer.retrace('-b')
+ if returncode:
+ bad()
+
+ # TODO: allow more criterias here, such as, performance threshold