Add git status test for 3 repos

This commit is contained in:
Philip Sargent 2022-03-05 17:42:12 +00:00
parent d7fd6b00ae
commit 5fe436e76a

View File

@ -134,5 +134,29 @@ class SubprocessTest(TestCase):
except subprocess.CalledProcessError:
self.assertTrue( False, f'no {i} installed')
def test_repos_git_status(self):
'''Expects a clean git repo with no added files and no merge failures
'''
from pathlib import Path
import troggle.settings as settings
for cwd in [settings.EXPOWEB, settings.DRAWINGS_DATA, Path(settings.REPOS_ROOT_PATH) / "troggle"]: # add settings.SURVEX_DATA when loser is gitified
sp = subprocess.run([settings.GIT, "status"], cwd=cwd, capture_output=True, text=True)
print(str(cwd) + ":\n\n" + sp.stderr + '\n\n' + sp.stdout + '\n\nreturn code: ' + str(sp.returncode))
if sp.returncode != 0:
print(str(cwd) + ":\n\n" + sp.stderr + '\n\n' + sp.stdout + '\n\nreturn code: ' + str(sp.returncode))
self.assertTrue( sp.returncode == 0, f'{cwd} - git is unhappy')
content = sp.stdout
ph = r'Your branch is up to date'
phmatch = re.search(ph, content)
self.assertIsNotNone(phmatch, f"{cwd} - Failed to find expected git output: '" + ph +"'")
ph1 = r'no changes added to commit'
phmatch1 = re.search(ph1, content)
ph2 = r'nothing to commit'
phmatch2 = re.search(ph2, content)
phmatch = phmatch1 or phmatch2
self.assertIsNotNone(phmatch, f"{cwd} - Failed to find expected git output: {ph1} or {ph2}")