You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2016/02/09 18:11:27 UTC
[10/12] lucy-clownfish git commit: Add test target for Python runtime
bindings.
Add test target for Python runtime bindings.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/49361b77
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/49361b77
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/49361b77
Branch: refs/heads/master
Commit: 49361b775a6af4fd42c5fd3ceff8d946d93418f2
Parents: fb4cc37
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Tue Jan 19 20:28:26 2016 -0800
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Sat Feb 6 10:23:21 2016 -0800
----------------------------------------------------------------------
runtime/python/setup.py | 30 ++++++++++++++++++++++++++++++
runtime/python/test/test_clownfish.py | 27 +++++++++++++++++++++++++++
2 files changed, 57 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/49361b77/runtime/python/setup.py
----------------------------------------------------------------------
diff --git a/runtime/python/setup.py b/runtime/python/setup.py
index a522cb9..fdaa593 100644
--- a/runtime/python/setup.py
+++ b/runtime/python/setup.py
@@ -24,6 +24,8 @@ import glob
import shutil
import subprocess
import sysconfig
+import sys
+import unittest
# Get a compiler object and and strings representing the compiler type and
# CFLAGS. Add the Python headers include dir to CFLAGS.
@@ -113,6 +115,33 @@ class my_build(_build):
self.run_command('charmony')
_build.run(self)
+class test(_Command):
+ description = "Run unit tests."
+ user_options = []
+ def initialize_options(self):
+ pass
+ def finalize_options(self):
+ pass
+ def ext_build_dir(self):
+ """Returns the build directory for compiled extensions"""
+ pattern = "lib.{platform}-{version[0]}.{version[1]}"
+ dirname = pattern.format(platform=sysconfig.get_platform(),
+ version=sys.version_info)
+ return os.path.join('build', dirname)
+
+ def run(self):
+ self.run_command('build')
+ orig_sys_path = sys.path[:]
+ sys.path.append(self.ext_build_dir())
+
+ loader = unittest.TestLoader()
+ tests = loader.discover("test")
+ test_runner = unittest.runner.TextTestRunner()
+ test_runner.run(tests)
+
+ # restore sys.path
+ sys.path = orig_sys_path
+
setup(name = 'clownfish',
version = '0.4.0',
description = 'Clownfish runtime',
@@ -125,6 +154,7 @@ setup(name = 'clownfish',
'build': my_build,
'clean': my_clean,
'charmony': charmony,
+ 'test': test,
},
package_dir={'': 'src'},)
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/49361b77/runtime/python/test/test_clownfish.py
----------------------------------------------------------------------
diff --git a/runtime/python/test/test_clownfish.py b/runtime/python/test/test_clownfish.py
new file mode 100644
index 0000000..fd124d3
--- /dev/null
+++ b/runtime/python/test/test_clownfish.py
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import unittest
+import clownfish
+
+class MyTest(unittest.TestCase):
+
+ def testTrue(self):
+ self.assertTrue(True, "True should be true")
+
+
+if __name__ == '__main__':
+ unittest.main()
+