summaryrefslogtreecommitdiff
path: root/cpp/test/Slice
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2016-11-25 13:13:22 +0100
committerBenoit Foucher <benoit@zeroc.com>2016-11-25 13:13:22 +0100
commitdcdc32af1fced49d80a8ccd93230e15d91ab45d8 (patch)
treeeb69e2555fbd54496fce8a33f4dd610e1473ff51 /cpp/test/Slice
parentC# IceSSL/configuration log expired certificate exceptions. (diff)
downloadice-dcdc32af1fced49d80a8ccd93230e15d91ab45d8.tar.bz2
ice-dcdc32af1fced49d80a8ccd93230e15d91ab45d8.tar.xz
ice-dcdc32af1fced49d80a8ccd93230e15d91ab45d8.zip
Refactored test scripts
Diffstat (limited to 'cpp/test/Slice')
-rwxr-xr-xcpp/test/Slice/errorDetection/run.py69
-rw-r--r--cpp/test/Slice/errorDetection/test.py49
-rwxr-xr-xcpp/test/Slice/headers/run.py156
-rw-r--r--cpp/test/Slice/headers/test.py154
-rw-r--r--cpp/test/Slice/keyword/Client.cpp2
-rwxr-xr-xcpp/test/Slice/keyword/run.py24
-rwxr-xr-xcpp/test/Slice/macros/run.py24
-rwxr-xr-xcpp/test/Slice/structure/run.py24
-rw-r--r--cpp/test/Slice/unicodePaths/run.py82
-rw-r--r--cpp/test/Slice/unicodePaths/test.py71
10 files changed, 275 insertions, 380 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() ])
diff --git a/cpp/test/Slice/headers/run.py b/cpp/test/Slice/headers/run.py
deleted file mode 100755
index 0747f0c8e63..00000000000
--- a/cpp/test/Slice/headers/run.py
+++ /dev/null
@@ -1,156 +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 directory!")
-sys.path.append(os.path.join(path[0], "scripts"))
-import TestUtil
-
-def clean():
- for f in ["iceslices",
- "linktoslices",
- os.path.join("slices", "linktodir2"),
- os.path.join("slices", "linktodir1"),
- os.path.join("slices", "dir1", "linktoa3.ice")]:
- if os.path.exists(f):
- os.unlink(f)
- os.system("rm -rf project1 tmp")
-
-clean()
-os.symlink("slices", "linktoslices")
-os.symlink("dir1", os.path.join("slices", "linktodir1"))
-os.symlink("a3.ice", os.path.join("slices", "dir1", "linktoa3.ice"))
-os.symlink("dir2", os.path.join("slices", "linktodir2"))
-
-slice2cpp = TestUtil.getSliceTranslator()
-TestUtil.addLdPath(TestUtil.getCppLibDir())
-
-basedir = os.path.dirname(os.path.abspath(__file__))
-slicedir = TestUtil.getSliceDir()
-os.symlink(slicedir, "iceslices")
-
-def runTest(cmd):
- os.system(cmd)
- f = open("b.h")
- if not re.search('#include <dir1\/a1\.h>\n'
- '#include <linktodir1\/a2\.h>\n'
- '#include <linktodir1\/linktoa3\.h>\n'
- '#include <Ice\/Identity\.h>\n', f.read(), re.S):
- print("failed!")
- sys.exit(1)
- os.unlink("b.h")
- os.unlink("b.cpp")
-
-sys.stdout.write("compiling slice files and checking headers... ")
-sys.stdout.flush()
-runTest("%s -Iiceslices -Islices slices/dir2/b.ice" % (slice2cpp))
-runTest("%s -Iiceslices -I../headers/slices slices/dir2/b.ice" % (slice2cpp))
-runTest("%s -Iiceslices -Ilinktoslices slices/dir2/b.ice" % (slice2cpp))
-runTest("%s -Iiceslices -Ilinktoslices/../linktoslices slices/dir2/b.ice" % (slice2cpp))
-runTest("%s -I%s -Islices linktoslices/dir2/b.ice" % (slice2cpp, slicedir))
-runTest("%s -I%s -Ilinktoslices linktoslices/linktodir2/b.ice" % (slice2cpp, slicedir))
-
-# Also ensure it works with case insensitive file system
-if os.path.exists("SLICES"):
- runTest("%s -IICESLICES -ISLICES SLICES/DIR2/B.ice" % (slice2cpp))
- runTest("%s -IICESLICES -ILINKTOSLICES LINKTOSLICES/LINKTODIR2/B.ice" % (slice2cpp))
-
-#
-# Slice files are symlinks, include dir is a regular directory
-#
-os.system("mkdir -p project1/git/services.settings.slices")
-os.system("mkdir -p project1/src/services/settings")
-os.system("cd project1/src/services/settings && ln -s ../../../git/services.settings.slices slices")
-
-f = open("project1/git/services.settings.slices/A.ice", "w")
-f.write("// dumy file")
-f.close()
-f = open("project1/git/services.settings.slices/B.ice", "w")
-f.write("#include <services/settings/slices/A.ice>")
-f.close()
-
-os.system("cd project1 && %s -Isrc src/services/settings/slices/B.ice" % slice2cpp)
-f = open("project1/B.h")
-
-if not re.search(re.escape('#include <services/settings/slices/A.h>'), f.read()):
- print("failed!")
- sys.exit(1)
-
-clean()
-
-#
-# Slice file is regular file, include dir is a symlink to a second symlink
-#
-os.system("mkdir -p tmp/Ice-x.y.z/share")
-os.system("cd tmp/Ice-x.y.z/share && ln -s %s" % slicedir)
-
-
-os.system("mkdir -p project1/share")
-os.system("cd project1/share && ln -s %s/tmp/Ice-x.y.z/share/slice" % basedir)
-f = open("project1/A.ice", "w")
-f.write("#include <Ice/Identity.ice>")
-f.close()
-os.system("cd project1 && %s -Ishare/slice A.ice" % slice2cpp)
-f = open("project1/A.h")
-if not re.search(re.escape('#include <Ice/Identity.h>'), f.read()):
- print("failed!")
- sys.exit(1)
-
-clean()
-
-#
-# Typical Ice install with symlink Ice-x.y -> Ice-x.y.z
-#
-os.system("mkdir -p tmp/Ice-x.y.z/slice/Ice")
-os.system("cd tmp && ln -s Ice-x.y.z Ice-x.y")
-f = open("tmp/Ice-x.y.z/slice/Ice/Identity.ice", "w")
-f.write("// dumy file")
-
-os.system("mkdir -p project1")
-f = open("project1/A.ice", "w")
-f.write("#include <Ice/Identity.ice>")
-f.close()
-os.system("cd project1 && %s -I%s/tmp/Ice-x.y/slice A.ice" % (slice2cpp, basedir))
-f = open("project1/A.h")
-if not re.search(re.escape('#include <Ice/Identity.h>'), f.read()):
- print("failed!")
- sys.exit(1)
-
-clean()
-
-#
-# symlink directory with extra / at end
-#
-#
-os.system("mkdir -p tmp/Ice-x.y.z/slice/Ice")
-os.system("mkdir -p tmp/Ice")
-os.system("cd tmp/Ice && ln -s ../Ice-x.y.z/slice/ .")
-f = open("tmp/Ice-x.y.z/slice/Ice/Identity.ice", "w")
-f.write("// dumy file")
-f.close()
-os.system("mkdir -p project1")
-f = open("project1/A.ice", "w")
-f.write("#include <Ice/Identity.ice>")
-f.close()
-os.system("cd project1 && %s -I%s/tmp/Ice/slice A.ice" % (slice2cpp, basedir))
-f = open("project1/A.h")
-if not re.search(re.escape('#include <Ice/Identity.h>'), f.read()):
- print("failed!2")
- sys.exit(1)
-clean()
-
-print("ok")
diff --git a/cpp/test/Slice/headers/test.py b/cpp/test/Slice/headers/test.py
new file mode 100644
index 00000000000..a5c169ede49
--- /dev/null
+++ b/cpp/test/Slice/headers/test.py
@@ -0,0 +1,154 @@
+# -*- 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 SliceHeadersTestCase(ClientTestCase):
+
+ def runClientSide(self, current):
+ self.clean()
+
+ slice2cpp = SliceTranslator("slice2cpp")
+
+ os.symlink("slices", "linktoslices")
+ os.symlink("dir1", os.path.join("slices", "linktodir1"))
+ os.symlink("a3.ice", os.path.join("slices", "dir1", "linktoa3.ice"))
+ os.symlink("dir2", os.path.join("slices", "linktodir2"))
+
+ basedir = self.testsuite.getPath()
+ slicedir = current.driver.getSliceDir()
+ os.symlink(slicedir, "iceslices")
+
+ def runTest(args):
+ slice2cpp.run(current, args=args.split(" "))
+ f = open("b.h")
+ if not re.search('#include <dir1\/a1\.h>\n'
+ '#include <linktodir1\/a2\.h>\n'
+ '#include <linktodir1\/linktoa3\.h>\n'
+ '#include <Ice\/Identity\.h>\n', f.read(), re.S):
+ raise RuntimeError("failed!")
+
+ os.unlink("b.h")
+ os.unlink("b.cpp")
+
+ current.write("compiling slice files and checking headers... ")
+ runTest("-Iiceslices -Islices slices/dir2/b.ice")
+ runTest("-Iiceslices -I../headers/slices slices/dir2/b.ice")
+ runTest("-Iiceslices -Ilinktoslices slices/dir2/b.ice")
+ runTest("-Iiceslices -Ilinktoslices/../linktoslices slices/dir2/b.ice")
+ runTest("-I%s -Islices linktoslices/dir2/b.ice" % slicedir)
+ runTest("-I%s -Ilinktoslices linktoslices/linktodir2/b.ice" % slicedir)
+
+ # Also ensure it works with case insensitive file system
+ if os.path.exists("SLICES"):
+ runTest("-IICESLICES -ISLICES SLICES/DIR2/B.ice")
+ runTest("-IICESLICES -ILINKTOSLICES LINKTOSLICES/LINKTODIR2/B.ice")
+
+ slice2cpp = slice2cpp.getCommandLine(current)
+
+ #
+ # Slice files are symlinks, include dir is a regular directory
+ #
+ os.system("mkdir -p project1/git/services.settings.slices")
+ os.system("mkdir -p project1/src/services/settings")
+ os.system("cd project1/src/services/settings && ln -s ../../../git/services.settings.slices slices")
+
+ f = open("project1/git/services.settings.slices/A.ice", "w")
+ f.write("// dumy file")
+ f.close()
+ f = open("project1/git/services.settings.slices/B.ice", "w")
+ f.write("#include <services/settings/slices/A.ice>")
+ f.close()
+
+ os.system("cd project1 && %s -Isrc src/services/settings/slices/B.ice" % slice2cpp)
+ f = open("project1/B.h")
+ if not re.search(re.escape('#include <services/settings/slices/A.h>'), f.read()):
+ raise RuntimeError("failed!")
+
+ self.clean()
+
+ #
+ # Slice file is regular file, include dir is a symlink to a second symlink
+ #
+ os.system("mkdir -p tmp/Ice-x.y.z/share")
+ os.system("cd tmp/Ice-x.y.z/share && ln -s %s" % slicedir)
+
+ os.system("mkdir -p project1/share")
+ os.system("cd project1/share && ln -s %s/tmp/Ice-x.y.z/share/slice" % basedir)
+ f = open("project1/A.ice", "w")
+ f.write("#include <Ice/Identity.ice>")
+ f.close()
+ os.system("cd project1 && %s -Ishare/slice A.ice" % slice2cpp)
+ f = open("project1/A.h")
+ if not re.search(re.escape('#include <Ice/Identity.h>'), f.read()):
+ raise RuntimeError("failed!")
+
+ self.clean()
+
+ #
+ # Typical Ice install with symlink Ice-x.y -> Ice-x.y.z
+ #
+ os.system("mkdir -p tmp/Ice-x.y.z/slice/Ice")
+ os.system("cd tmp && ln -s Ice-x.y.z Ice-x.y")
+ f = open("tmp/Ice-x.y.z/slice/Ice/Identity.ice", "w")
+ f.write("// dumy file")
+
+ os.system("mkdir -p project1")
+ f = open("project1/A.ice", "w")
+ f.write("#include <Ice/Identity.ice>")
+ f.close()
+ os.system("cd project1 && %s -I%s/tmp/Ice-x.y/slice A.ice" % (slice2cpp, basedir))
+ f = open("project1/A.h")
+ if not re.search(re.escape('#include <Ice/Identity.h>'), f.read()):
+ raise RuntimeError("failed!")
+
+ self.clean()
+
+ #
+ # symlink directory with extra / at end
+ #
+ #
+ os.system("mkdir -p tmp/Ice-x.y.z/slice/Ice")
+ os.system("mkdir -p tmp/Ice")
+ os.system("cd tmp/Ice && ln -s ../Ice-x.y.z/slice/ .")
+ f = open("tmp/Ice-x.y.z/slice/Ice/Identity.ice", "w")
+ f.write("// dumy file")
+ f.close()
+ os.system("mkdir -p project1")
+ f = open("project1/A.ice", "w")
+ f.write("#include <Ice/Identity.ice>")
+ f.close()
+ os.system("cd project1 && %s -I%s/tmp/Ice/slice A.ice" % (slice2cpp, basedir))
+ f = open("project1/A.h")
+ if not re.search(re.escape('#include <Ice/Identity.h>'), f.read()):
+ raise RuntimeError("failed!")
+ self.clean()
+
+ current.writeln("ok")
+
+ def teardownClientSide(self, current, success):
+ self.clean()
+
+ def clean(self):
+ for f in ["iceslices",
+ "linktoslices",
+ os.path.join("slices", "linktodir2"),
+ os.path.join("slices", "linktodir1"),
+ os.path.join("slices", "dir1", "linktoa3.ice")]:
+ if os.path.lexists(f):
+ os.unlink(f)
+
+ if os.path.exists("project1"): shutil.rmtree("project1")
+ if os.path.exists("tmp"): shutil.rmtree("tmp")
+
+if not isinstance(platform, Windows):
+ TestSuite(__name__, [ SliceHeadersTestCase() ], chdir=True)
+
+
diff --git a/cpp/test/Slice/keyword/Client.cpp b/cpp/test/Slice/keyword/Client.cpp
index 87f1556485b..661b0b223ac 100644
--- a/cpp/test/Slice/keyword/Client.cpp
+++ b/cpp/test/Slice/keyword/Client.cpp
@@ -170,7 +170,7 @@ testtypes()
int
run(const Ice::CommunicatorPtr& communicator)
{
- communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010:udp");
+ communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
adapter->add(ICE_MAKE_SHARED(charI), Ice::stringToIdentity("test"));
adapter->activate();
diff --git a/cpp/test/Slice/keyword/run.py b/cpp/test/Slice/keyword/run.py
deleted file mode 100755
index d06758d0994..00000000000
--- a/cpp/test/Slice/keyword/run.py
+++ /dev/null
@@ -1,24 +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
-
-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 directory!")
-sys.path.append(os.path.join(path[0], "scripts"))
-import TestUtil
-
-client = os.path.join(os.getcwd(), TestUtil.getTestExecutable("client"))
-TestUtil.simpleTest(client)
diff --git a/cpp/test/Slice/macros/run.py b/cpp/test/Slice/macros/run.py
deleted file mode 100755
index d06758d0994..00000000000
--- a/cpp/test/Slice/macros/run.py
+++ /dev/null
@@ -1,24 +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
-
-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 directory!")
-sys.path.append(os.path.join(path[0], "scripts"))
-import TestUtil
-
-client = os.path.join(os.getcwd(), TestUtil.getTestExecutable("client"))
-TestUtil.simpleTest(client)
diff --git a/cpp/test/Slice/structure/run.py b/cpp/test/Slice/structure/run.py
deleted file mode 100755
index d06758d0994..00000000000
--- a/cpp/test/Slice/structure/run.py
+++ /dev/null
@@ -1,24 +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
-
-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 directory!")
-sys.path.append(os.path.join(path[0], "scripts"))
-import TestUtil
-
-client = os.path.join(os.getcwd(), TestUtil.getTestExecutable("client"))
-TestUtil.simpleTest(client)
diff --git a/cpp/test/Slice/unicodePaths/run.py b/cpp/test/Slice/unicodePaths/run.py
deleted file mode 100644
index c8f999a0cab..00000000000
--- a/cpp/test/Slice/unicodePaths/run.py
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/env python
-# -*- 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 os, sys, locale, shutil
-
-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 directory!")
-sys.path.append(os.path.join(path[0], "scripts"))
-import TestUtil
-
-def test(b):
- if not b:
- print("failed!")
- sys.exit(1)
-
-if TestUtil.isAIX() or TestUtil.isLinux():
- encoding = locale.getdefaultlocale()[1]
- if encoding != "UTF-8":
- print("Please set LC_ALL to xx_xx.UTF-8, for example FR_FR.UTF-8")
- print("Skipping test")
- sys.exit(0)
-
-if sys.version_info[0] == 2 and TestUtil.isWin32():
- print("To run this test on Windows you need to be using Python 3.x")
- print("Python 2.x subprocess module doesn't support unicode on Windows")
- print("Skipping tes")
- sys.exit(0)
-
-sys.stdout.write("testing Slice compiler and unicode file paths... ")
-sys.stdout.flush()
-tests = [
- ("cpp", ["Test.cpp", "Test.h", "TestI.cpp", "TestI.h"], "--impl-c++11"),
- ("cpp", ["Test.cpp", "Test.h", "TestI.cpp", "TestI.h"], "--impl-c++98"),
- ("cs", ["Test.cs", "TestI.cs"], "--impl"),
- ("html", ["index.html"], ""),
- ("java", ["Test/Point.java", "Test/CanvasI.java"], "--impl"),
- ("js", ["Test.js"], ""),
- ("objc", ["Test.m"], ""),
- ("php", ["Test.php"], "")]
-
-#
-# Write config
-#
-if sys.version_info[0] == 2:
- srcPath = "./\xe4\xb8\xad\xe5\x9b\xbd".decode("utf-8")
-else:
- srcPath = "./\u4e2d\u56fd"
-if os.path.exists(srcPath):
- shutil.rmtree(srcPath)
-os.mkdir(srcPath)
-TestUtil.createFile("%s/Test.ice" % srcPath, ["module Test { ",
- "class Point{int x; int y; };",
- "interface Canvas{ void draw(Point p); };",
- "};"], "utf-8")
-
-for language, generated, args in tests:
- compiler = '%s' % TestUtil.getSliceTranslator(language)
- if not os.path.isfile(compiler):
- continue
- p = TestUtil.runCommand('"%s" %s/Test.ice --output-dir %s %s' % (compiler, srcPath, srcPath, args))
- test(p.wait() == 0)
- for f in generated:
- test(os.path.isfile(os.path.join(srcPath, f)))
- os.remove(os.path.join(srcPath, f))
-
-
-if os.path.exists(srcPath):
- shutil.rmtree(srcPath)
-print("ok")
diff --git a/cpp/test/Slice/unicodePaths/test.py b/cpp/test/Slice/unicodePaths/test.py
new file mode 100644
index 00000000000..95923fc10c2
--- /dev/null
+++ b/cpp/test/Slice/unicodePaths/test.py
@@ -0,0 +1,71 @@
+# -*- 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 shutil, locale
+
+class SliceUnicodePathsTestCase(ClientTestCase):
+
+ def runClientSide(self, current):
+
+ if isinstance(platform, Linux) or isinstance(platform, AIX):
+ encoding = locale.getdefaultlocale()[1]
+ if encoding != "UTF-8":
+ current.writeln("Please set LC_ALL to xx_xx.UTF-8, for example FR_FR.UTF-8")
+ current.writeln("Skipping test")
+ return
+ elif isinstance(platform, Windows) and isPython2:
+ current.writeln("To run this test on Windows you need to be using Python 3.x")
+ current.writeln("Python 2.x subprocess module doesn't support unicode on Windows")
+ current.writeln("Skipping test")
+ return
+
+ current.write("testing Slice compiler and unicode file paths... ")
+
+ srcPath = "./\xe4\xb8\xad\xe5\x9b\xbd" if isPython2 else "./\u4e2d\u56fd"
+
+ if os.path.exists(srcPath): shutil.rmtree(srcPath)
+ os.mkdir(srcPath)
+
+ self.createFile("%s/Test.ice" % srcPath,
+ ["module Test { ",
+ "class Point{int x; int y; };",
+ "interface Canvas{ void draw(Point p); };",
+ "};"], "utf-8")
+
+ tests = [
+ ("cpp", ["Test.cpp", "Test.h", "TestI.cpp", "TestI.h"], "--impl-c++11"),
+ ("cpp", ["Test.cpp", "Test.h", "TestI.cpp", "TestI.h"], "--impl-c++98"),
+ ("cs", ["Test.cs", "TestI.cs"], "--impl"),
+ ("html", ["index.html"], ""),
+ ("java", ["Test/Point.java", "Test/CanvasI.java"], "--impl"),
+ ("js", ["Test.js"], ""),
+ ("objc", ["Test.m"], ""),
+ ("php", ["Test.php"], "")]
+
+ try:
+ for language, generated, args in tests:
+ compiler = SliceTranslator('slice2%s' % language)
+ if not os.path.isfile(compiler.getCommandLine(current)):
+ continue
+
+ args = [srcPath + "/Test.ice", "--output-dir", srcPath] + args.split(" ")
+ compiler.run(current, args=args)
+
+ for f in generated:
+ if not os.path.isfile(os.path.join(srcPath, f)):
+ raise RuntimeError("failed! (can't find {0})".format(os.path.join(srcPath, f)))
+ os.remove(os.path.join(srcPath, f))
+
+ current.writeln("ok")
+
+ finally:
+ if os.path.exists(srcPath): shutil.rmtree(srcPath)
+
+TestSuite(__name__, [ SliceUnicodePathsTestCase() ], chdir=True)