mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-26 04:22:30 -10:00
Revert "Bug 1962485 - Fix jj tests in mozversioncontrol r=sfink,ahal"
This reverts commit b26130c25b.
This commit is contained in:
1 parent
653ab68ea3
commit
11048374bc
5 files changed
+16
-54
No files matched your search
@@ -3,10 +3,8 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
@@ -55,12 +53,13 @@ SETUP = {
|
||||
git config user.email "<[email protected]>"
|
||||
git add *
|
||||
git commit -am "Initial commit"
|
||||
jj git init --colocate
|
||||
jj config set --repo user.name "Testing McTesterson"
|
||||
jj config set --repo user.email "[email protected]"
|
||||
jj describe --reset-author --no-edit
|
||||
""",
|
||||
"""
|
||||
# Pass in user name/email via env vars because the initial commit
|
||||
# will use them before we have a chance to configure them.
|
||||
JJ_USER="Testing McTesterson" JJ_EMAIL="[email protected]" jj git init --colocate
|
||||
jj config set --repo user.name "Testing McTesterson"
|
||||
jj config set --repo user.email "[email protected]"
|
||||
jj git remote add upstream ../remoterepo
|
||||
jj git fetch --remote upstream
|
||||
jj bookmark track master@upstream
|
||||
@@ -97,27 +96,17 @@ def shell(cmd, working_dir):
|
||||
|
||||
|
||||
@pytest.fixture(params=["git", "hg", "jj", "src"])
|
||||
def repo(request):
|
||||
def repo(tmpdir, request):
|
||||
if request.param == "jj":
|
||||
if os.getenv("MOZ_AUTOMATION") == 1:
|
||||
fetches_dir = os.environ.get("MOZ_FETCHES_DIR", "")
|
||||
jj_dir = Path(fetches_dir) / "jj"
|
||||
if jj_dir.is_dir():
|
||||
os.environ["PATH"] = os.pathsep.join([str(jj_dir), os.environ["PATH"]])
|
||||
if platform.system() == "Darwin":
|
||||
pytest.skip(
|
||||
"jj tests disabled for MacOS CI due to incompatible git on workers"
|
||||
)
|
||||
if os.getenv("MOZ_AVOID_JJ_VCS") not in (None, "0", ""):
|
||||
pytest.skip("jj support disabled")
|
||||
try:
|
||||
subprocess.call(["jj", "--version"], stdout=subprocess.DEVNULL)
|
||||
except OSError:
|
||||
pytest.skip("jj unavailable")
|
||||
|
||||
tmpdir = Path(tmpdir)
|
||||
vcs = request.param
|
||||
# Use tempfile since pytest's tempdir is too long for jj on Windows
|
||||
td = tempfile.TemporaryDirectory(prefix=f"{vcs}-repo")
|
||||
tmpdir = Path(td.name)
|
||||
steps = SETUP[vcs]
|
||||
|
||||
if hasattr(request.module, "STEPS"):
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import re
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
@@ -27,7 +26,7 @@ STEPS = {
|
||||
],
|
||||
"jj": [
|
||||
"""
|
||||
jj describe -m "Ignore file for testing"
|
||||
jj describe -m 'Ignore file for testing'
|
||||
echo foo > .gitignore
|
||||
jj new
|
||||
""",
|
||||
@@ -107,32 +106,9 @@ def test_commit(repo):
|
||||
|
||||
# Verify only the intended file was added to the commit
|
||||
patch = vcs._run(*patch_cmd)
|
||||
|
||||
def find_diff_marker(patch: str, filename: str):
|
||||
patterns = [
|
||||
rf"^diff --git a/{re.escape(filename)} b/{re.escape(filename)}$",
|
||||
rf"^Modified regular file {re.escape(filename)}:$",
|
||||
]
|
||||
|
||||
matches = [
|
||||
line
|
||||
for line in patch.splitlines()
|
||||
if any(re.fullmatch(p, line) for p in patterns)
|
||||
]
|
||||
|
||||
assert matches, f"No diff marker found for '{filename}'"
|
||||
assert (
|
||||
len(matches) == 1
|
||||
), f"More than one diff marker for '{filename}': {matches}"
|
||||
|
||||
return matches[0]
|
||||
|
||||
marker = find_diff_marker(patch, "bar")
|
||||
|
||||
assert marker in [
|
||||
"diff --git a/bar b/bar",
|
||||
"Modified regular file bar:",
|
||||
]
|
||||
diffs = [line for line in patch.splitlines() if "diff --git" in line]
|
||||
assert len(diffs) == 1
|
||||
assert diffs[0] == "diff --git a/bar b/bar"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -35,11 +35,10 @@ STEPS = {
|
||||
jj new -m "FIRST PATCH"
|
||||
echo bar >> bar
|
||||
""",
|
||||
# snapshot, since bug 1962245 suppresses automatic ones
|
||||
"""
|
||||
jj new -m "SECOND PATCH"
|
||||
printf "baz\\r\\nqux" > baz
|
||||
jj log -n0
|
||||
jj log -n0 # snapshot, since bug 1962245 suppresses automatic ones
|
||||
""",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -27,13 +27,12 @@ STEPS = {
|
||||
"""
|
||||
],
|
||||
"jj": [
|
||||
# snapshot, since mach's jj integration avoids doing this automatically
|
||||
"""
|
||||
jj new -m "commit 1"
|
||||
echo bar >> bar
|
||||
jj commit -m "commit 2"
|
||||
echo baz > baz
|
||||
jj log -n0
|
||||
jj log -n0 # snapshot, since mach's jj integration avoids doing this automatically
|
||||
"""
|
||||
],
|
||||
}
|
||||
|
||||
@@ -48,12 +48,11 @@ STEPS = {
|
||||
""",
|
||||
],
|
||||
"jj": [
|
||||
# snapshot, since bug 1962245 suppresses automatic ones
|
||||
"""
|
||||
echo "bar" >> bar
|
||||
echo "baz" > baz
|
||||
rm foo
|
||||
jj log -n0
|
||||
jj log -n0 # snapshot, since bug 1962245 suppresses automatic ones
|
||||
""",
|
||||
"""
|
||||
jj commit -m "Remove foo; modify bar; add baz"
|
||||
@@ -61,7 +60,7 @@ STEPS = {
|
||||
"""
|
||||
echo ooka >> baz
|
||||
echo newborn > baby
|
||||
jj log -n0
|
||||
jj log -n0 # snapshot, since bug 1962245 suppresses automatic ones
|
||||
""",
|
||||
"""
|
||||
jj describe -m "Modify baz; add baby"
|
||||
|
||||
Reference in new issue
Block a user