예제 #1
0
    def __assert_history(self, expected):
        out = utils.stdout(gl.history())
        cids = list(reversed(re.findall(r'ci (.*) in (\S*)', out, re.UNICODE)))
        self.assertItemsEqual(
            cids, expected, 'cids is ' + text(cids) + ' exp ' + text(expected))

        st_out = utils.stdout(gl.status())
        self.assertFalse('fuse' in st_out)
예제 #2
0
파일: test_e2e.py 프로젝트: imoapps/gitless
  def __assert_history(self, expected):
    out = utils.stdout(gl.history(_tty_out=False))
    cids = list(reversed(re.findall(r'ci (.*) in (.*)', out, re.UNICODE)))
    self.assertEqual(
        cids, expected, 'cids is ' + text(cids) + ' exp ' + text(expected))

    st_out = utils.stdout(gl.status())
    self.assertFalse('fuse' in st_out)
예제 #3
0
파일: test_e2e.py 프로젝트: imoapps/gitless
 def __assert_commit(self, *expected_committed):
   h = utils.stdout(gl.history(v=True, _tty_out=False))
   for fp in expected_committed:
     if fp not in h:
       self.fail('{0} was apparently not committed!'.format(fp))
   expected_not_committed = [
       fp for fp in self.FPS if fp not in expected_committed]
   for fp in expected_not_committed:
     if fp in h:
       self.fail('{0} was apparently committed!'.format(fp))
예제 #4
0
 def __assert_commit(self, *expected_committed):
   h = utils.stdout(gl.history(v=True, _tty_out=False))
   for fp in expected_committed:
     if fp not in h:
       self.fail('{0} was apparently not committed!'.format(fp))
   expected_not_committed = [
       fp for fp in self.FPS if fp not in expected_committed]
   for fp in expected_not_committed:
     if fp in h:
       self.fail('{0} was apparently committed!'.format(fp))
예제 #5
0
    def test_basic_functionality(self):
        utils.write_file('file1', 'Contents of file1')
        # Track
        gl.track('file1')
        self.assertRaises(ErrorReturnCode, gl.track, 'file1')
        self.assertRaises(ErrorReturnCode, gl.track, 'non-existent')
        # Untrack
        gl.untrack('file1')
        self.assertRaises(ErrorReturnCode, gl.untrack, 'file1')
        self.assertRaises(ErrorReturnCode, gl.untrack, 'non-existent')
        # Commit
        gl.track('file1')
        gl.commit(m='file1 commit')
        self.assertRaises(ErrorReturnCode, gl.commit, m='nothing to commit')
        # History
        if 'file1 commit' not in utils.stdout(gl.history()):
            self.fail('Commit didn\'t appear in history')
        # Branch
        # Make some changes to file1 and branch out
        utils.write_file('file1', 'New contents of file1')
        gl.branch(c='branch1')
        gl.switch('branch1')
        if 'New' in utils.read_file('file1'):
            self.fail('Branch not independent!')
        # Switch back to master branch, check that contents are the same as before.
        gl.switch('master')
        if 'New' not in utils.read_file('file1'):
            self.fail('Branch not independent!')
        out = utils.stdout(gl.branch())
        if '* master' not in out:
            self.fail('Branch status output wrong: {0}'.format(out))
        if 'branch1' not in out:
            self.fail('Branch status output wrong: {0}'.format(out))

        gl.branch(c='branch2')
        gl.branch(c='branch-conflict1')
        gl.branch(c='branch-conflict2')
        gl.commit(m='New contents commit')

        # Fuse
        gl.switch('branch1')
        self.assertRaises(ErrorReturnCode, gl.fuse)  # no upstream set
        try:
            gl.fuse('master')
        except ErrorReturnCode as e:
            self.fail(utils.stderr(e))
        out = utils.stdout(gl.history())
        if 'file1 commit' not in out:
            self.fail(out)

        # Merge
        gl.switch('branch2')
        self.assertRaises(ErrorReturnCode, gl.merge)  # no upstream set
        gl.merge('master')
        out = utils.stdout(gl.history())
        if 'file1 commit' not in out:
            self.fail(out)

        # Conflicting fuse
        gl.switch('branch-conflict1')
        utils.write_file('file1', 'Conflicting changes to file1')
        gl.commit(m='changes in branch-conflict1')
        err = utils.stderr(gl.fuse('master', _ok_code=[1]))
        if 'conflict' not in err:
            self.fail(err)
        out = utils.stdout(gl.status())
        if 'file1 (with conflicts)' not in out:
            self.fail(out)

        # Try aborting
        gl.fuse('--abort')
        out = utils.stdout(gl.status())
        if 'file1' in out:
            self.fail(out)

        # Ok, now let's fix the conflicts
        err = utils.stderr(gl.fuse('master', _ok_code=[1]))
        if 'conflict' not in err:
            self.fail(err)
        out = utils.stdout(gl.status())
        if 'file1 (with conflicts)' not in out:
            self.fail(out)

        utils.write_file('file1', 'Fixed conflicts!')
        self.assertRaises(ErrorReturnCode, gl.commit, m='resolve not called')
        self.assertRaises(ErrorReturnCode, gl.resolve, 'non-existent')
        gl.resolve('file1')
        gl.commit(m='fixed conflicts')
예제 #6
0
파일: test_e2e.py 프로젝트: imoapps/gitless
  def test_basic_functionality(self):
    utils.write_file('file1', 'Contents of file1')
    # Track
    gl.track('file1')
    self.assertRaises(ErrorReturnCode, gl.track, 'file1')
    self.assertRaises(ErrorReturnCode, gl.track, 'non-existent')
    # Untrack
    gl.untrack('file1')
    self.assertRaises(ErrorReturnCode, gl.untrack, 'file1')
    self.assertRaises(ErrorReturnCode, gl.untrack, 'non-existent')
    # Commit
    gl.track('file1')
    gl.commit(m='file1 commit')
    self.assertRaises(ErrorReturnCode, gl.commit, m='nothing to commit')
    # History
    if 'file1 commit' not in utils.stdout(gl.history(_tty_out=False)):
      self.fail('Commit didn\'t appear in history')
    # Branch
    # Make some changes to file1 and branch out
    utils.write_file('file1', 'New contents of file1')
    gl.branch(c='branch1')
    gl.switch('branch1')
    if 'New' in utils.read_file('file1'):
      self.fail('Branch not independent!')
    # Switch back to master branch, check that contents are the same as before.
    gl.switch('master')
    if 'New' not in utils.read_file('file1'):
      self.fail('Branch not independent!')
    out = utils.stdout(gl.branch(_tty_out=False))
    if '* master' not in out:
      self.fail('Branch status output wrong: {0}'.format(out))
    if 'branch1' not in out:
      self.fail('Branch status output wrong: {0}'.format(out))

    gl.branch(c='branch2')
    gl.branch(c='branch-conflict1')
    gl.branch(c='branch-conflict2')
    gl.commit(m='New contents commit')

    # Fuse
    gl.switch('branch1')
    self.assertRaises(ErrorReturnCode, gl.fuse)  # no upstream set
    try:
      gl.fuse('master')
    except ErrorReturnCode as e:
      self.fail(utils.stderr(e))
    out = utils.stdout(gl.history(_tty_out=False))
    if 'file1 commit' not in out:
      self.fail(out)

    # Merge
    gl.switch('branch2')
    self.assertRaises(ErrorReturnCode, gl.merge)  # no upstream set
    gl.merge('master')
    out = utils.stdout(gl.history(_tty_out=False))
    if 'file1 commit' not in out:
      self.fail(out)

    # Conflicting fuse
    gl.switch('branch-conflict1')
    utils.write_file('file1', 'Conflicting changes to file1')
    gl.commit(m='changes in branch-conflict1')
    err = utils.stderr(gl.fuse('master', _tty_out=False, _ok_code=[1]))
    if 'conflict' not in err:
      self.fail(err)
    out = utils.stdout(gl.status(_tty_out=False))
    if 'file1 (with conflicts)' not in out:
      self.fail(out)

    # Try aborting
    gl.fuse('--abort')
    out = utils.stdout(gl.status(_tty_out=False))
    if 'file1' in out:
      self.fail(out)

    # Ok, now let's fix the conflicts
    err = utils.stderr(gl.fuse('master', _tty_out=False, _ok_code=[1]))
    if 'conflict' not in err:
      self.fail(err)
    out = utils.stdout(gl.status(_tty_out=False))
    if 'file1 (with conflicts)' not in out:
      self.fail(out)

    utils.write_file('file1', 'Fixed conflicts!')
    self.assertRaises(ErrorReturnCode, gl.commit, m='resolve not called')
    self.assertRaises(ErrorReturnCode, gl.resolve, 'non-existent')
    gl.resolve('file1')
    gl.commit(m='fixed conflicts')