diff options
Diffstat (limited to 'tests/scanner')
-rw-r--r-- | tests/scanner/Makefile.am | 6 | ||||
-rw-r--r-- | tests/scanner/test_sourcescanner.py | 41 |
2 files changed, 46 insertions, 1 deletions
diff --git a/tests/scanner/Makefile.am b/tests/scanner/Makefile.am index d72d2557..e3fd4321 100644 --- a/tests/scanner/Makefile.am +++ b/tests/scanner/Makefile.am @@ -192,12 +192,16 @@ else CHECKDOCS = endif +PYTESTS = test_sourcescanner.py + XFAIL_TESTS = Typedefs-1.0.gir -TESTS = Headeronly-1.0.gir $(CHECKGIRS) $(CHECKDOCS) $(TYPELIBS) +TESTS = Headeronly-1.0.gir $(CHECKGIRS) $(CHECKDOCS) $(TYPELIBS) $(PYTESTS) TESTS_ENVIRONMENT = srcdir=$(srcdir) top_srcdir=$(top_srcdir) builddir=$(builddir) top_builddir=$(top_builddir) \ + PYTHON=$(PYTHON) UNINSTALLED_INTROSPECTION_SRCDIR=$(top_srcdir) \ $(top_srcdir)/tests/gi-tester EXTRA_DIST += \ + $(PYTESTS) \ Regress-1.0-C-expected \ Regress-1.0-Gjs-expected \ Regress-1.0-Python-expected \ diff --git a/tests/scanner/test_sourcescanner.py b/tests/scanner/test_sourcescanner.py new file mode 100644 index 00000000..3963683d --- /dev/null +++ b/tests/scanner/test_sourcescanner.py @@ -0,0 +1,41 @@ +import unittest +import tempfile +import os + +from giscanner.sourcescanner import SourceScanner + + +two_typedefs_source = """ +/** + * Spam: + */ +typedef struct _spam Spam; + +/** + * Eggs: + */ +typedef struct _eggs Eggs; +""" + + +class Test(unittest.TestCase): + def setUp(self): + self.ss = SourceScanner() + tmp_fd, tmp_name = tempfile.mkstemp() + file = os.fdopen(tmp_fd, 'wt') + file.write(two_typedefs_source) + file.close() + + self.ss.parse_files([tmp_name]) + + def test_get_symbols_length_consistency(self): + self.assertEqual(len(list(self.ss.get_symbols())), 2) + self.assertEqual(len(list(self.ss.get_symbols())), 2) + + def test_get_comments_length_consistency(self): + self.assertEqual(len(list(self.ss.get_comments())), 2) + self.assertEqual(len(list(self.ss.get_comments())), 2) + + +if __name__ == '__main__': + unittest.main() |