def _testFilename(inputname, outputname): import AUTOclui, AUTOutil, runAUTO old_path = os.getcwd() log = open("log", "w") os.environ["LANG"] = "C" console = AUTOInteractiveConsole(AUTOclui.exportFunctions(log=log)) console.execfile(inputname) console.close() log.close() os.chdir(old_path) cmd = [ "diff", "-b", "--ignore-matching-lines='.*ab\.o.*'", "--ignore-matching-lines='.*cir\.o.*'", "--ignore-matching-lines='.*wav\.o.*'", "--ignore-matching-lines=' [0-9][0-9 ] .*'", "--ignore-matching-lines='Finished running:.*'", "--ignore-matching-lines='.*Location of special point.*'", "--ignore-matching-lines='[uU]sing .*'", "--ignore-matching-lines='.*Total Time.*'", "log", outputname ] status, output = AUTOutil.getstatusoutput(cmd) if status != 0: raise AUTOExceptions.AUTORegressionError( "Error: log files differ:\n%s" % output) os.system("rm -f log")
def test(): import os import sys import AUTOutil log = open("log", "w") err = open("err", "w") stdout = sys.stdout class teelog(object): def write(self, text): log.write(text) stdout.write(text) def flush(self): log.flush() stdout.flush() runDemo("ab", log=teelog(), err=err, makefile="", demos_dir=os.path.join(os.environ["AUTO_DIR"], "python"), clean="yes") log.close() err.close() diffopts = [ "diff", "-b", "--ignore-matching-lines='.*Total Time.*'", "--ignore-matching-lines='.*ab\.o.*'", "--ignore-matching-lines=' [0-9] .*'" ] status, output = AUTOutil.getstatusoutput(diffopts + ["log", "test_data/runDemo.log"]) if status != 0: raise AUTOExceptions.AUTORegressionError("Log files differ") status, output = AUTOutil.getstatusoutput(diffopts + ["err", "test_data/runDemo.err"]) if status != 0: raise AUTOExceptions.AUTORegressionError("Error files differ") os.remove("log") os.remove("err")