| 68 | class TestBasic(TestEndToEnd): |
| 69 | |
| 70 | def test_basic_functionality(self): |
| 71 | utils.write_file('file1', 'Contents of file1') |
| 72 | # Track |
| 73 | gl.track('file1') |
| 74 | self.assertRaises(ErrorReturnCode, gl.track, 'file1') |
| 75 | self.assertRaises(ErrorReturnCode, gl.track, 'non-existent') |
| 76 | # Untrack |
| 77 | gl.untrack('file1') |
| 78 | self.assertRaises(ErrorReturnCode, gl.untrack, 'file1') |
| 79 | self.assertRaises(ErrorReturnCode, gl.untrack, 'non-existent') |
| 80 | # Commit |
| 81 | gl.track('file1') |
| 82 | gl.commit(m='file1 commit') |
| 83 | self.assertRaises(ErrorReturnCode, gl.commit, m='nothing to commit') |
| 84 | # History |
| 85 | if 'file1 commit' not in utils.stdout(gl.history()): |
| 86 | self.fail('Commit didn\'t appear in history') |
| 87 | # Branch |
| 88 | # Make some changes to file1 and branch out |
| 89 | utils.write_file('file1', 'New contents of file1') |
| 90 | gl.branch(c='branch1') |
| 91 | gl.switch('branch1') |
| 92 | if 'New' in utils.read_file('file1'): |
| 93 | self.fail('Branch not independent!') |
| 94 | # Switch back to master branch, check that contents are the same as before. |
| 95 | gl.switch('master') |
| 96 | if 'New' not in utils.read_file('file1'): |
| 97 | self.fail('Branch not independent!') |
| 98 | out = utils.stdout(gl.branch()) |
| 99 | if '* master' not in out: |
| 100 | self.fail('Branch status output wrong: {0}'.format(out)) |
| 101 | if 'branch1' not in out: |
| 102 | self.fail('Branch status output wrong: {0}'.format(out)) |
| 103 | |
| 104 | gl.branch(c='branch2') |
| 105 | gl.branch(c='branch-conflict1') |
| 106 | gl.branch(c='branch-conflict2') |
| 107 | gl.commit(m='New contents commit') |
| 108 | |
| 109 | # Fuse |
| 110 | gl.switch('branch1') |
| 111 | self.assertRaises(ErrorReturnCode, gl.fuse) # no upstream set |
| 112 | try: |
| 113 | gl.fuse('master') |
| 114 | except ErrorReturnCode as e: |
| 115 | self.fail(utils.stderr(e)) |
| 116 | out = utils.stdout(gl.history()) |
| 117 | if 'file1 commit' not in out: |
| 118 | self.fail(out) |
| 119 | |
| 120 | # Merge |
| 121 | gl.switch('branch2') |
| 122 | self.assertRaises(ErrorReturnCode, gl.merge) # no upstream set |
| 123 | gl.merge('master') |
| 124 | out = utils.stdout(gl.history()) |
| 125 | if 'file1 commit' not in out: |
| 126 | self.fail(out) |
| 127 | |