- with open(filename, "r") as chk:
- text = chk.read()
- loc_coverage(locations, text)
- arb_coverage(arb_msgs, text)
- obj_coverage(objects, text)
- hint_coverage(hints, text)
- threshold_coverage(classes, text)
- threshold_coverage(turn_thresholds, text)
-
- location_html = ""
- location_total = len(locations) * 2
- location_covered = 0
- locations.sort()
- for locouter in locations:
- locname = locouter[0]
- loc = locouter[1]
- if loc["description"]["long"] != True:
- long_success = "uncovered"
- else:
- long_success = "covered"
- location_covered += 1
-
- if loc["description"]["short"] != True:
- short_success = "uncovered"
- else:
- short_success = "covered"
- location_covered += 1
-
- location_html += location_row.format(locname, long_success, short_success)
- location_percent = round((location_covered / float(location_total)) * 100, 1)
-
- arb_msgs.sort()
- arb_msg_html = ""
- arb_total = len(arb_msgs)
- arb_covered = 0
- for name, msg in arb_msgs:
- if msg != True:
- success = "uncovered"
- else:
- success = "covered"
- arb_covered += 1
- arb_msg_html += arb_msg_row.format(name, success)
- arb_percent = round((arb_covered / float(arb_total)) * 100, 1)
-
- object_html = ""
- objects_total = 0
- objects_covered = 0
- objects.sort()
- for (obj_name, obj) in objects:
- if obj["descriptions"]:
- for j, desc in enumerate(obj["descriptions"]):
- objects_total += 1
- if desc != True:
- success = "uncovered"
- else:
- success = "covered"
- objects_covered += 1
- object_html += object_row.format("%s[%d]" % (obj_name, j), success)
- objects_percent = round((objects_covered / float(objects_total)) * 100, 1)
-
- hints.sort()
- hints_html = "";
- hints_total = len(hints) * 2
- hints_covered = 0
- for name, hint in hints:
- if hint["question"] != True:
- question_success = "uncovered"
- else:
- question_success = "covered"
- hints_covered += 1
- if hint["hint"] != True:
- hint_success = "uncovered"
- else:
- hint_success = "covered"
- hints_covered += 1
- hints_html += location_row.format(name, question_success, hint_success)
- hints_percent = round((hints_covered / float(hints_total)) * 100, 1)
-
- class_html = ""
- class_total = len(classes)
- class_covered = 0
- for name, msg in enumerate(classes):
- if msg["message"] != True:
- success = "uncovered"
- else:
- success = "covered"
- class_covered += 1
- class_html += arb_msg_row.format(msg["threshold"], success)
- class_percent = round((class_covered / float(class_total)) * 100, 1)
-
- turn_html = ""
- turn_total = len(turn_thresholds)
- turn_covered = 0
- for name, msg in enumerate(turn_thresholds):
- if msg["message"] != True:
- success = "uncovered"
- else:
- success = "covered"
- turn_covered += 1
- turn_html += arb_msg_row.format(msg["threshold"], success)
- turn_percent = round((turn_covered / float(turn_total)) * 100, 1)
+ with open(filename, "r") as f:
+ check_file_contents.append(f.read())
+
+ # run coverage analysis report on dungeon database
+ report = coverage_report(db, check_file_contents)
+
+ # render report output
+ categories_html = ""
+ summary_html = ""
+ summary_stdout = "adventure.yaml coverage rate:\n"
+ for name, category in sorted(report.items()):
+ # ignore categories with zero entries
+ if category["total"] > 0:
+ # Calculate percent coverage
+ category["percent"] = (category["covered"] / float(category["total"])) * 100
+
+ # render section header
+ cat_messages = list(category["messages"].items())
+ cat_keys = cat_messages[0][1].keys()
+ headers_html = ""
+ colspan = 10 - len(cat_keys)
+ for key in cat_keys:
+ headers_html += HTML_CATEGORY_HEADER_CELL.format(key)
+ category_html = HTML_CATEGORY_HEADER.format(colspan=colspan, label=category["name"], cells=headers_html)
+
+ # render message coverage row
+ for message_id, covered in cat_messages:
+ category_html_row = ""
+ for key, value in covered.items():
+ category_html_row += HTML_CATEGORY_COVERAGE_CELL.format("uncovered" if value != True else "covered")
+ category_html += HTML_CATEGORY_ROW.format(id=message_id,colspan=colspan, cells=category_html_row)
+ categories_html += HTML_CATEGORY_SECTION.format(id=name, rows=category_html)
+
+ # render category summaries
+ summary_stdout += STDOUT_REPORT_CATEGORY.format(**category)
+ summary_html += HTML_SUMMARY_ROW.format(**category)