From eaca7dc80c765dd3a8dbe4c8fb3b206656bbc5e2 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Sun, 3 Feb 2019 15:52:21 +0200 Subject: [PATCH] travis: osx: handle EAGAIN error Signed-off-by: Ruslan Kuprieiev --- tests/basic_env.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/basic_env.py b/tests/basic_env.py index 52a775343..dd24be067 100644 --- a/tests/basic_env.py +++ b/tests/basic_env.py @@ -73,9 +73,23 @@ class TestDir(TestCase): class TestGit(TestDir): + N_RETRIES = 5 def setUp(self): super(TestGit, self).setUp() - self.git = Repo.init() + # NOTE: handles EAGAIN error on BSD systems (osx in our case). + # Otherwise when running tests you might get this exception: + # + # GitCommandNotFound: Cmd('git') not found due to: + # OSError('[Errno 35] Resource temporarily unavailable') + retries = self.N_RETRIES + while retries: + try: + self.git = Repo.init() + except GitCommandNotFound as exc: + retries -= 1 + continue + break + self.git.index.add([self.CODE]) self.git.index.commit("add code")