Skip to content

Commit 0d664a7

Browse files
committed
tests: fix on mac os
On macOS, BSD sed interpreted the script pattern `1s/1/2/` as the backup suffix and failed with a non-zero exit code. Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent b770b2b commit 0d664a7

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

tests/scripts/test_pkgdev_commit.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def test_git_message_opts(self, repo, make_git_repo, tmp_path):
259259
repo.create_ebuild("cat/pkg-1")
260260
git_repo.add_all("cat/pkg-1", commit=False)
261261
with (
262-
os_environ(GIT_EDITOR="sed -i '1s/1/2/'"),
262+
os_environ(GIT_EDITOR="sed -i '' '1s/1/2/'"),
263263
patch("sys.argv", self.args + ["-u", "-t", path]),
264264
pytest.raises(SystemExit) as excinfo,
265265
chdir(git_repo.path),
@@ -391,7 +391,7 @@ def test_edited_commit_message(self, capsys, repo, make_git_repo):
391391
f.write("# comment\n")
392392

393393
with (
394-
os_environ(GIT_EDITOR="sed -i '1s/$/commit/'"),
394+
os_environ(GIT_EDITOR="sed -i '' '1s/$/commit/'"),
395395
patch("sys.argv", self.args + ["-u"]),
396396
pytest.raises(SystemExit) as excinfo,
397397
chdir(git_repo.path),
@@ -496,7 +496,7 @@ def test_generated_commit_summaries(self, capsys, repo, make_git_repo):
496496

497497
def commit():
498498
with (
499-
os_environ(GIT_EDITOR="sed -i '1s/$/summary/'"),
499+
os_environ(GIT_EDITOR="sed -i '' '1s/$/summary/'"),
500500
patch("sys.argv", self.args + ["-a"]),
501501
pytest.raises(SystemExit) as excinfo,
502502
chdir(git_repo.path),
@@ -650,7 +650,7 @@ def test_generated_commit_summaries_keywords(self, capsys, make_repo, make_git_r
650650

651651
def commit():
652652
with (
653-
os_environ(GIT_EDITOR="sed -i '1s/$/summary/'"),
653+
os_environ(GIT_EDITOR="sed -i '' '1s/$/summary/'"),
654654
patch("sys.argv", self.args + ["-a"]),
655655
pytest.raises(SystemExit) as excinfo,
656656
chdir(git_repo.path),
@@ -731,7 +731,7 @@ def test_metadata_summaries(self, capsys, repo, make_git_repo):
731731

732732
def commit():
733733
with (
734-
os_environ(GIT_EDITOR="sed -i '1s/$/summary/'"),
734+
os_environ(GIT_EDITOR="sed -i '' '1s/$/summary/'"),
735735
patch("sys.argv", self.args + ["-a"]),
736736
pytest.raises(SystemExit) as excinfo,
737737
chdir(git_repo.path),
@@ -923,7 +923,7 @@ def test_no_summary(self, capsys, repo, make_git_repo):
923923

924924
def commit(args):
925925
with (
926-
os_environ(GIT_EDITOR="sed -i '1s/$/summary/'"),
926+
os_environ(GIT_EDITOR="sed -i '' '1s/$/summary/'"),
927927
patch("sys.argv", self.args + args),
928928
pytest.raises(SystemExit) as excinfo,
929929
chdir(git_repo.path),

tests/scripts/test_pkgdev_mask.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def test_nonexistent_visual(self, capsys):
146146

147147
def test_failed_editor(self, capsys):
148148
with (
149-
os_environ("VISUAL", EDITOR="sed -i 's///'"),
149+
os_environ("VISUAL", EDITOR="sed -i '' 's///'"),
150150
patch("sys.argv", self.args + ["cat/pkg"]),
151151
pytest.raises(SystemExit),
152152
chdir(pjoin(self.repo.path)),
@@ -157,7 +157,7 @@ def test_failed_editor(self, capsys):
157157

158158
def test_empty_mask_comment(self, capsys):
159159
with (
160-
os_environ("VISUAL", EDITOR="sed -i 's/#/#/'"),
160+
os_environ("VISUAL", EDITOR="sed -i '' 's/#/#/'"),
161161
patch("sys.argv", self.args + ["cat/pkg"]),
162162
pytest.raises(SystemExit),
163163
chdir(pjoin(self.repo.path)),
@@ -168,7 +168,7 @@ def test_empty_mask_comment(self, capsys):
168168

169169
def test_mask_cwd(self):
170170
with (
171-
os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"),
171+
os_environ("VISUAL", EDITOR="sed -i '' '1s/$/mask comment/'"),
172172
patch("sys.argv", self.args),
173173
pytest.raises(SystemExit),
174174
chdir(pjoin(self.repo.path, "cat/pkg")),
@@ -178,7 +178,7 @@ def test_mask_cwd(self):
178178

179179
def test_mask_target(self):
180180
with (
181-
os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"),
181+
os_environ("VISUAL", EDITOR="sed -i '' '1s/$/mask comment/'"),
182182
patch("sys.argv", self.args + ["cat/pkg"]),
183183
pytest.raises(SystemExit),
184184
chdir(pjoin(self.repo.path)),
@@ -188,7 +188,7 @@ def test_mask_target(self):
188188

189189
def test_mask_ebuild_path(self):
190190
with (
191-
os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"),
191+
os_environ("VISUAL", EDITOR="sed -i '' '1s/$/mask comment/'"),
192192
patch("sys.argv", self.args + ["cat/pkg/pkg-0.ebuild"]),
193193
pytest.raises(SystemExit),
194194
chdir(pjoin(self.repo.path)),
@@ -208,7 +208,7 @@ def test_existing_masks(self):
208208
)
209209

210210
with (
211-
os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"),
211+
os_environ("VISUAL", EDITOR="sed -i '' '1s/$/mask comment/'"),
212212
patch("sys.argv", self.args + ["=cat/pkg-0"]),
213213
pytest.raises(SystemExit),
214214
chdir(pjoin(self.repo.path)),
@@ -236,7 +236,7 @@ def test_invalid_header(self, capsys):
236236
)
237237

238238
with (
239-
os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"),
239+
os_environ("VISUAL", EDITOR="sed -i '' '1s/$/mask comment/'"),
240240
patch("sys.argv", self.args + ["=cat/pkg-0"]),
241241
pytest.raises(SystemExit),
242242
chdir(pjoin(self.repo.path)),
@@ -268,7 +268,7 @@ def test_invalid_author(self, capsys):
268268
)
269269

270270
with (
271-
os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"),
271+
os_environ("VISUAL", EDITOR="sed -i '' '1s/$/mask comment/'"),
272272
patch("sys.argv", self.args + ["=cat/pkg-0"]),
273273
pytest.raises(SystemExit),
274274
chdir(pjoin(self.repo.path)),
@@ -281,7 +281,7 @@ def test_last_rites(self):
281281
for rflag in ("-r", "--rites"):
282282
for args in ([rflag], [rflag, "14"]):
283283
with (
284-
os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"),
284+
os_environ("VISUAL", EDITOR="sed -i '' '1s/$/mask comment/'"),
285285
patch("sys.argv", self.args + ["cat/pkg"] + args),
286286
pytest.raises(SystemExit),
287287
chdir(pjoin(self.repo.path)),
@@ -308,7 +308,7 @@ def test_last_rites_with_email(self, tmp_path):
308308
for rflag in ("-r", "--rites"):
309309
with (
310310
os_environ(
311-
"VISUAL", EDITOR="sed -i '1s/$/mask comment/'", MAILER=f"> {output_file} echo"
311+
"VISUAL", EDITOR="sed -i '' '1s/$/mask comment/'", MAILER=f"> {output_file} echo"
312312
),
313313
patch("sys.argv", self.args + ["cat/pkg", rflag, "--email"]),
314314
pytest.raises(SystemExit),
@@ -324,7 +324,7 @@ def test_last_rites_with_email(self, tmp_path):
324324
def test_last_email_bad_mailer(self, capsys):
325325
for rflag in ("-r", "--rites"):
326326
with (
327-
os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'", MAILER="false"),
327+
os_environ("VISUAL", EDITOR="sed -i '' '1s/$/mask comment/'", MAILER="false"),
328328
patch("sys.argv", self.args + ["cat/pkg", rflag, "--email"]),
329329
pytest.raises(SystemExit),
330330
chdir(pjoin(self.repo.path)),
@@ -345,7 +345,7 @@ def test_mask_bugs(self):
345345
for bug_num in bug_nums:
346346
args += [bflag, bug_num]
347347
with (
348-
os_environ("VISUAL", EDITOR="sed -i '1s/$/mask comment/'"),
348+
os_environ("VISUAL", EDITOR="sed -i '' '1s/$/mask comment/'"),
349349
patch("sys.argv", self.args + ["cat/pkg"] + args),
350350
pytest.raises(SystemExit),
351351
chdir(pjoin(self.repo.path)),

0 commit comments

Comments
 (0)