diff --git a/pykat/testing/test.py b/pykat/testing/test.py index 670618c2c5391e772116de52237970bf94c51084..6439f3dbca2ea2a54e7dcda7a9a5649797a7811d 100644 --- a/pykat/testing/test.py +++ b/pykat/testing/test.py @@ -54,6 +54,7 @@ class FinesseTestProcess(Thread): running_suite = "" cancelling = False errorOccurred = None + diffFound = False def __init__(self, TEST_DIR, BASE_DIR, test_commit, run_fast=False, suites=[], test_id="0", @@ -295,11 +296,12 @@ class FinesseTestProcess(Thread): for out in outs: self.cancelCheck() - #print "Diffing " + out + ref_file = os.path.join(REF_DIR,out) if not os.path.exists(ref_file): raise DiffException("Reference file doesn't exist for " + out, out) + ref_arr = np.loadtxt(ref_file) out_arr = np.loadtxt(out) @@ -316,6 +318,7 @@ class FinesseTestProcess(Thread): diff = np.any(rel_diff >= self.diff_rel_eps) if diff: + self.diffFound = True # store the rows which are different ix = np.where(rel_diff >= self.diff_rel_eps)[0][0] output_differences[suite][out] = (ref_arr[ix], out_arr[ix], np.max(rel_diff)) @@ -384,10 +387,13 @@ class FinesseTestProcess(Thread): def run(self): try: + raise Exception("Test exception") self.startFinesseTest() except Exception as ex: + exc_type, exc_value, exc_traceback = sys.exc_info() - errorOccurred = dict(type=exc_type, value=exc_value, traceback=exc_traceback) + + self.errorOccurred = dict(value=str(exc_value), traceback=str(traceback.format_exc(5))) print "*** Exception for test_id = " + str(self.test_id) traceback.print_exception(exc_type, exc_value, exc_traceback, diff --git a/pykat/testing/web/templates/finesse_test.html b/pykat/testing/web/templates/finesse_test.html index 16461216db60a3c159be98c2bbfdac20f4056116..f82cf266d10fba350db5d2d1a75a2bf64c2b1bbf 100644 --- a/pykat/testing/web/templates/finesse_test.html +++ b/pykat/testing/web/templates/finesse_test.html @@ -54,7 +54,7 @@ <div class="prev_test"> <h2>Previous Tests</h2> <input type="button" value="Refresh" id="btnGetPrevTests"/> - <div id="tblPrevTests" /> + <div id="tblPrevTests" style="width: 900px;" /> </div> </div> @@ -133,9 +133,20 @@ "bLengthChange": true, "aaData": data.tests, "bJQueryUI": true, + "aaSorting" : [[0, 'desc']], + "fnRowCallback": function (nRow, aData){ + if(aData.status == "Running"){ + $(nRow).css({"background-color":"orange"}) + }else if(aData.status == "ERRORS" || aData.status == "Test Exception"){ + $(nRow).css({"background-color":"red"}) + }else if(aData.status == "Not started"){ + $(nRow).css({"background-color":"gray"}) + } + }, "aoColumns": [ { "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) { + console.log(oData["test_id"]); var a = $('<button type="button" style="margin: 0">View</button>').button().on('click', function () { }); @@ -158,9 +169,10 @@ $(nTd).empty(); $(nTd).append(a); $(nTd).append(b); - }, "mDataProp": "test_id", "sWidth": "30%", "bSearchable": false, "sTitle": "", "bSortable": false + }, "mDataProp": "test_id", "bSearchable": false, "sTitle": "", "bSortable": false }, { "mDataProp": "test_id", "sTitle": "Test ID","bSearchable": true, "bVisible": true, "sClass": "center" }, + { "mDataProp": "status", "sTitle": "Status","bSearchable": true, "bVisible": true, "sClass": "center" }, { "mDataProp": "git_commit", "sTitle": "Git Commit", "bSearchable": true, "bVisible": true, "sClass": "center" }, { "mDataProp": "startTime", "sTitle": "Start Time", "bSearchable": false, "bVisible": true, "sClass": "center" }, { "mDataProp": "endTime", "sTitle": "End Time", "bSearchable": false, "bVisible": true, "sClass": "center" } diff --git a/pykat/testing/web/web_interface.py b/pykat/testing/web/web_interface.py index 57bfa8e8273b3312fe61f41b6afa1876d521531a..45d05a41ae9378f3522e04afaa97fb576bca14f8 100644 --- a/pykat/testing/web/web_interface.py +++ b/pykat/testing/web/web_interface.py @@ -108,6 +108,9 @@ class FinesseProcessWatcher(Thread): doc["error"] = self.process_to_watch.errorOccurred doc["startTime"] = str(start) doc["endTime"] = str(datetime.now()) + doc["testRun"] = self.process_to_watch.finished_test + doc["diffFound"] = self.process_to_watch.diffFound + db.update(doc) try: @@ -246,7 +249,9 @@ def finesse_start_test(): test_id=test.test_id, git_commit=test.get_version(), cancelled=test.cancelling, - error=test.errorOccurred)) + error=test.errorOccurred, + diffFound=test.diffFound, + testRun=test.finished_test)) __run_new(test) finally: @@ -351,14 +356,13 @@ def finesse_get_prev_tests(count): try: data = db.all('testid',with_doc=True) - #db.get_many('testid',start=min,end=max,limit=-1, with_doc=True) for a in data: i = a["doc"] err = (not i['error'] is None) - + if "startTime" in i: startTime = i["startTime"] else: @@ -369,13 +373,28 @@ def finesse_get_prev_tests(count): else: endTime = "" + global current_test + + if current_test is not None and current_test.test_id == i["test_id"]: + status = "Running" + elif err: + status = "Test Exception" + elif i["cancelled"] == True: + status = "Cancelled" + elif "diffFound" in i and i["diffFound"] == True: + status = "ERRORS" + elif "testRun" in i and i["testRun"] == False: + status = "Not started" + else: + status = "OK" + obj = dict(test_id=i['test_id'], git_commit=i['git_commit'], - error=err, + status=status, startTime=startTime, endTime=endTime) - rtn.append(obj) + rtn.insert(0,obj) return jsonify(tests=rtn)