def test_exesub_except_stat_err(self): """Test that execute_subprocess raises an exception on error when caller doesn't request return code """ cmd = ['false'] with self.assertRaises(RuntimeError): execute_subprocess(cmd, status_to_caller=False)
def have_svn_access(): """Check if we have svn access so we can enable tests that use svn. """ have_svn = False cmd = [ 'svn', 'ls', SVN_TEST_REPO, ] try: execute_subprocess(cmd) have_svn = True except BaseException: pass return have_svn
def test_exesub_return_stat_ok(self): """Test that execute_subprocess returns a status code when caller requests and the executed subprocess succeeds. """ cmd = ['true'] status = execute_subprocess(cmd, status_to_caller=True) self.assertEqual(status, 0)
def create_branch(dest_dir, repo_name, branch, with_commit=False): """Update a repository branch, and potentially the remote. """ # pylint: disable=R0913 cwd = os.getcwd() repo_root = os.path.join(dest_dir, EXTERNALS_NAME) repo_root = os.path.join(repo_root, repo_name) os.chdir(repo_root) cmd = [ 'git', 'checkout', '-b', branch, ] execute_subprocess(cmd) if with_commit: msg = 'start work on {0}'.format(branch) with open(README_NAME, 'a') as handle: handle.write(msg) cmd = [ 'git', 'add', README_NAME, ] execute_subprocess(cmd) cmd = [ 'git', 'commit', '-m', msg, ] execute_subprocess(cmd) os.chdir(cwd)
def checkout_ref(refname): """Checkout the given refname in the current directory""" execute_subprocess(['git', 'checkout', refname])
def make_git_tag(tagname): """Make a lightweight tag at the current commit""" execute_subprocess(['git', 'tag', '-m', 'making a tag', tagname])
def checkout_git_branch(branchname): """Checkout a new branch in the current directory""" execute_subprocess(['git', 'checkout', '-b', branchname])
def add_git_commit(): """Add a git commit in the current directory""" with open('README', 'a') as myfile: myfile.write('more info') execute_subprocess(['git', 'add', 'README']) execute_subprocess(['git', 'commit', '-m', 'my commit message'])
def make_git_repo(): """Turn the current directory into an empty git repository""" execute_subprocess(['git', 'init'])