summarise_results.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import json
  2. import sys
  3. def extract_test_results(json_file_path):
  4. passed_instances = set()
  5. all_instances = set()
  6. with open(json_file_path, 'r') as file:
  7. report = json.load(file)
  8. # Add resolved instances
  9. for instance_id in report['resolved']:
  10. passed_instances.add(instance_id)
  11. # Add all instances in the report
  12. for _, instance_ids in report.items():
  13. for instance_id in instance_ids:
  14. all_instances.add(instance_id)
  15. return passed_instances, all_instances
  16. if __name__ == '__main__':
  17. if len(sys.argv) != 2:
  18. print(
  19. 'Usage: poetry run python summarise_results.py <path_to_report_json_file>'
  20. )
  21. sys.exit(1)
  22. json_file_path = sys.argv[1]
  23. passed_instances, all_instances = extract_test_results(json_file_path)
  24. succ_rate = len(passed_instances) / len(all_instances)
  25. print(
  26. f'\nPassed {len(passed_instances)} tests, total {len(all_instances)} tests, resolve rate = {succ_rate:.2%}'
  27. )
  28. print('PASSED TESTS:')
  29. print(sorted(list(passed_instances)))
  30. print('FAILED TESTS:')
  31. print(sorted(list(all_instances - passed_instances)))