From f05b00e73f0076a7cebb6206863c310a78c3d288 Mon Sep 17 00:00:00 2001 From: Nicolas Roche Date: Thu, 23 Nov 2023 12:43:33 +0100 Subject: [PATCH] Fix two tests related to darwin and recent git * add initial_branch parameter to git init * disable linux only tests on darwin --- src/e3/vcs/git.py | 10 ++++++++-- tests/tests_e3/os/process/main_test.py | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/e3/vcs/git.py b/src/e3/vcs/git.py index ec8703a1..1447c730 100644 --- a/src/e3/vcs/git.py +++ b/src/e3/vcs/git.py @@ -147,16 +147,22 @@ def git_cmd( ) return p - def init(self, url: str | None = None, remote: str | None = "origin") -> None: + def init( + self, + url: str | None = None, + remote: str | None = "origin", + initial_branch: str = "master", + ) -> None: """Initialize a new Git repository and configure the remote. :param url: url of the remote repository, if None create a local git repository :param remote: name of the remote to create + :param initial_branch: name of the initial branch (default is master) :raise: GitError """ e3.fs.mkdir(self.working_tree) - self.git_cmd(["init", "-q"]) + self.git_cmd(["init", "-q", f"--initial-branch={initial_branch}"]) # Git version 1.8.3.1 might crash when calling "git stash" when # .git/logs/refs is not created. Recent versions of git do not diff --git a/tests/tests_e3/os/process/main_test.py b/tests/tests_e3/os/process/main_test.py index e9168868..b87989bf 100644 --- a/tests/tests_e3/os/process/main_test.py +++ b/tests/tests_e3/os/process/main_test.py @@ -120,7 +120,7 @@ def run_test(): e.restore() -@pytest.mark.skipif(sys.platform == "win32", reason="A linux test") +@pytest.mark.skipif(not sys.platform.startswith("linux"), reason="A linux test") def test_rlimit_ctrl_c(): """Test rlimit CTRL-C. @@ -193,7 +193,7 @@ def test_rlimit_ctrl_c(): assert int(end - start) < 30, f"CTRL-C failed: take {int(end - start)} seconds" -@pytest.mark.skipif(sys.platform == "win32", reason="A linux test") +@pytest.mark.skipif(not sys.platform.startswith("linux"), reason="A linux test") def test_rlimit_foreground_option(): """Test rlimit --foreground.