Go to the documentation of this file.00001 from cmt2cmake import CMTParser
00002 from pyparsing import ParseException
00003
00004 def _test_package():
00005 tokens = list(CMTParser.parseString('package Test'))
00006 assert tokens == ['package', 'Test']
00007
00008 def test_version():
00009 tokens = list(CMTParser.parseString('version v1r2p3'))
00010 assert tokens == ['version', 'v1r2p3']
00011
00012 def test_library():
00013 statement = 'library GaudiKernelLib *.cpp -no_static -import=Boost'
00014 tokens = list(CMTParser.parseString(statement))
00015 print tokens
00016 assert tokens == ['library', 'GaudiKernelLib', '*.cpp', '-no_static', '-import=Boost']
00017
00018 statement = 'library TestLib test/lib/*.cpp a_variable=some_value -group=tests'
00019 tokens = list(CMTParser.parseString(statement))
00020 print tokens
00021 assert tokens == ['library', 'TestLib', 'test/lib/*.cpp', 'a_variable=some_value', '-group=tests']
00022
00023 def test_macro():
00024 s = 'macro_append ROOT_linkopts "some" WIN32 "other"'
00025 tokens = list(CMTParser.parseString(s))
00026 print tokens
00027 assert tokens == ['macro_append', 'ROOT_linkopts', '"some"', 'WIN32', '"other"']
00028
00029 s = 'macro a_var "value"'
00030 tokens = list(CMTParser.parseString(s))
00031 print tokens
00032 assert tokens == ['macro', 'a_var', '"value"']
00033
00034 s = 'macro a_var'
00035 try:
00036 tokens = list(CMTParser.parseString(s))
00037 assert False, 'parsing should have failed: %r' % s
00038 except ParseException:
00039 pass