Exemplo n.º 1
0
    def checkout(self):
        from aasemble.django.utils import run_cmd

        run_cmd(['git',
                 'clone', self.build_record['source']['git_repository'],
                 '--recursive',
                 '-b', self.build_record['source']['git_branch'],
                 self.builddir], logger=self.logger)
        run_cmd(['git', 'reset', '--hard', self.build_record['sha']], cwd=self.builddir, logger=self.logger)
Exemplo n.º 2
0
    def test_run_cmd_override_env(self):
        os.environ['TESTVAR'] = 'foo'
        stdout = run_cmd(['env'])
        self.assertIn(b'TESTVAR=foo', stdout)

        stdout = run_cmd(['env'], override_env={'TESTVAR': 'bar'})
        self.assertIn(b'TESTVAR=bar', stdout)

        stdout = run_cmd(['env'], override_env={'TESTVAR': None})
        self.assertNotIn(b'TESTVAR=', stdout)
Exemplo n.º 3
0
    def test_run_cmd_override_env(self):
        os.environ['TESTVAR'] = 'foo'
        stdout = run_cmd(['env'])
        self.assertIn(b'TESTVAR=foo', stdout)

        stdout = run_cmd(['env'], override_env={'TESTVAR': 'bar'})
        self.assertIn(b'TESTVAR=bar', stdout)

        stdout = run_cmd(['env'], override_env={'TESTVAR': None})
        self.assertNotIn(b'TESTVAR=', stdout)
Exemplo n.º 4
0
 def test_run_cmd_stdout_can_discard_stderr(self):
     tmpfile = self._prepare_stdout_stderr_script()
     try:
         self.assertNotIn(b'stderr', run_cmd([tmpfile],
                                             discard_stderr=True))
     finally:
         os.unlink(tmpfile)
Exemplo n.º 5
0
    def test_run_cmd_alternate_stdout(self):
        fd, tmpfile = tempfile.mkstemp()
        try:
            with os.fdopen(fd, 'w') as fp:
                rv = run_cmd(['echo', 'foo'], stdout=fp)

            self.assertEquals(rv, None)

            with open(tmpfile, 'r') as fp:
                self.assertEquals(fp.read(), 'foo\n')

        finally:
            os.unlink(tmpfile)
Exemplo n.º 6
0
    def test_run_cmd_alternate_stdout(self):
        fd, tmpfile = tempfile.mkstemp()
        try:
            with os.fdopen(fd, 'w') as fp:
                rv = run_cmd(['echo', 'foo'], stdout=fp)

            self.assertEquals(rv, None)

            with open(tmpfile, 'r') as fp:
                self.assertEquals(fp.read(), 'foo\n')

        finally:
            os.unlink(tmpfile)
Exemplo n.º 7
0
 def test_run_cmd_other_cwd(self):
     self.assertEquals(run_cmd(['pwd'], cwd='/').strip(), b'/')
Exemplo n.º 8
0
 def test_run_cmd_dead_simple(self):
     # Should simply return successfully
     stdout = run_cmd(['true'])
     self.assertEquals(stdout, b'')
Exemplo n.º 9
0
 def test_run_cmd_stdout_can_discard_stderr(self):
     tmpfile = self._prepare_stdout_stderr_script()
     try:
         self.assertNotIn(b'stderr', run_cmd([tmpfile], discard_stderr=True))
     finally:
         os.unlink(tmpfile)
Exemplo n.º 10
0
 def test_run_cmd_stdout_includes_stderr(self):
     tmpfile = self._prepare_stdout_stderr_script()
     try:
         self.assertIn(b'stderr', run_cmd([tmpfile]))
     finally:
         os.unlink(tmpfile)
Exemplo n.º 11
0
 def test_run_cmd_other_cwd(self):
     self.assertEquals(run_cmd(['pwd'], cwd='/').strip(), b'/')
Exemplo n.º 12
0
 def test_run_cmd_dead_simple(self):
     # Should simply return successfully
     stdout = run_cmd(['true'])
     self.assertEquals(stdout, b'')
Exemplo n.º 13
0
 def test_run_cmd_stdout_includes_stderr(self):
     tmpfile = self._prepare_stdout_stderr_script()
     try:
         self.assertIn(b'stderr', run_cmd([tmpfile]))
     finally:
         os.unlink(tmpfile)
Exemplo n.º 14
0
 def test_run_cmd_no_trailing_linefeed(self):
     logger = mock.MagicMock()
     stdout = run_cmd(['bash', '-c', 'echo -n foo'], logger=logger)
     self.assertEquals(stdout, b'foo')
     logger.log.assert_called_with(20, 'foo')
Exemplo n.º 15
0
def key_data(repository):
    if repository.key_id:
        return run_cmd(['gpg', '-a', '--export', repository.key_id])
Exemplo n.º 16
0
 def test_run_cmd_no_trailing_linefeed(self):
     logger = mock.MagicMock()
     stdout = run_cmd(['bash', '-c', 'echo -n foo'], logger=logger)
     self.assertEquals(stdout, b'foo')
     logger.log.assert_called_with(20, 'foo')