diff --git a/pykat/testing/test.py b/pykat/testing/test.py index 3864445f0bbffb1f16fe28a3289faf72bb21c5ef..30d4b4062b00c95d768deada839ae58c6d4165fd 100644 --- a/pykat/testing/test.py +++ b/pykat/testing/test.py @@ -60,12 +60,6 @@ class FinesseTestProcess(Thread): self.TEST_DIR = TEST_DIR self.BASE_DIR = BASE_DIR - if os.path.exists(self.BASE_DIR): - print "Deleting previous base_dir " + BASE_DIR - shutil.rmtree(self.BASE_DIR) - - os.mkdir(self.BASE_DIR) - self.emails = "" if type(nobuild) is str: @@ -135,6 +129,13 @@ class FinesseTestProcess(Thread): # Firstly we need to build the latest version of finesse if not self.nobuild: + + if os.path.exists(self.BASE_DIR): + print "Deleting previous base_dir " + self.BASE_DIR + shutil.rmtree(self.BASE_DIR) + + os.mkdir(self.BASE_DIR) + print "deleting build dir..." + BUILD_PATH if os.path.exists(BUILD_PATH): shutil.rmtree(BUILD_PATH) @@ -164,20 +165,29 @@ class FinesseTestProcess(Thread): utils.runcmd(["./finesse.sh","--build"],cwd=BUILD_PATH) self.cancelCheck() - + FINESSE_EXE = os.path.join(self.BASE_DIR,"build","kat" + EXE) # check if kat runs if not os.path.exists(FINESSE_EXE): raise Exception("Kat file was not found in " + FINESSE_EXE) - # check version numbers match up - out = utils.runcmd([FINESSE_EXE]) + out = None + - shortid = out[0].split("\n")[2].split("(build ")[-1].rstrip(")").split("-")[-1].lstrip("g") + # check version numbers match up + out = utils.runcmd([FINESSE_EXE,"-v"]) + + # I am sure there is a regex expression that could make this + # easier but I am being lazy + out = out[0] + out = out.split("\n") + out = out[0].split("(")[1].split(")") + out = out[0].split("-")[-1] + shortid = out.lstrip("g") if shortid != self.git_commit[0:len(shortid)]: - raise Exception("Version of kat did not match the version that it was requested to build. Not sure why...") + raise Exception("Version of kat {0} did not match the version that it was requested to build {1}.".format(shortid, self.git_commit[0:len(shortid)])) self.built = True diff --git a/pykat/testing/utils.py b/pykat/testing/utils.py index 0e68a7f28417f13b1d48275aaf6f4c7935ad6c98..ae8b361dfac7928c11910a00543892e9c3d18c1e 100644 --- a/pykat/testing/utils.py +++ b/pykat/testing/utils.py @@ -20,7 +20,7 @@ def runcmd(args, cwd="."): out, err = p.communicate() if p.returncode != 0: - print "STDERR: " + err + print "STDERR: " + errk print "STDOUT: " + out raise RunException(p.returncode, args, err, out) diff --git a/pykat/testing/web/web_interface.py b/pykat/testing/web/web_interface.py index 21a405ba8bed692b2691fc4321848c13872298c0..8ab97008868c9716dc8fb103f1a55111c5f5335e 100644 --- a/pykat/testing/web/web_interface.py +++ b/pykat/testing/web/web_interface.py @@ -115,6 +115,26 @@ class FinesseProcessWatcher(Thread): print "Watcher is continuing" try: + # store a copy of the kat file for future use if a nobuild is + # requested from the user. + if sys.platform == "win32": + EXE = ".exe" + else: + EXE = "" + + KAT_EXE = os.path.join(app.instance_path,"tests",str(self.process_to_watch.test_id),"build","kat" + EXE) + KAT_STORE_PATH = os.path.join(app.instance_path,"kat_store") + KAT_STORE_EXE = os.path.join(KAT_STORE_PATH,"kat_" + str(self.process_to_watch.get_version()) + EXE) + + if not os.path.exists(KAT_STORE_PATH): + os.mkdir(KAT_STORE_PATH) + + if os.path.exists(KAT_EXE): + if os.path.exists(KAT_STORE_EXE): + os.remove(KAT_STORE_EXE) + + shutil.copyfile(KAT_EXE, KAT_STORE_EXE) + testdoc = db.get('testid', self.process_to_watch.test_id, with_doc=True)["doc"] @@ -177,7 +197,7 @@ class FinesseProcessWatcher(Thread): doc["timing"].append(self.process_to_watch.run_times[suite][kat]) db.insert(doc) - + #finally update with details on the kat files ran testdoc["kats_run"] = kats_run db.update(testdoc)