1111import timing
1212import typed_astunparse
1313
14- from transpyle .general .code_reader import CodeReader
15- from transpyle .general .binder import Binder
16- from transpyle .cpp .parser import CppParser
17- from transpyle .cpp .ast_generalizer import CppAstGeneralizer
18- from transpyle .cpp .unparser import Cpp14Unparser
19- from transpyle .cpp .compiler import CppSwigCompiler
20- from transpyle .cpp .compiler_interface import GppInterface
14+ from transpyle .general import AstGeneralizer , Binder , CodeReader , Compiler , Parser , Unparser
15+ from transpyle .general .exc import ExternalToolError
16+
17+ try :
18+ from transpyle .cpp .parser import CppParser
19+ except (ImportError , ExternalToolError ):
20+ pass
21+ try :
22+ from transpyle .cpp .ast_generalizer import CppAstGeneralizer
23+ except (ImportError , ExternalToolError ):
24+ pass
25+ try :
26+ from transpyle .cpp .unparser import Cpp14Unparser
27+ except (ImportError , ExternalToolError ):
28+ pass
29+ try :
30+ from transpyle .cpp .compiler import CppSwigCompiler
31+ except (ImportError , ExternalToolError ):
32+ pass
33+ try :
34+ from transpyle .cpp .compiler_interface import GppInterface
35+ except (ImportError , ExternalToolError ):
36+ pass
2137
2238from .common import \
2339 PERFORMANCE_RESULTS_ROOT , EXAMPLES_ROOT , EXAMPLES_ROOTS , \
2945_TIME = timing .get_timing_group (__name__ )
3046
3147
48+ @unittest .skipIf (Parser .find ('C++' ) is None , 'skipping due to missing C++ language support' )
3249class ParserTests (unittest .TestCase ):
3350
3451 @execute_on_language_examples ('cpp14' )
@@ -53,6 +70,7 @@ def test_try_parse_invalid(self):
5370 _LOG .debug ('%s' , err .exception )
5471
5572
73+ @unittest .skipIf (AstGeneralizer .find ('C++' ) is None , 'skipping due to missing C++ language support' )
5674class AstGeneralizerTests (unittest .TestCase ):
5775
5876 @execute_on_language_examples ('cpp14' )
@@ -71,6 +89,7 @@ def test_generalize_examples(self, input_path):
7189 _LOG .debug ('%s' , typed_astunparse .unparse (syntax ))
7290
7391
92+ @unittest .skipIf (Unparser .find ('C++' ) is None , 'skipping due to missing C++ language support' )
7493class UnparserTests (unittest .TestCase ):
7594
7695 @execute_on_language_examples ('cpp14' )
@@ -97,6 +116,7 @@ def test_unparse_examples(self, input_path):
97116 _LOG .info ('unparsed "%s" in %fs' , input_path , timer .elapsed )
98117
99118
119+ @unittest .skipIf (Compiler .find ('C++' ) is None , 'skipping due to missing C++ language support' )
100120class CompilerTests (unittest .TestCase ):
101121
102122 def test_cpp_paths_exist (self ):
0 commit comments