CheckBaselineTests.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from __future__ import print_function
  4. import sys
  5. import re
  6. import os
  7. import argparse
  8. from os.path import *
  9. from subprocess import Popen, PIPE
  10. from CheckOptions import CheckOptions
  11. class CheckBaselineTests (CheckOptions):
  12. def __init__(self, args):
  13. CheckOptions.__init__(self, args)
  14. self.missing_baseline_tests = set()
  15. self.untested_options = [
  16. 'anon',
  17. 'args-only',
  18. 'debug',
  19. 'download',
  20. 'force-color',
  21. 'force-pager',
  22. 'generated',
  23. 'help',
  24. 'import',
  25. 'no-color',
  26. 'no-pager',
  27. 'options',
  28. 'price-exp',
  29. 'revalued-total',
  30. 'seed',
  31. 'trace',
  32. 'verbose',
  33. 'verify',
  34. 'verify-memory',
  35. 'version'
  36. ]
  37. def main(self):
  38. for option in self.ledger_options():
  39. if option in self.untested_options: continue
  40. baseline_testpath = join(self.source, 'test', 'baseline', 'opt-%s.test' % option)
  41. if exists(baseline_testpath) and getsize(baseline_testpath) > 0: continue
  42. self.missing_baseline_tests.add(option)
  43. if len(self.missing_baseline_tests):
  44. print("Missing Baseline test for:%s%s\n" % (self.sep, self.sep.join(sorted(list(self.missing_baseline_tests)))))
  45. errors = len(self.missing_baseline_tests)
  46. return errors
  47. if __name__ == "__main__":
  48. def getargs():
  49. parser = argparse.ArgumentParser(prog='CheckBaselineTests',
  50. description='Check that ledger options are tested')
  51. parser.add_argument('-l', '--ledger',
  52. dest='ledger',
  53. type=str,
  54. action='store',
  55. required=True,
  56. help='the path to the ledger executable to test with')
  57. parser.add_argument('-s', '--source',
  58. dest='source',
  59. type=str,
  60. action='store',
  61. required=True,
  62. help='the path to the top level ledger source directory')
  63. return parser.parse_args()
  64. args = getargs()
  65. script = CheckBaselineTests(args)
  66. status = script.main()
  67. sys.exit(status)