def test_that_manifest_dependencies_are_included(self): package_name = 'my_package' # Make a CMakeLists.txt file. cmakelists_path = create_temp_file(contents='') # Make a manifest.xml file. manifest_path = create_temp_file(contents=''' <package> <depend package="pkg_a"/> <depend package="pkg_b"/> <rosdep name="pkg_c" /> <rosdep name="pkg_d" /> </package> ''') output = StringIO.StringIO() # Run the catkinize script. main([package_name, cmakelists_path, manifest_path], output) # Check that dependencies are listed. out_lines = output.getvalue().splitlines() cpkg_lines = [l for l in out_lines if 'catkin_package' in l] self.assertEqual(1, len(cpkg_lines), str(cpkg_lines)) cpkg_line = cpkg_lines[0] pattern = 'DEPENDS pkg_a pkg_b pkg_c pkg_d' msg = ''' Failed to find package dependencies in the catkin_package() call: Expected to find a line containing %s but got %s ''' % (pattern, cpkg_line) self.assertTrue(pattern in cpkg_line, msg)
def test_main(self): for case in ['rpekf', 'stage']: infile = os.path.join(os.path.dirname(__file__), 'fixtures', 'CMakeLists.%s.txt.in' % case) outfile = os.path.join(os.path.dirname(__file__), 'fixtures', 'CMakeLists.%s.txt.out' % case) result_buf = StringIO.StringIO() manifest = create_temp_file(contents='<package/>') main(['foo', infile, manifest], outstream=result_buf) with open(outfile, 'r') as fhand: expect = fhand.read() self.compare_contents(outfile, expect, result_buf.getvalue())
def run_with_fixture(self, case): infile = os.path.join(os.path.dirname(__file__), 'fixtures', 'CMakeLists.%s.txt.in' % case) manfile = os.path.join(os.path.dirname(__file__), 'fixtures', 'manifest.%s.xml' % case) outfile = os.path.join(os.path.dirname(__file__), 'fixtures', 'CMakeLists.%s.txt.out' % case) result_buf = StringIO.StringIO() try: main(['foo', infile, manfile], outstream=result_buf) except SystemExit: pass with open(outfile, 'r') as fhand: expect = fhand.read() # self.assertEqual(expect, result_buf.getvalue(), "%s\n!=\n%s" % (expect, result_buf.getvalue())) self.compare_contents(outfile, expect, result_buf.getvalue())