<s> import os <EOL> from qisys import ui <EOL> import qisrc . git <EOL> import qitoolchain . toolchain <EOL> from qisrc . test . conftest import svn_server <EOL> from qisrc . test . conftest import git_server <EOL> def get_tc_file_contents ( tc ) : <EOL> """<STR_LIT>""" <EOL> tc_file_path = tc . toolchain_file <EOL> with open ( tc_file_path , "<STR_LIT:r>" ) as fp : <EOL> contents = fp . read ( ) <EOL> return contents <EOL> def test_get_tc_names ( ) : <EOL> toolchain = qitoolchain . toolchain . Toolchain ( "<STR_LIT:bar>" ) <EOL> toolchain = qitoolchain . toolchain . Toolchain ( "<STR_LIT>" ) <EOL> assert qitoolchain . get_tc_names ( ) == [ "<STR_LIT:bar>" , "<STR_LIT>" ] <EOL> def test_persistent_storage ( feed ) : <EOL> boost_package = qitoolchain . qipackage . QiPackage ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> feed . add_package ( boost_package , with_url = True ) <EOL> toolchain = qitoolchain . toolchain . Toolchain ( "<STR_LIT:bar>" ) <EOL> toolchain . update ( feed . url ) <EOL> toolchain2 = qitoolchain . get_toolchain ( "<STR_LIT:bar>" ) <EOL> assert toolchain2 . packages == toolchain . packages <EOL> def test_stores_feed_after_updating ( feed ) : <EOL> toolchain = qitoolchain . toolchain . Toolchain ( "<STR_LIT:bar>" ) <EOL> toolchain . update ( feed . url ) <EOL> toolchain2 = qitoolchain . toolchain . Toolchain ( "<STR_LIT:bar>" ) <EOL> assert toolchain2 . feed_location == feed . url <EOL> def test_add_local_ctc ( tmpdir ) : <EOL> ctc = tmpdir . mkdir ( "<STR_LIT>" ) <EOL> toolchain_xml = ctc . join ( "<STR_LIT>" ) <EOL> toolchain_xml . write ( """<STR_LIT>""" ) <EOL> toolchain = qitoolchain . toolchain . Toolchain ( "<STR_LIT:bar>" ) <EOL> package_xml = ctc . join ( "<STR_LIT>" ) <EOL> package_xml . write ( """<STR_LIT>""" ) <EOL> toolchain . update ( toolchain_xml . strpath ) <EOL> tc_contents = get_tc_file_contents ( toolchain ) <EOL> ctc_path = toolchain . db . get_package_path ( "<STR_LIT>" ) <EOL> config_cmake = os . path . join ( ctc_path , "<STR_LIT>" ) <EOL> assert ( '<STR_LIT>' % config_cmake ) in tc_contents <EOL> toolchain2 = qitoolchain . toolchain . Toolchain ( "<STR_LIT:bar>" ) <EOL> tc_contents = get_tc_file_contents ( toolchain2 ) <EOL> assert ( '<STR_LIT>' % config_cmake ) in tc_contents <EOL> def test_removing ( feed ) : <EOL> boost_package = qitoolchain . qipackage . QiPackage ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> feed . add_package ( boost_package , with_url = True ) <EOL> toolchain = qitoolchain . toolchain . Toolchain ( "<STR_LIT:bar>" ) <EOL> toolchain . update ( feed . url ) <EOL> toolchain . remove ( ) <EOL> toolchain2 = qitoolchain . toolchain . Toolchain ( "<STR_LIT:bar>" ) <EOL> assert not toolchain2 . packages <EOL> def test_update_svn_package ( tmpdir , svn_server ) : <EOL> boost_url = svn_server . create_repo ( "<STR_LIT>" ) <EOL> svn_server . commit_file ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> feed_xml = """<STR_LIT>""" <EOL> feed_xml = feed_xml . format ( url = boost_url ) <EOL> feed_path = tmpdir . join ( "<STR_LIT>" ) <EOL> feed_path . write ( feed_xml ) <EOL> toolchain = qitoolchain . toolchain . Toolchain ( "<STR_LIT:bar>" ) <EOL> toolchain . update ( feed_path . strpath ) <EOL> boost_package = toolchain . get_package ( "<STR_LIT>" ) <EOL> boost_lib = os . path . join ( boost_package . path , "<STR_LIT>" ) <EOL> assert os . path . exists ( boost_lib ) <EOL> svn_server . commit_file ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> toolchain . update ( ) <EOL> boost_lib = os . path . join ( boost_package . path , "<STR_LIT>" ) <EOL> assert os . path . exists ( boost_lib ) <EOL> def test_sysroot ( tmpdir ) : <EOL> ctc_package = qitoolchain . qipackage . QiPackage ( "<STR_LIT>" ) <EOL> ctc_package . sysroot = "<STR_LIT>" <EOL> ctc_package . cross_gdb = "<STR_LIT>" <EOL> ctc_package . path = tmpdir . strpath <EOL> toolchain = qitoolchain . toolchain . Toolchain ( "<STR_LIT:test>" ) <EOL> toolchain . add_package ( ctc_package ) <EOL> path = toolchain . get_package ( "<STR_LIT>" ) . path <EOL> assert toolchain . get_sysroot ( ) == os . path . join ( path , "<STR_LIT>" ) <EOL> assert toolchain . get_cross_gdb ( ) == os . path . join ( path , "<STR_LIT>" ) <EOL> def test_displays_git_info ( tmpdir , git_server , feed , qitoolchain_action ) : <EOL> boost_package = qitoolchain . qipackage . QiPackage ( "<STR_LIT>" , version = "<STR_LIT>" ) <EOL> feed . add_package ( boost_package ) <EOL> git_server . create_repo ( "<STR_LIT>" ) <EOL> git_server . change_branch ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> git_server . push_file ( "<STR_LIT>" , "<STR_LIT>" , feed . feed_xml . read ( ) , <EOL> branch = "<STR_LIT>" ) <EOL> feed_url = git_server . get_repo ( "<STR_LIT>" ) . clone_url <EOL> git = qisrc . git . Git ( tmpdir . strpath ) <EOL> _ , out = git . call ( "<STR_LIT>" , feed_url , "<STR_LIT>" , raises = False ) <EOL> devel_sha1 = out . split ( ) [ <NUM_LIT:0> ] [ : <NUM_LIT:8> ] <EOL> qitoolchain_action ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:bar>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:foo>" , feed_url ) <EOL> foo_tc = qitoolchain . get_toolchain ( "<STR_LIT:foo>" ) <EOL> as_str = str ( foo_tc ) <EOL> assert "<STR_LIT>" in as_str <EOL> assert "<STR_LIT>" in as_str <EOL> assert "<STR_LIT>" % feed_url in as_str <EOL> assert devel_sha1 in as_str </s>
