def getty_csi_init(html_file, iso): with open(html_file, 'r+') as f: html_string = f.read() anchor = "__getty_stub__" isolation_ctrl = "<div id='csi-iso-ctrl' style='display:none;'><p>No Impact Isolation</p></div>\n" if iso: iso_links = "" active_style = "color:blue;background:whitesmoke;" inactive_style = "color:gray;background:linear-gradient(whitesmoke, lightgray);" for iso_type, iso_text, link_style, tiptext in [ ("ni", "Source & Test Change", active_style, "old src & tests\nvs.\nnew src & tests"), ("si", "Source Change Only", inactive_style, "old vs. new src\n(with same tests)"), ("ti4o", "Test Change (for OLD Source)", inactive_style, "old tests vs. new tests\n(both for old src)"), ("ti4n", "Test Change (for NEW Source)", inactive_style, "old tests vs. new tests\n(both for new src)")]: iso_links += \ " <a id='csi-iso-link-" + iso_type + "' class='csi-iso-ctrl-group' href='#' " + \ " style='" + link_style + "' " + \ "onclick='return iso_type_reset(\"" + iso_type + "\");'>" + iso_text + \ "<span class='iso-type-tip'><pre>" + tiptext + "</pre></span></a>\n" iso_links = "<div class='link-button-tabs-bottom'>" + iso_links + "</div>" isolation_ctrl = "<div id='csi-iso-ctrl' style='margin-top:10px;'>\n" + \ " <span class='more-inv-display-option-listing menu-words'>Invariant Changes Due To:</span>\n" + \ iso_links + "</div>\n" legends = "<div style='float:right;'>" + \ "<span class='menu-words' style='margin-left: 32px;'>Legends: </span>" + \ "<span class='program-words'>" + \ "<span><u>code-changed</u> </span>" + \ "<span style='color:red;'>invariant-changed</span> " + \ "<span style='color:darkgray;'>invariant-unchanged</span> " + \ "<span>...(#old-calls + #newly-added)</span>" + \ "</span></div>" html_string = html_string.replace(anchor, "<div id='csi-output-targets'></div>\n" + \ "<div id='csi-output-neighbors-outer'>" + \ " <div id='csi-output-menu' class='menu-words'>" + \ "<span style='margin-right:4px;'>More Methods </span>\n" + \ " " + create_show_hide_toggle("onoffswitch", "moremethodscb", "return toggle_show_invequal();") + \ "<span style='margin: 0px 4px 0 80px;'>Tests </span>" + \ " " + create_show_hide_toggle("onoffswitch", "moretestscb", "return toggle_show_tests();") + \ legends + \ " </div>\n" + \ " <div id='csi-output-neighbors' style='margin:8px;'>" + \ " <div style='text-align: center;'>" + \ "Choose a method/class from above to show its invocation neighbors." + \ " </div>\n" + \ " </div>\n" + \ "</div>\n" + \ "<div id='csi-output-invcomp-outer'>\n" + isolation_ctrl + \ " <div id='csi-output-invcomp' style='margin: 8px 2px;'>" + \ " <div style='margin: 8px 4px; text-align: center;'>Invariant differentials will be shown here." + \ "</div></div></div>") f.seek(0) f.truncate() f.write(html_string)
def getty_csi_init(html_file, iso): with open(html_file, 'r+') as f: html_string = f.read() anchor = "__getty_stub__" isolation_ctrl = "<div id='csi-iso-ctrl' style='display:none;'><p>No Impact Isolation</p></div>\n" if iso: iso_links = "" active_style = "color:blue;background:whitesmoke;" inactive_style = "color:gray;background:linear-gradient(whitesmoke, lightgray);" for iso_type, iso_text, link_style, tiptext in [ ("ni", "Source & Test Change", inactive_style, "old src & tests\nvs.\nnew src & tests"), ("si", "Source Change Only", active_style, "old vs. new src\n(with same tests)"), ("ti4o", "Test Change (for OLD Source)", inactive_style, "old tests vs. new tests\n(both for old src)"), ("ti4n", "Test Change (for NEW Source)", inactive_style, "old tests vs. new tests\n(both for new src)") ]: iso_links += \ " <a id='csi-iso-link-" + iso_type + "' class='csi-iso-ctrl-group' href='#' " + \ " style='" + link_style + "' " + \ "onclick='return iso_type_reset(\"" + iso_type + "\");'>" + iso_text + \ "<span class='iso-type-tip'><pre>" + tiptext + "</pre></span></a>\n" iso_links = "<div class='link-button-tabs-bottom'>" + iso_links + "</div>" isolation_ctrl = "<div id='csi-iso-ctrl' style='margin-top:10px;'>\n" + \ " <span class='more-inv-display-option-listing menu-words'>Invariant Changes Due To:</span>\n" + \ iso_links + "</div>\n" html_string = html_string.replace(anchor, "<div id='csi-output-targets'></div>\n" + \ "<div id='csi-output-neighbors-outer'>" + \ " <div id='csi-output-menu' class='menu-words'>" + \ "<span style='margin-right:4px;'>Methods without invariant changes </span>\n" + \ " " + create_show_hide_toggle("onoffswitch", "moremethodscb", "return toggle_show_invequal();") + "\n" + \ "<span style='margin: 0px 4px 0 80px;'>Test cases </span>" + \ " " + create_show_hide_toggle("onoffswitch", "moretestscb", "return toggle_show_tests();") + "\n" + \ " " + create_legends_tooltip() + "\n" + \ " </div>\n" + \ " <div id='csi-output-neighbors' style='margin:8px;'>" + \ " <div style='text-align: center;'>" + \ "Choose a method/class from above to show its invocation neighbors." + \ " </div>\n" + \ " </div>\n" + \ "</div>\n" + \ "<div id='csi-output-invcomp-outer'>\n" + isolation_ctrl + \ " <div id='csi-output-invcomp' style='margin: 8px 2px;'>" + \ " <div style='margin: 8px 4px; text-align: center;'>Invariant differentials will be shown here." + \ "</div></div></div>") f.seek(0) f.truncate() f.write(html_string)
<meta property="dc:modified" content="{4}" /> <meta name="description" content="{2}" /> <meta property="dc:abstract" content="{2}" /> </head> """ html_hdr = basic_html_hdr + """ <body style='overflow-y:scroll;'> __getty_stub__ <div style='padding-left:4px;' id='sh-srcdiff-switch'> <div class='menu-words' style='margin: 24px 0 8px 0;'> List of All Code Changes {0} </div></div> <div id='getty-full-code-diff' style="display:none;"> """.format(create_show_hide_toggle('btn-sh-sd', 'btn-sh-sd', '$(\"div#getty-full-code-diff\").toggle();return false;', checked=False)) continue_hdr = """</div> <div style='display:none;padding-left:4px;margin-top:8px;' id='sh-invdiff-switch'> <div class='menu-words' style='margin: 24px 0 8px 0;'> List of Invariant Differentials {0} </div></div> <div id='getty-full-inv-diff' style='display:none;'> """.format(create_show_hide_toggle('btn-sh-id', 'btn-sh-id', '$(\"div#getty-full-inv-diff\").toggle();return false;', checked=False)) footer_info = """<footer> <p><br>--------<br>Generated at {0}. Getty - Semantiful Differentials. </p> </footer> """
def getty_csi_targets_prep(html_file, go, prev_hash, post_hash, common_package, all_changed_tests, old_changed_tests, new_changed_tests, new_modified_src, new_all_src, old_test_set, new_test_set, old_caller_of, old_callee_of, old_pred_of, old_succ_of, new_caller_of, new_callee_of, new_pred_of, new_succ_of, old_refined_target_set, new_refined_target_set, refined_target_set, all_classes_set, iso): # TODO: # Consider to use new_refined_target_set, old_refined_target_set for better results all_whose_inv_changed = set() if config.analyze_tests and not config.limit_interest: all_considered = (set(new_all_src) | set(new_test_set)) elif config.limit_interest: all_considered = refined_target_set else: all_considered = set(new_all_src) for mtd in all_considered: if iso: if is_possibly_different(mtd, go, prev_hash, post_hash, preprocessed=True): all_whose_inv_changed.add(mtd); else: if is_different(mtd, go, prev_hash, post_hash): all_whose_inv_changed.add(mtd); all_whose_clsobj_inv_changed = set() for cls in all_classes_set: if iso: if is_possibly_different(cls, go, prev_hash, post_hash, preprocessed=True): all_whose_clsobj_inv_changed.add(cls) else: if is_different(cls, go, prev_hash, post_hash): all_whose_clsobj_inv_changed.add(cls) with open(html_file, 'r') as rf: html_string = rf.read() targets_place_holder = "<div id='csi-output-targets'></div>" cpkg_disclaimer = "" if common_package != '' and common_package is not None: common_package_display = "<span class='program-words'>" + common_package + "</span>" cpkg_disclaimer = "<div style='float:right;' class='target-top-row menu-words'>" + \ "<b>Common Package:</b> " + common_package_display + "</div>" compare_commit_msgs = "<div class='target-top-row menu-words'><b>Compare Commits:</b> " + \ "<a id='commit-msg-link' href='#'>" + prev_hash + " vs. " + post_hash + "</a></div>" replace_header = \ "<div id='csi-output-targets'>" + cpkg_disclaimer + compare_commit_msgs + \ "<div class='menu-words entry-header'><b>Updated Source:</b></div>" if new_modified_src: replacement = "<div class='target-sep'>,</div>".join( [__link_to_show_neighbors(t, common_package) for t in sorted(list(new_modified_src))]) else: replacement = "<span>None</span>" embed_test_update = "<br><div class='menu-words entry-header'><b>Updated Tests:</b></div>" if all_changed_tests: tests_replacement = "<div class='target-sep'>,</div>".join( [__link_to_show_neighbors(t, common_package) for t in sorted(list(all_changed_tests))]) else: tests_replacement = "<span>None</span>" inv_change_update = \ "<div class='menu-words entry-header'><b>Methods & Classes with Possible Invariant Changes </b></div>" + \ create_show_hide_toggle("onoffswitch", "inv-change-list-sh", "$(\"div#invariant-change-list-divs\").toggle();return false;", checked=False, extra_style="margin-top:8px;") if all_whose_inv_changed or all_whose_clsobj_inv_changed: if all_whose_inv_changed: invch_mtd_replacement = "<span class='menu-words'>Methods: </span>" + \ "<div class='target-sep'>,</div>".join( [__link_to_show_neighbors(t, common_package, "output-invc-highlight") for t in sorted(list(all_whose_inv_changed))]) else: invch_mtd_replacement = "<span class='menu-words'>Methods: None</span>" if all_whose_clsobj_inv_changed: invch_cls_replacement = "<span class='menu-words'>Classes: </span>" + \ "<div class='target-sep'>,</div>".join( [__link_to_show_neighbors(t, common_package, "output-invc-highlight") for t in sorted(list(all_whose_clsobj_inv_changed))]) else: invch_cls_replacement = "<span class='menu-words'>Classes: None</span>" invch_replacement = invch_mtd_replacement + "<br>" + invch_cls_replacement else: invch_replacement = "<span>None</span>" invch_replacement = "<div id='invariant-change-list-divs' style='display:none;'>" + invch_replacement + "</div>" replace_footer = "</div>" html_string = html_string.replace(targets_place_holder, replace_header + replacement + \ embed_test_update + tests_replacement + \ "<div>" + inv_change_update + invch_replacement + "</div>" + \ replace_footer) html_string = _getty_csi_setvars(html_string, go, prev_hash, post_hash, common_package, all_changed_tests, old_changed_tests, new_changed_tests, new_modified_src, new_all_src, old_test_set, new_test_set, old_caller_of, old_callee_of, old_pred_of, old_succ_of, new_caller_of, new_callee_of, new_pred_of, new_succ_of, all_whose_inv_changed, all_whose_clsobj_inv_changed) with open(html_file, 'w') as wf: wf.write(html_string)
</head> """ html_hdr = basic_html_hdr + """ <body style='overflow-y:scroll;'> __getty_stub__ <div style='padding-left:4px;' id='sh-srcdiff-switch'> <div class='menu-words' style='margin: 24px 0 8px 0;'> List of All Code Changes {0} </div></div> <div id='getty-full-code-diff' style="display:none;"> """.format( create_show_hide_toggle( 'btn-sh-sd', 'btn-sh-sd', '$(\"div#getty-full-code-diff\").toggle();return false;', checked=False)) continue_hdr = """</div> <div style='display:none;padding-left:4px;margin-top:8px;' id='sh-invdiff-switch'> <div class='menu-words' style='margin: 24px 0 8px 0;'> List of Invariant Differentials {0} </div></div> <div id='getty-full-inv-diff' style='display:none;'> """.format( create_show_hide_toggle( 'btn-sh-id', 'btn-sh-id', '$(\"div#getty-full-inv-diff\").toggle();return false;',
def getty_csi_targets_prep(html_file, go, prev_hash, post_hash, common_package, all_changed_tests, old_changed_tests, new_changed_tests, all_changed_methods, new_modified_src, new_all_src, old_test_set, new_test_set, old_caller_of, old_callee_of, old_pred_of, old_succ_of, new_caller_of, new_callee_of, new_pred_of, new_succ_of, old_refined_target_set, new_refined_target_set, refined_target_set, all_classes_set, iso, expansion_set=None): all_whose_inv_changed_candidates = set() if config.analyze_tests and not config.limit_interest: all_considered = (set(new_all_src) | set(new_test_set)) elif config.limit_interest: all_considered = refined_target_set else: all_considered = set(new_all_src) if config.class_level_expansion: all_considered = all_considered | expansion_set for mtd in all_considered: if iso: if is_possibly_different(mtd, go, prev_hash, post_hash, preprocessed=True): all_whose_inv_changed_candidates.add(mtd) else: if is_different(mtd, go, prev_hash, post_hash): all_whose_inv_changed_candidates.add(mtd) all_whose_inv_changed = set() for one_target in all_whose_inv_changed_candidates: if one_target.find(":") != -1: all_whose_inv_changed.add(one_target) all_whose_clsobj_inv_changed = set() for cls in all_classes_set: if iso: if is_possibly_different(cls, go, prev_hash, post_hash, preprocessed=True): all_whose_clsobj_inv_changed.add(cls) else: if is_different(cls, go, prev_hash, post_hash): all_whose_clsobj_inv_changed.add(cls) with open(html_file, 'r') as rf: html_string = rf.read() targets_place_holder = "<div id='csi-output-targets'></div>" cpkg_disclaimer = "" if common_package != '' and common_package is not None: common_package_display = "<span class='program-words'>" + common_package + "</span>" cpkg_disclaimer = "<div style='float:right;' class='target-top-row menu-words'>" + \ "<b>Common Package:</b> " + common_package_display + "</div>" compare_commit_msgs = "<div class='target-top-row menu-words'><b>Compare Commits:</b> " + \ "<a id='commit-msg-link' href='#'>" + prev_hash + " vs. " + post_hash + "</a></div>" replace_header = \ "<div id='csi-output-targets'>" + cpkg_disclaimer + compare_commit_msgs + \ "<div class='menu-words entry-header'><b>Updated Source:</b></div>" all_method_changes = set(all_changed_methods) | set(all_changed_tests) all_class_changes = set() for cm in all_method_changes: colon_pos = cm.find(":") if colon_pos != -1: all_class_changes.add(cm[:colon_pos]) else: all_class_changes.add(cm) if all_changed_methods: replacement = "<div class='target-sep'>,</div>".join([ __link_to_show_neighbors(t, common_package, all_invc_to_check=all_whose_inv_changed) for t in sorted(list(all_changed_methods)) ]) else: replacement = "<span>None</span>" embed_test_update = "<br><div class='menu-words entry-header'><b>Updated Tests:</b></div>" if all_changed_tests: tests_replacement = "<div class='target-sep'>,</div>".join([ __link_to_show_neighbors(t, common_package, all_invc_to_check=all_whose_inv_changed) for t in sorted(list(all_changed_tests)) ]) else: tests_replacement = "<span>None</span>" inv_change_update = \ "<div class='menu-words entry-header'><b>Methods & Classes with Possible Invariant Changes </b></div>" + \ create_show_hide_toggle("onoffswitch", "inv-change-list-sh", "$(\"div#invariant-change-list-divs\").toggle();return false;", checked=True, extra_style="margin-top:8px;") if all_whose_inv_changed or all_whose_clsobj_inv_changed: if all_whose_inv_changed: invch_mtd_replacement = "<span class='menu-words'>Methods: </span>" + \ "<div class='target-sep'>,</div>".join( [__link_to_show_neighbors(t, common_package, all_codec_to_check=all_method_changes) for t in sorted(list(all_whose_inv_changed))]) else: invch_mtd_replacement = "<span class='menu-words'>Methods: None</span>" if all_whose_clsobj_inv_changed: invch_cls_replacement = "<span class='menu-words'>Classes: </span>" + \ "<div class='target-sep'>,</div>".join( [__link_to_show_neighbors(t, common_package, all_codec_to_check=all_class_changes) for t in sorted(list(all_whose_clsobj_inv_changed))]) else: invch_cls_replacement = "<span class='menu-words'>Classes: None</span>" invch_replacement = invch_mtd_replacement + "<br>" + invch_cls_replacement else: invch_replacement = "<span>None</span>" invch_replacement = "<div id='invariant-change-list-divs'>" + invch_replacement + "</div>" replace_footer = "</div>" html_string = html_string.replace(targets_place_holder, replace_header + replacement + \ embed_test_update + tests_replacement + \ "<div>" + inv_change_update + invch_replacement + "</div>" + \ replace_footer) html_string = _getty_csi_setvars( html_string, go, prev_hash, post_hash, common_package, all_changed_tests, old_changed_tests, new_changed_tests, all_changed_methods, new_all_src, old_test_set, new_test_set, old_caller_of, old_callee_of, old_pred_of, old_succ_of, new_caller_of, new_callee_of, new_pred_of, new_succ_of, all_whose_inv_changed, all_whose_clsobj_inv_changed, iso) with open(html_file, 'w') as wf: wf.write(html_string)