result_checker.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/usr/bin/env python3
  2. # -*- Coding: UTF-8 -*-
  3. # ---------------------------------------------------------------------------
  4. # Open Asset Import Library (ASSIMP)
  5. # ---------------------------------------------------------------------------
  6. #
  7. # Copyright (c) 2006-2020, ASSIMP Development Team
  8. #
  9. # All rights reserved.
  10. #
  11. # Redistribution and use of this software in source and binary forms,
  12. # with or without modification, are permitted provided that the following
  13. # conditions are met:
  14. #
  15. # * Redistributions of source code must retain the above
  16. # copyright notice, this list of conditions and the
  17. # following disclaimer.
  18. #
  19. # * Redistributions in binary form must reproduce the above
  20. # copyright notice, this list of conditions and the
  21. # following disclaimer in the documentation and/or other
  22. # materials provided with the distribution.
  23. #
  24. # * Neither the name of the ASSIMP team, nor the names of its
  25. # contributors may be used to endorse or promote products
  26. # derived from this software without specific prior
  27. # written permission of the ASSIMP Development Team.
  28. #
  29. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  30. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  31. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  32. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  33. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  34. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  35. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  36. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  37. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  38. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  39. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40. # ---------------------------------------------------------------------------
  41. """
  42. This script runs as part of the Travis CI build on Github and controls
  43. whether a patch passes the regression test suite.
  44. Given the failures encountered by the regression suite runner (run.py) in
  45. ../results/whitelist.csv
  46. and the current whitelist of failures considered acceptable in
  47. ./run_regression_suite_failures_whitelisted.csv
  48. determine PASSED or FAILED.
  49. """
  50. import sys
  51. import os
  52. RESULTS_FILE = os.path.join('..', 'results', 'run_regression_suite_failures.csv')
  53. WHITELIST_FILE = os.path.join('whitelist.csv')
  54. BANNER = """
  55. *****************************************************************
  56. Regression suite result checker
  57. (test/regression/result_checker.py)
  58. *****************************************************************
  59. """
  60. def passed(message):
  61. print('\n\n**PASSED: {0}.\n'.format(message))
  62. return 0
  63. def failed(message):
  64. print('\n\n**FAILED: {0}. \nFor more information see test/regression/README.\n'
  65. .format(message))
  66. return -1
  67. def read_results_csv(filename):
  68. parse = lambda line: map(str.strip, line.split(';')[:2])
  69. try:
  70. with open(filename, 'rt') as results:
  71. return dict(parse(line) for line in results.readlines()[1:])
  72. except IOError:
  73. print('Failed to read {0}.'.format(filename))
  74. return None
  75. def run():
  76. print(BANNER)
  77. print('Reading input files.')
  78. result_dict = read_results_csv(RESULTS_FILE)
  79. whitelist_dict = read_results_csv(WHITELIST_FILE)
  80. if result_dict is None or whitelist_dict is None:
  81. return failed('Could not locate input files')
  82. if not result_dict:
  83. return passed('No failures encountered')
  84. print('Failures:\n' + '\n'.join(sorted(result_dict.keys())))
  85. print('Whitelisted:\n' + '\n'.join(sorted(whitelist_dict.keys())))
  86. non_whitelisted_failures = set(result_dict.keys()) - set(whitelist_dict.keys())
  87. print('Failures not whitelisted:\n' + '\n'.join(sorted(non_whitelisted_failures)))
  88. if not non_whitelisted_failures:
  89. return passed('All failures are whitelisted and considered acceptable \n' +
  90. 'due to implementation differences, library shortcomings and bugs \n' +
  91. 'that have not been fixed for a long time')
  92. return failed('Encountered new regression failures that are not whitelisted. \n' +
  93. 'Please carefully review the changes you made and use the gen_db.py script\n' +
  94. 'to update the regression database for the affected files')
  95. if __name__ == "__main__":
  96. sys.exit(run())
  97. # vim: ai ts=4 sts=4 et sw=4