diff options
Diffstat (limited to 'cpp/test/Slice/errorDetection/run.py')
-rwxr-xr-x | cpp/test/Slice/errorDetection/run.py | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/cpp/test/Slice/errorDetection/run.py b/cpp/test/Slice/errorDetection/run.py index abd3b0053b6..cd4f11068ef 100755 --- a/cpp/test/Slice/errorDetection/run.py +++ b/cpp/test/Slice/errorDetection/run.py @@ -10,26 +10,21 @@ import os, sys, re -for toplevel in [".", "..", "../..", "../../..", "../../../.."]: - toplevel = os.path.normpath(toplevel) - if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")): - break -else: - raise "can't find toplevel directory!" +path = [ ".", "..", "../..", "../../..", "../../../.." ] +head = os.path.dirname(sys.argv[0]) +if len(head) > 0: + path = [os.path.join(head, p) for p in path] +path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] +if len(path) == 0: + raise "can't find toplevel os.getcwd()!" +sys.path.append(os.path.join(path[0])) +from scripts import * -# -# For LD_LIBRARY_PATH and similar env variables -# -sys.path.append(os.path.join(toplevel, "config")) -import TestUtil -TestUtil.processCmdLine() - -directory = os.path.dirname(os.path.abspath(__file__)) slice2cpp = os.path.join(TestUtil.getCppBinDir(), "slice2cpp") -regex1 = re.compile(r"\.ice$", re.IGNORECASE) +regex1 = re.compile("\.ice$", re.IGNORECASE) files = [] -for file in os.listdir(directory): +for file in os.listdir(os.getcwd()): if(regex1.search(file)): files.append(file) @@ -40,17 +35,17 @@ for file in files: print file + "...", if file == "CaseSensitive.ice": - command = slice2cpp + " --case-sensitive -I. " + os.path.join(directory, file); + command = slice2cpp + " --case-sensitive -I. " + os.path.join(os.getcwd(), file); else: - command = slice2cpp + " -I. " + os.path.join(directory, file); + command = slice2cpp + " -I. " + os.path.join(os.getcwd(), file); stdin, stdout, stderr = os.popen3(command) lines1 = stdout.readlines() - lines2 = open(os.path.join(directory, regex1.sub(".err", file)), "r").readlines() + lines2 = open(os.path.join(os.getcwd(), regex1.sub(".err", file)), "r").readlines() if len(lines1) != len(lines2): print "failed!" sys.exit(1) - regex2 = re.compile(r"^.*(?=" + file + ")") + regex2 = re.compile("^.*(?=" + file + ")") i = 0 while i < len(lines1): line1 = regex2.sub("", lines1[i]).strip() |