diff options
author | Benoit Foucher <benoit@zeroc.com> | 2016-11-25 13:13:22 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2016-11-25 13:13:22 +0100 |
commit | dcdc32af1fced49d80a8ccd93230e15d91ab45d8 (patch) | |
tree | eb69e2555fbd54496fce8a33f4dd610e1473ff51 /cpp/test/Slice/unicodePaths | |
parent | C# IceSSL/configuration log expired certificate exceptions. (diff) | |
download | ice-dcdc32af1fced49d80a8ccd93230e15d91ab45d8.tar.bz2 ice-dcdc32af1fced49d80a8ccd93230e15d91ab45d8.tar.xz ice-dcdc32af1fced49d80a8ccd93230e15d91ab45d8.zip |
Refactored test scripts
Diffstat (limited to 'cpp/test/Slice/unicodePaths')
-rw-r--r-- | cpp/test/Slice/unicodePaths/run.py | 82 | ||||
-rw-r--r-- | cpp/test/Slice/unicodePaths/test.py | 71 |
2 files changed, 71 insertions, 82 deletions
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) |