コード例 #1
0
    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)
コード例 #2
0
ファイル: test_unit_utils.py プロジェクト: ESCOMP/CESM_CICE
    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)
コード例 #3
0
    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
コード例 #4
0
    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)
コード例 #5
0
ファイル: test_unit_utils.py プロジェクト: ESCOMP/CESM_CICE
    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)
コード例 #6
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)
コード例 #7
0
 def checkout_ref(refname):
     """Checkout the given refname in the current directory"""
     execute_subprocess(['git', 'checkout', refname])
コード例 #8
0
 def make_git_tag(tagname):
     """Make a lightweight tag at the current commit"""
     execute_subprocess(['git', 'tag', '-m', 'making a tag', tagname])
コード例 #9
0
 def checkout_git_branch(branchname):
     """Checkout a new branch in the current directory"""
     execute_subprocess(['git', 'checkout', '-b', branchname])
コード例 #10
0
 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'])
コード例 #11
0
 def make_git_repo():
     """Turn the current directory into an empty git repository"""
     execute_subprocess(['git', 'init'])
コード例 #12
0
 def checkout_ref(refname):
     """Checkout the given refname in the current directory"""
     execute_subprocess(['git', 'checkout', refname])
コード例 #13
0
 def make_git_tag(tagname):
     """Make a lightweight tag at the current commit"""
     execute_subprocess(['git', 'tag', '-m', 'making a tag', tagname])
コード例 #14
0
 def checkout_git_branch(branchname):
     """Checkout a new branch in the current directory"""
     execute_subprocess(['git', 'checkout', '-b', branchname])
コード例 #15
0
 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'])
コード例 #16
0
 def make_git_repo():
     """Turn the current directory into an empty git repository"""
     execute_subprocess(['git', 'init'])