diff options
Diffstat (limited to 'cpp/test/Slice/errorDetection')
-rwxr-xr-x | cpp/test/Slice/errorDetection/run.py | 69 | ||||
-rw-r--r-- | cpp/test/Slice/errorDetection/test.py | 49 |
2 files changed, 49 insertions, 69 deletions
diff --git a/cpp/test/Slice/errorDetection/run.py b/cpp/test/Slice/errorDetection/run.py deleted file mode 100755 index d1a194258d4..00000000000 --- a/cpp/test/Slice/errorDetection/run.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python -# ********************************************************************** -# -# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -# -# This copy of Ice is licensed to you under the terms described in the -# ICE_LICENSE file included in this distribution. -# -# ********************************************************************** - -import os, sys, re - -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 RuntimeError("can't find toplevel os.getcwd()!") -sys.path.append(os.path.join(path[0], "scripts")) -import TestUtil - -slice2cpp = '"%s"' % TestUtil.getSliceTranslator() - -regex1 = re.compile("\.ice$", re.IGNORECASE) -files = [] -for file in os.listdir(os.getcwd()): - if(regex1.search(file)): - files.append(file) - -files.sort() - -for file in files: - - sys.stdout.write(file + "... ") - sys.stdout.flush() - - if file.find("Underscore") != -1: - command = slice2cpp + ' --underscore -I. "%s"' % os.path.join(os.getcwd(), file) - else: - command = slice2cpp + ' -I. "%s"' % os.path.join(os.getcwd(), file) - p = TestUtil.runCommand(command) - (stdin, stdout, stderr) = (p.stdin, p.stdout, p.stderr) - - lines1 = stderr.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("^.*(?=" + file + ")") - i = 0 - while i < len(lines1): - if sys.version_info[0] == 2: - line1 = regex2.sub("", lines1[i]).strip() - line2 = regex2.sub("", lines2[i]).strip() - else: - line1 = regex2.sub("", lines1[i].decode("utf-8")).strip() - line2 = regex2.sub("", lines2[i]).strip() - if line1 != line2: - print("\n" + line1) - print("\n" + line2) - print("failed!") - sys.exit(1) - i = i + 1 - else: - print("ok") - -sys.exit(0) diff --git a/cpp/test/Slice/errorDetection/test.py b/cpp/test/Slice/errorDetection/test.py new file mode 100644 index 00000000000..71953c3086c --- /dev/null +++ b/cpp/test/Slice/errorDetection/test.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# ********************************************************************** +# +# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import glob + +class SliceErrorDetectionTestCase(ClientTestCase): + + def runClientSide(self, current): + testdir = self.getPath() + slice2cpp = SliceTranslator("slice2cpp") + + files = glob.glob("{0}/*.ice".format(testdir)) + files.sort() + for file in files: + current.write(os.path.basename(file) + "... ") + + args = ["-I.", file] + if file.find("Underscore") >= 0: + args.append("--underscore") + + # Don't print out slice2cpp output and expect failures + slice2cpp.run(current, args=args, exitstatus=1) + output = slice2cpp.getOutput() + + regex1 = re.compile("\.ice$", re.IGNORECASE) + lines1 = output.strip().split("\n") + lines2 = open(os.path.join(testdir, regex1.sub(".err", file)), "r").readlines() + if len(lines1) != len(lines2): + raise RuntimeError("failed (lines1 = {0}, lines2 = {1})!".format(len(lines1), len(lines2))) + + regex2 = re.compile("^.*(?=" + os.path.basename(file) + ")") + i = 0 + while i < len(lines1): + line1 = regex2.sub("", lines1[i]).strip() + line2 = regex2.sub("", lines2[i]).strip() + if line1 != line2: + raise RuntimeError("failed! (line1 = \"{0}\", line2 = \"{1}\"".format(line1, line2)) + i = i + 1 + else: + current.writeln("ok") + +TestSuite(__name__, [ SliceErrorDetectionTestCase() ]) |