Skip to content

Commit c59db5c

Browse files
committed
Add REGEX check for CastXML version
Since the CastXML repository has the code for the comments but has not generated a release yet, check the version of the castxml executable before running. If it is 0.3.6 or older, do not run the test. Fix style errors.
1 parent df4a4cc commit c59db5c

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

unittests/test_comments.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Distributed under the Boost Software License, Version 1.0.
44
# See http://www.boost.org/LICENSE_1_0.txt
55

6+
import re
7+
import subprocess
68
import unittest
79

810
from . import parser_test_case
@@ -28,6 +30,7 @@ def setUp(self):
2830
Test.xml_generator_from_xml_file = \
2931
self.config.xml_generator_from_xml_file
3032
self.xml_generator_from_xml_file = Test.xml_generator_from_xml_file
33+
3134
self.global_ns = Test.global_ns
3235

3336
def test(self):
@@ -37,11 +40,25 @@ def test(self):
3740
if self.config.castxml_epic_version != 1:
3841
# Run this test only with castxml epic version == 1
3942
return
40-
43+
# Try to capture CastXML's patch version: 0.3.<###>
44+
# If the version is <= 0.3.6, return as the functionality doesn't exist
45+
# Else, continue on with the test.
46+
rtn = subprocess.run(
47+
[self.config.xml_generator_path, "--version"],
48+
stdout=subprocess.PIPE
49+
)
50+
version_regex = re.compile(
51+
b"castxml version 0.3.(?P<patch_ver>[0-9]+)"
52+
)
53+
reg_match = re.match(version_regex, rtn.stdout)
54+
if reg_match:
55+
if int(reg_match.group("patch_ver")) <= 6:
56+
return
4157
tnamespace = self.global_ns.namespace("comment")
4258

4359
self.assertIn("comment", dir(tnamespace))
44-
self.assertEqual(["//! Namespace Comment", "//! Across multiple lines"],
60+
self.assertEqual(["//! Namespace Comment",
61+
"//! Across multiple lines"],
4562
tnamespace.comment.text)
4663

4764
tenumeration = tnamespace.enumeration("com_enum")

0 commit comments

Comments
 (0)