def test_parse_nonempty2(self): input = '''\ # Top level comment FIND_PACKAGE(ITK REQUIRED) INCLUDE(${ITK_USE_FILE}) ADD_EXECUTABLE(CastImageFilter CastImageFilter.cxx) TARGET_LINK_LIBRARIES(CastImageFilter # inline comment 1 vtkHybrid #inline comment 2 ITKIO ITKBasicFilters ITKCommon ) ''' output = parse(input) expected = File([ Comment('# Top level comment'), Command('FIND_PACKAGE', [Arg('ITK'), Arg('REQUIRED')]), Command('INCLUDE', [Arg('${ITK_USE_FILE}')]), BlankLine(), Command('ADD_EXECUTABLE', [Arg('CastImageFilter'), Arg('CastImageFilter.cxx')]), Command('TARGET_LINK_LIBRARIES', [ Arg('CastImageFilter', comments=['# inline comment 1']), Arg('vtkHybrid', comments=['#inline comment 2']), Arg('ITKIO'), Arg('ITKBasicFilters'), Arg('ITKCommon'), ]) ]) msg = '\nexpected\n%s\ngot\n%s' % (expected, output) self.assertEqual(expected, output, msg)
def test_parse_nonempty1(self): input = 'FIND_PACKAGE(ITK REQUIRED)' output = parse(input) expected = File( [Command('FIND_PACKAGE', [Arg('ITK'), Arg('REQUIRED')])]) msg = '\nexpected\n%s\ngot\n%s' % (repr(expected), repr(output)) self.assertEqual(expected, output, msg)
def test_multiline_string(self): s = ''' string containing newlines ''' input = '''\ set (MY_STRING "%s") ''' % s tree = parse(input) expected = File( [Command('set', [Arg('MY_STRING'), Arg('"' + s + '"')])]) self.assertEqual(expected, tree)
def test_command_with_no_args(self): tree = parse('cmd()') expected = File([Command('cmd', [])]) self.assertEqual(expected, tree)
def test_arg_with_a_slash(self): tree = parse('include_directories (${HELLO_SOURCE_DIR}/Hello)') expected = File([ Command('include_directories', [Arg('${HELLO_SOURCE_DIR}/Hello')]) ]) self.assertEqual(expected, tree)