Forcing floating point division for % coverage, so we don't show 0%
[open-adventure.git] / tests / coverage_dungeon.py
old mode 100644 (file)
new mode 100755 (executable)
index 4d0a236..4af9832
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python
 
 # This is the open-adventure dungeon text coverage report generator. It
 # consumes a YAML description of the dungeon and determines whether the
@@ -109,6 +109,7 @@ if __name__ == "__main__":
     location_html = ""
     location_total = len(locations) * 2
     location_covered = 0
+    locations.sort()
     for locouter in locations:
         locname = locouter[0]
         loc = locouter[1]
@@ -125,8 +126,9 @@ if __name__ == "__main__":
             location_covered += 1
 
         location_html += location_row.format(locname, long_success, short_success)
-    location_percent = round((location_covered / location_total) * 100, 1)
+    location_percent = round((location_covered / float(location_total)) * 100, 1)
 
+    arb_msgs.sort()
     arb_msg_html = ""
     arb_total = len(arb_msgs)
     arb_covered = 0
@@ -137,11 +139,12 @@ if __name__ == "__main__":
             success = "covered"
             arb_covered += 1
         arb_msg_html += arb_msg_row.format(name, success)
-    arb_percent = round((arb_covered / arb_total) * 100, 1)
+    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"]):
@@ -152,7 +155,7 @@ if __name__ == "__main__":
                     success = "covered"
                     objects_covered += 1
                 object_html += object_row.format("%s[%d]" % (obj_name, j), success)
-    objects_percent = round((objects_covered / objects_total) * 100, 1)
+    objects_percent = round((objects_covered / float(objects_total)) * 100, 1)
 
     # output some quick report stats
     print("\nadventure.yaml coverage rate:")