2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-02-27 18:10:17 +00:00

More detailed debug output

This commit is contained in:
Philip Sargent 2022-03-05 18:02:01 +00:00
parent 5fe436e76a
commit 88f5df0f19

@ -121,7 +121,7 @@ class SubprocessTest(TestCase):
pass pass
def test_installs(self): def test_installs(self):
'''Expects external software installed: cavern, survexport, git ''' Expects external software installed: cavern, survexport, git
(but not whether it actually works) (but not whether it actually works)
''' '''
import troggle.settings as settings import troggle.settings as settings
@ -135,28 +135,30 @@ class SubprocessTest(TestCase):
self.assertTrue( False, f'no {i} installed') self.assertTrue( False, f'no {i} installed')
def test_repos_git_status(self): def test_repos_git_status(self):
'''Expects a clean git repo with no added files and no merge failures ''' Expects clean git repos with no added files and no merge failures
''' '''
from pathlib import Path from pathlib import Path
import troggle.settings as settings 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 TROGGLE_PATH = Path(settings.REPOS_ROOT_PATH) / "troggle"
for cwd in [settings.EXPOWEB, settings.DRAWINGS_DATA, TROGGLE_PATH]: # add settings.SURVEX_DATA when loser is gitified
sp = subprocess.run([settings.GIT, "status"], cwd=cwd, capture_output=True, text=True) 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)) scwd = str(cwd)
#print(scwd + ":\n\n" + sp.stderr + '\n\n' + sp.stdout + '\n\nreturn code: ' + str(sp.returncode))
if sp.returncode != 0: if sp.returncode != 0:
print(str(cwd) + ":\n\n" + sp.stderr + '\n\n' + sp.stdout + '\n\nreturn code: ' + str(sp.returncode)) print(scwd + ":\n\n" + sp.stderr + '\n\n' + sp.stdout + '\n\nreturn code: ' + str(sp.returncode))
self.assertTrue( sp.returncode == 0, f'{cwd} - git is unhappy') self.assertTrue( sp.returncode == 0, f'{scwd} - git is unhappy')
content = sp.stdout content = sp.stdout
ph = r'Your branch is up to date' ph = r'Your branch is up to date'
phmatch = re.search(ph, content) phmatch = re.search(ph, content)
self.assertIsNotNone(phmatch, f"{cwd} - Failed to find expected git output: '" + ph +"'") self.assertIsNotNone(phmatch, f"{scwd} - Failed to find expected git output: '" + ph +"'")
ph1 = r'no changes added to commit' ph1 = r'no changes added to commit'
phmatch1 = re.search(ph1, content) phmatch1 = re.search(ph1, content)
ph2 = r'nothing to commit' ph2 = r'nothing to commit'
phmatch2 = re.search(ph2, content) phmatch2 = re.search(ph2, content)
phmatch = phmatch1 or phmatch2 phmatch = phmatch1 or phmatch2
self.assertIsNotNone(phmatch, f"{cwd} - Failed to find expected git output: {ph1} or {ph2}") self.assertIsNotNone(phmatch, f"{scwd} - Failed to find expected git output: {ph1} or {ph2}")