summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-07-27 09:45:30 +0000
committerChristoph Reiter <reiter.christoph@gmail.com>2018-07-27 09:45:30 +0000
commit746abb72a27a1959a891723b661839b7f158fa8c (patch)
treebe976eafb125b8cd992e571d0d295a8bf72cbef4 /tests
parent6c85b1c45460edd74395b119ebbff6a53eacec7e (diff)
parentc26a7548f43d7fad96c4c7d83aeb7150bcb9e48b (diff)
downloadgobject-introspection-746abb72a27a1959a891723b661839b7f158fa8c.tar.gz
Merge branch 'tests-transformer-win32' into 'master'
transformer: don't shell out for filter commands and make the tests work on Windows See merge request GNOME/gobject-introspection!54
Diffstat (limited to 'tests')
-rw-r--r--tests/scanner/meson.build11
-rw-r--r--tests/scanner/test_transformer.py38
2 files changed, 29 insertions, 20 deletions
diff --git a/tests/scanner/meson.build b/tests/scanner/meson.build
index 86c7d5da..07df91a9 100644
--- a/tests/scanner/meson.build
+++ b/tests/scanner/meson.build
@@ -6,17 +6,14 @@ scanner_test_files = [
'test_shlibs.py',
]
-# FIXME: Windows
-if host_system != 'windows'
- scanner_test_files += ['test_transformer.py']
-endif
-
# FIXME: MSVC
if cc.get_id() != 'msvc'
- scanner_test_files += ['test_sourcescanner.py']
+ scanner_test_files += [
+ 'test_sourcescanner.py',
+ 'test_transformer.py',
+ ]
endif
foreach f : scanner_test_files
test(f, python, args: files(f), env: scanner_test_env)
endforeach
-
diff --git a/tests/scanner/test_transformer.py b/tests/scanner/test_transformer.py
index 13b0b669..467f0c5c 100644
--- a/tests/scanner/test_transformer.py
+++ b/tests/scanner/test_transformer.py
@@ -42,16 +42,15 @@ def load_namespace_from_source_string(namespace, source):
class TestIdentifierFilter(unittest.TestCase):
def test_underscore_t_identifier_filter(self):
- cmd = textwrap.dedent(r"""
- python -c '
- import sys, re
- for line in sys.stdin:
- line = re.sub(r"^test_t$", "TestContext", line)
- line = re.sub(r"_t$", "", line)
- line = re.sub(r"^test_", "Test_", line)
- line = re.sub(r"_([a-z])", lambda m: m.group(1).title(),
- line)
- sys.stdout.write(line)'""")
+ cmd = [sys.executable, '-c', textwrap.dedent("""
+ import sys, re
+ for line in sys.stdin:
+ line = re.sub(r"^test_t$", "TestContext", line)
+ line = re.sub(r"_t$", "", line)
+ line = re.sub(r"^test_", "Test_", line)
+ line = re.sub(r"_([a-z])", lambda m: m.group(1).title(),
+ line)
+ sys.stdout.write(line)""")]
namespace = ast.Namespace('Test', '1.0')
xformer = Transformer(namespace, identifier_filter_cmd=cmd)
@@ -63,18 +62,31 @@ class TestIdentifierFilter(unittest.TestCase):
self.assertEqual(xformer.strip_identifier('test_foo_tart'), 'FooTart')
def test_invalid_command(self):
- cmd = r'this-is-not-a-real-command'
+ cmd = ['this-is-not-a-real-command']
namespace = ast.Namespace('Test', '1.0')
xformer = Transformer(namespace, identifier_filter_cmd=cmd)
- self.assertRaises(ValueError, xformer.strip_identifier, 'test_t')
+ self.assertRaises(OSError, xformer.strip_identifier, 'test_t')
def test_invalid_argument(self):
- cmd = r'sed --not-a-valid-argument'
+ cmd = [sys.executable, '--not-a-valid-argument']
namespace = ast.Namespace('Test', '1.0')
xformer = Transformer(namespace, identifier_filter_cmd=cmd)
self.assertRaises(ValueError, xformer.strip_identifier, 'test_t')
+class TestSymbolFilter(unittest.TestCase):
+
+ def test_split_csymbol(self):
+ cmd = [
+ sys.executable, '-c',
+ 'import sys; sys.stdout.write("test_" + sys.stdin.read())']
+ namespace = ast.Namespace('Test', '1.0')
+ xformer = Transformer(namespace, symbol_filter_cmd=cmd)
+
+ self.assertEqual(
+ xformer.split_csymbol('foo_bar_quux')[1], "foo_bar_quux")
+
+
class TestStructTypedefs(unittest.TestCase):
def setUp(self):
# Hack to set logging singleton