* [PATCH v3 1/8] patman: cosmetic: Fix PEP 8 warnings for the gitutil module.
@ 2022-12-19 22:32 Maxim Cournoyer
2022-12-19 22:32 ` [PATCH v3 2/8] patman: locate test data files via __file__ and pathlib Maxim Cournoyer
` (7 more replies)
0 siblings, 8 replies; 19+ messages in thread
From: Maxim Cournoyer @ 2022-12-19 22:32 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Maxim Cournoyer, Simon Glass
This patch fixes all the PEP 8 warnings reported by Pyflake for the
gitutil module.
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
---
(no changes since v1)
tools/patman/gitutil.py | 106 ++++++++++++++++++++++++----------------
1 file changed, 65 insertions(+), 41 deletions(-)
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
index ceaf2ce150..74c6e94494 100644
--- a/tools/patman/gitutil.py
+++ b/tools/patman/gitutil.py
@@ -2,21 +2,19 @@
# Copyright (c) 2011 The Chromium OS Authors.
#
-import re
import os
-import subprocess
import sys
from patman import command
from patman import settings
from patman import terminal
-from patman import tools
# True to use --no-decorate - we check this in setup()
use_no_decorate = True
+
def log_cmd(commit_range, git_dir=None, oneline=False, reverse=False,
- count=None):
+ count=None):
"""Create a command to perform a 'git log'
Args:
@@ -49,6 +47,7 @@ def log_cmd(commit_range, git_dir=None, oneline=False, reverse=False,
cmd.append('--')
return cmd
+
def count_commits_to_branch(branch):
"""Returns number of commits between HEAD and the tracking branch.
@@ -68,13 +67,14 @@ def count_commits_to_branch(branch):
rev_range = '@{upstream}..'
pipe = [log_cmd(rev_range, oneline=True)]
result = command.run_pipe(pipe, capture=True, capture_stderr=True,
- oneline=True, raise_on_error=False)
+ oneline=True, raise_on_error=False)
if result.return_code:
raise ValueError('Failed to determine upstream: %s' %
result.stderr.strip())
patch_count = len(result.stdout.splitlines())
return patch_count
+
def name_revision(commit_hash):
"""Gets the revision name for a commit
@@ -91,6 +91,7 @@ def name_revision(commit_hash):
name = stdout.split(' ')[1].strip()
return name
+
def guess_upstream(git_dir, branch):
"""Tries to guess the upstream for a branch
@@ -109,7 +110,7 @@ def guess_upstream(git_dir, branch):
"""
pipe = [log_cmd(branch, git_dir=git_dir, oneline=True, count=100)]
result = command.run_pipe(pipe, capture=True, capture_stderr=True,
- raise_on_error=False)
+ raise_on_error=False)
if result.return_code:
return None, "Branch '%s' not found" % branch
for line in result.stdout.splitlines()[1:]:
@@ -121,6 +122,7 @@ def guess_upstream(git_dir, branch):
return name, "Guessing upstream as '%s'" % name
return None, "Cannot find a suitable upstream for branch '%s'" % branch
+
def get_upstream(git_dir, branch):
"""Returns the name of the upstream for a branch
@@ -135,10 +137,10 @@ def get_upstream(git_dir, branch):
"""
try:
remote = command.output_one_line('git', '--git-dir', git_dir, 'config',
- 'branch.%s.remote' % branch)
+ 'branch.%s.remote' % branch)
merge = command.output_one_line('git', '--git-dir', git_dir, 'config',
- 'branch.%s.merge' % branch)
- except:
+ 'branch.%s.merge' % branch)
+ except Exception:
upstream, msg = guess_upstream(git_dir, branch)
return upstream, msg
@@ -149,7 +151,8 @@ def get_upstream(git_dir, branch):
return '%s/%s' % (remote, leaf), None
else:
raise ValueError("Cannot determine upstream branch for branch "
- "'%s' remote='%s', merge='%s'" % (branch, remote, merge))
+ "'%s' remote='%s', merge='%s'"
+ % (branch, remote, merge))
def get_range_in_branch(git_dir, branch, include_upstream=False):
@@ -168,6 +171,7 @@ def get_range_in_branch(git_dir, branch, include_upstream=False):
rstr = '%s%s..%s' % (upstream, '~' if include_upstream else '', branch)
return rstr, msg
+
def count_commits_in_range(git_dir, range_expr):
"""Returns the number of commits in the given range.
@@ -180,12 +184,13 @@ def count_commits_in_range(git_dir, range_expr):
"""
pipe = [log_cmd(range_expr, git_dir=git_dir, oneline=True)]
result = command.run_pipe(pipe, capture=True, capture_stderr=True,
- raise_on_error=False)
+ raise_on_error=False)
if result.return_code:
return None, "Range '%s' not found or is invalid" % range_expr
patch_count = len(result.stdout.splitlines())
return patch_count, None
+
def count_commits_in_branch(git_dir, branch, include_upstream=False):
"""Returns the number of commits in the given branch.
@@ -201,6 +206,7 @@ def count_commits_in_branch(git_dir, branch, include_upstream=False):
return None, msg
return count_commits_in_range(git_dir, range_expr)
+
def count_commits(commit_range):
"""Returns the number of commits in the given range.
@@ -215,6 +221,7 @@ def count_commits(commit_range):
patch_count = int(stdout)
return patch_count
+
def checkout(commit_hash, git_dir=None, work_tree=None, force=False):
"""Checkout the selected commit for this build
@@ -231,10 +238,11 @@ def checkout(commit_hash, git_dir=None, work_tree=None, force=False):
pipe.append('-f')
pipe.append(commit_hash)
result = command.run_pipe([pipe], capture=True, raise_on_error=False,
- capture_stderr=True)
+ capture_stderr=True)
if result.return_code != 0:
raise OSError('git checkout (%s): %s' % (pipe, result.stderr))
+
def clone(git_dir, output_dir):
"""Checkout the selected commit for this build
@@ -243,10 +251,11 @@ def clone(git_dir, output_dir):
"""
pipe = ['git', 'clone', git_dir, '.']
result = command.run_pipe([pipe], capture=True, cwd=output_dir,
- capture_stderr=True)
+ capture_stderr=True)
if result.return_code != 0:
raise OSError('git clone: %s' % result.stderr)
+
def fetch(git_dir=None, work_tree=None):
"""Fetch from the origin repo
@@ -263,6 +272,7 @@ def fetch(git_dir=None, work_tree=None):
if result.return_code != 0:
raise OSError('git fetch: %s' % result.stderr)
+
def check_worktree_is_available(git_dir):
"""Check if git-worktree functionality is available
@@ -274,9 +284,10 @@ def check_worktree_is_available(git_dir):
"""
pipe = ['git', '--git-dir', git_dir, 'worktree', 'list']
result = command.run_pipe([pipe], capture=True, capture_stderr=True,
- raise_on_error=False)
+ raise_on_error=False)
return result.return_code == 0
+
def add_worktree(git_dir, output_dir, commit_hash=None):
"""Create and checkout a new git worktree for this build
@@ -290,10 +301,11 @@ def add_worktree(git_dir, output_dir, commit_hash=None):
if commit_hash:
pipe.append(commit_hash)
result = command.run_pipe([pipe], capture=True, cwd=output_dir,
- capture_stderr=True)
+ capture_stderr=True)
if result.return_code != 0:
raise OSError('git worktree add: %s' % result.stderr)
+
def prune_worktrees(git_dir):
"""Remove administrative files for deleted worktrees
@@ -305,7 +317,8 @@ def prune_worktrees(git_dir):
if result.return_code != 0:
raise OSError('git worktree prune: %s' % result.stderr)
-def create_patches(branch, start, count, ignore_binary, series, signoff = True):
+
+def create_patches(branch, start, count, ignore_binary, series, signoff=True):
"""Create a series of patches from the top of the current branch.
The patch files are written to the current directory using
@@ -321,9 +334,7 @@ def create_patches(branch, start, count, ignore_binary, series, signoff = True):
Filename of cover letter (None if none)
List of filenames of patch files
"""
- if series.get('version'):
- version = '%s ' % series['version']
- cmd = ['git', 'format-patch', '-M' ]
+ cmd = ['git', 'format-patch', '-M']
if signoff:
cmd.append('--signoff')
if ignore_binary:
@@ -341,9 +352,10 @@ def create_patches(branch, start, count, ignore_binary, series, signoff = True):
# We have an extra file if there is a cover letter
if series.get('cover'):
- return files[0], files[1:]
+ return files[0], files[1:]
else:
- return None, files
+ return None, files
+
def build_email_list(in_list, tag=None, alias=None, warn_on_error=True):
"""Build a list of email addresses based on an input list.
@@ -385,40 +397,43 @@ def build_email_list(in_list, tag=None, alias=None, warn_on_error=True):
raw += lookup_email(item, alias, warn_on_error=warn_on_error)
result = []
for item in raw:
- if not item in result:
+ if item not in result:
result.append(item)
if tag:
return ['%s %s%s%s' % (tag, quote, email, quote) for email in result]
return result
+
def check_suppress_cc_config():
"""Check if sendemail.suppresscc is configured correctly.
Returns:
True if the option is configured correctly, False otherwise.
"""
- suppresscc = command.output_one_line('git', 'config', 'sendemail.suppresscc',
- raise_on_error=False)
+ suppresscc = command.output_one_line(
+ 'git', 'config', 'sendemail.suppresscc', raise_on_error=False)
# Other settings should be fine.
if suppresscc == 'all' or suppresscc == 'cccmd':
col = terminal.Color()
print((col.build(col.RED, "error") +
- ": git config sendemail.suppresscc set to %s\n" % (suppresscc)) +
- " patman needs --cc-cmd to be run to set the cc list.\n" +
- " Please run:\n" +
- " git config --unset sendemail.suppresscc\n" +
- " Or read the man page:\n" +
- " git send-email --help\n" +
- " and set an option that runs --cc-cmd\n")
+ ": git config sendemail.suppresscc set to %s\n"
+ % (suppresscc)) +
+ " patman needs --cc-cmd to be run to set the cc list.\n" +
+ " Please run:\n" +
+ " git config --unset sendemail.suppresscc\n" +
+ " Or read the man page:\n" +
+ " git send-email --help\n" +
+ " and set an option that runs --cc-cmd\n")
return False
return True
+
def email_patches(series, cover_fname, args, dry_run, warn_on_error, cc_fname,
- self_only=False, alias=None, in_reply_to=None, thread=False,
- smtp_server=None):
+ self_only=False, alias=None, in_reply_to=None, thread=False,
+ smtp_server=None):
"""Email a patch series.
Args:
@@ -487,9 +502,10 @@ send --cc-cmd cc-fname" cover p1 p2'
"git config sendemail.to u-boot@lists.denx.de")
return
cc = build_email_list(list(set(series.get('cc')) - set(series.get('to'))),
- '--cc', alias, warn_on_error)
+ '--cc', alias, warn_on_error)
if self_only:
- to = build_email_list([os.getenv('USER')], '--to', alias, warn_on_error)
+ to = build_email_list([os.getenv('USER')], '--to',
+ alias, warn_on_error)
cc = []
cmd = ['git', 'send-email', '--annotate']
if smtp_server:
@@ -565,7 +581,7 @@ def lookup_email(lookup_name, alias=None, warn_on_error=True, level=0):
if not alias:
alias = settings.alias
lookup_name = lookup_name.strip()
- if '@' in lookup_name: # Perhaps a real email address
+ if '@' in lookup_name: # Perhaps a real email address
return [lookup_name]
lookup_name = lookup_name.lower()
@@ -581,7 +597,7 @@ def lookup_email(lookup_name, alias=None, warn_on_error=True, level=0):
return out_list
if lookup_name:
- if not lookup_name in alias:
+ if lookup_name not in alias:
msg = "Alias '%s' not found" % lookup_name
if warn_on_error:
print(col.build(col.RED, msg))
@@ -589,11 +605,12 @@ def lookup_email(lookup_name, alias=None, warn_on_error=True, level=0):
for item in alias[lookup_name]:
todo = lookup_email(item, alias, warn_on_error, level + 1)
for new_item in todo:
- if not new_item in out_list:
+ if new_item not in out_list:
out_list.append(new_item)
return out_list
+
def get_top_level():
"""Return name of top-level directory for this git repo.
@@ -608,6 +625,7 @@ def get_top_level():
"""
return command.output_one_line('git', 'rev-parse', '--show-toplevel')
+
def get_alias_file():
"""Gets the name of the git alias file.
@@ -615,7 +633,7 @@ def get_alias_file():
Filename of git alias file, or None if none
"""
fname = command.output_one_line('git', 'config', 'sendemail.aliasesfile',
- raise_on_error=False)
+ raise_on_error=False)
if not fname:
return None
@@ -625,6 +643,7 @@ def get_alias_file():
return os.path.join(get_top_level(), fname)
+
def get_default_user_name():
"""Gets the user.name from .gitconfig file.
@@ -634,6 +653,7 @@ def get_default_user_name():
uname = command.output_one_line('git', 'config', '--global', 'user.name')
return uname
+
def get_default_user_email():
"""Gets the user.email from the global .gitconfig file.
@@ -643,17 +663,19 @@ def get_default_user_email():
uemail = command.output_one_line('git', 'config', '--global', 'user.email')
return uemail
+
def get_default_subject_prefix():
"""Gets the format.subjectprefix from local .git/config file.
Returns:
Subject prefix found in local .git/config file, or None if none
"""
- sub_prefix = command.output_one_line('git', 'config', 'format.subjectprefix',
- raise_on_error=False)
+ sub_prefix = command.output_one_line(
+ 'git', 'config', 'format.subjectprefix', raise_on_error=False)
return sub_prefix
+
def setup():
"""Set up git utils, by reading the alias files."""
# Check for a git alias file also
@@ -666,6 +688,7 @@ def setup():
use_no_decorate = (command.run_pipe([cmd], raise_on_error=False)
.return_code == 0)
+
def get_head():
"""Get the hash of the current HEAD
@@ -674,6 +697,7 @@ def get_head():
"""
return command.output_one_line('git', 'show', '-s', '--pretty=format:%H')
+
if __name__ == "__main__":
import doctest
base-commit: 2243922edca9f56a9d5519b9d6e36f5d7a18434d
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH v3 2/8] patman: locate test data files via __file__ and pathlib
2022-12-19 22:32 [PATCH v3 1/8] patman: cosmetic: Fix PEP 8 warnings for the gitutil module Maxim Cournoyer
@ 2022-12-19 22:32 ` Maxim Cournoyer
2022-12-21 0:28 ` Simon Glass
2022-12-19 22:32 ` [PATCH v3 3/8] patman: invoke the checkpatch.pl script with '--u-boot' and '--strict' Maxim Cournoyer
` (6 subsequent siblings)
7 siblings, 1 reply; 19+ messages in thread
From: Maxim Cournoyer @ 2022-12-19 22:32 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Maxim Cournoyer, Simon Glass
Previously it would rely on the executing script location, which could
break for example when running the tests via 'pytest'.
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
---
(no changes since v1)
tools/patman/func_test.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 7b92bc67be..7fa4a00786 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -7,6 +7,7 @@
"""Functional tests for checking that patman behaves correctly"""
import os
+import pathlib
import re
import shutil
import sys
@@ -28,6 +29,10 @@ from patman.test_util import capture_sys_output
import pygit2
from patman import status
+
+TEST_DATA_DIR = pathlib.Path(__file__).parent / 'test/'
+
+
class TestFunctional(unittest.TestCase):
"""Functional tests for checking that patman behaves correctly"""
leb = (b'Lord Edmund Blackadd\xc3\xabr <weasel@blackadder.org>'.
@@ -57,8 +62,7 @@ class TestFunctional(unittest.TestCase):
Returns:
str: Full path to file in the test directory
"""
- return os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
- 'test', fname)
+ return TEST_DATA_DIR / fname
@classmethod
def _get_text(cls, fname):
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH v3 3/8] patman: invoke the checkpatch.pl script with '--u-boot' and '--strict'
2022-12-19 22:32 [PATCH v3 1/8] patman: cosmetic: Fix PEP 8 warnings for the gitutil module Maxim Cournoyer
2022-12-19 22:32 ` [PATCH v3 2/8] patman: locate test data files via __file__ and pathlib Maxim Cournoyer
@ 2022-12-19 22:32 ` Maxim Cournoyer
2022-12-21 0:28 ` Simon Glass
2022-12-19 22:32 ` [PATCH v3 4/8] patman: rename main script to __main__.py Maxim Cournoyer
` (5 subsequent siblings)
7 siblings, 1 reply; 19+ messages in thread
From: Maxim Cournoyer @ 2022-12-19 22:32 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Maxim Cournoyer, Simon Glass
This resolves 10 out of 11 test failures seen when running './patman
test' from the 'tools/patman' subdirectory. This was caused by the
.checkpatch.conf configuration file at the root of the project not
being picked up. Make the test suite of patman independent from it by
always invoking the checkpatch.pl script with the minimally required
arguments for the test suite to pass.
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
---
Changes in v3:
- Fix typo in commit message
Changes in v2:
- Reword the commit message with a better explanation of the problem
- Add the '--strict' argument to script invocation
tools/patman/checkpatch.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py
index d1b902dd96..012c0d895c 100644
--- a/tools/patman/checkpatch.py
+++ b/tools/patman/checkpatch.py
@@ -211,7 +211,7 @@ def check_patch(fname, verbose=False, show_types=False, use_tree=False):
stdout: Full output of checkpatch
"""
chk = find_check_patch()
- args = [chk]
+ args = [chk, '--u-boot', '--strict']
if not use_tree:
args.append('--no-tree')
if show_types:
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v3 3/8] patman: invoke the checkpatch.pl script with '--u-boot' and '--strict'
2022-12-19 22:32 ` [PATCH v3 3/8] patman: invoke the checkpatch.pl script with '--u-boot' and '--strict' Maxim Cournoyer
@ 2022-12-21 0:28 ` Simon Glass
2023-01-13 10:19 ` Sjoerd Simons
0 siblings, 1 reply; 19+ messages in thread
From: Simon Glass @ 2022-12-21 0:28 UTC (permalink / raw)
To: Maxim Cournoyer; +Cc: Maxim Cournoyer, Simon Glass, U-Boot Mailing List
This resolves 10 out of 11 test failures seen when running './patman
test' from the 'tools/patman' subdirectory. This was caused by the
.checkpatch.conf configuration file at the root of the project not
being picked up. Make the test suite of patman independent from it by
always invoking the checkpatch.pl script with the minimally required
arguments for the test suite to pass.
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
---
Changes in v3:
- Fix typo in commit message
Changes in v2:
- Reword the commit message with a better explanation of the problem
- Add the '--strict' argument to script invocation
tools/patman/checkpatch.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm/next, thanks!
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 3/8] patman: invoke the checkpatch.pl script with '--u-boot' and '--strict'
2022-12-21 0:28 ` Simon Glass
@ 2023-01-13 10:19 ` Sjoerd Simons
2023-01-13 13:54 ` Maxim Cournoyer
0 siblings, 1 reply; 19+ messages in thread
From: Sjoerd Simons @ 2023-01-13 10:19 UTC (permalink / raw)
To: Simon Glass, Maxim Cournoyer; +Cc: Maxim Cournoyer, U-Boot Mailing List
Hey,
This breaks using patman for linux as it's check-patch has no clue
about `--u-boot` :). I'm not sure if people using patman for linux
patches is meant to be a supported use-case though (the documentation
seems to indicate it is)
On Wed, 2022-12-21 at 00:28 +0000, Simon Glass wrote:
> This resolves 10 out of 11 test failures seen when running './patman
> test' from the 'tools/patman' subdirectory. This was caused by the
> .checkpatch.conf configuration file at the root of the project not
> being picked up. Make the test suite of patman independent from it by
> always invoking the checkpatch.pl script with the minimally required
> arguments for the test suite to pass.
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
> ---
>
> Changes in v3:
> - Fix typo in commit message
>
> Changes in v2:
> - Reword the commit message with a better explanation of the problem
> - Add the '--strict' argument to script invocation
>
> tools/patman/checkpatch.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Applied to u-boot-dm/next, thanks!
--
Sjoerd Simons
Collabora Ltd.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 3/8] patman: invoke the checkpatch.pl script with '--u-boot' and '--strict'
2023-01-13 10:19 ` Sjoerd Simons
@ 2023-01-13 13:54 ` Maxim Cournoyer
0 siblings, 0 replies; 19+ messages in thread
From: Maxim Cournoyer @ 2023-01-13 13:54 UTC (permalink / raw)
To: Sjoerd Simons; +Cc: Simon Glass, Maxim Cournoyer, U-Boot Mailing List
Hi Sjoerd,
----- Original Message -----
> From: "Sjoerd Simons" <sjoerd@collabora.com>
> To: "Simon Glass" <sjg@chromium.org>, "Maxim Cournoyer" <maxim.cournoyer@gmail.com>
> Cc: "Maxim Cournoyer" <maxim.cournoyer@savoirfairelinux.com>, "U-Boot Mailing List" <u-boot@lists.denx.de>
> Sent: Friday, January 13, 2023 5:19:39 AM
> Subject: Re: [PATCH v3 3/8] patman: invoke the checkpatch.pl script with '--u-boot' and '--strict'
> Hey,
>
> This breaks using patman for linux as it's check-patch has no clue
> about `--u-boot` :). I'm not sure if people using patman for linux
> patches is meant to be a supported use-case though (the documentation
> seems to indicate it is)
Sorry for the breakage, and thank you for reporting it! I had overlooked that. I've reverted that commit and fixed the test suite via symlinking the top level .checkpatch.conf to tools/patman/.checkpatch.conf instead, which seems to work.
You are CC'd to that change [0], in case you'd like to test it in your environment.
Thank you,
Maxim
[0] https://patchwork.ozlabs.org/project/uboot/patch/20230113135051.22738-2-maxim.cournoyer@savoirfairelinux.com/
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 4/8] patman: rename main script to __main__.py
2022-12-19 22:32 [PATCH v3 1/8] patman: cosmetic: Fix PEP 8 warnings for the gitutil module Maxim Cournoyer
2022-12-19 22:32 ` [PATCH v3 2/8] patman: locate test data files via __file__ and pathlib Maxim Cournoyer
2022-12-19 22:32 ` [PATCH v3 3/8] patman: invoke the checkpatch.pl script with '--u-boot' and '--strict' Maxim Cournoyer
@ 2022-12-19 22:32 ` Maxim Cournoyer
2022-12-21 0:28 ` Simon Glass
2022-12-19 22:32 ` [PATCH v3 5/8] patman: add pytest configuration file Maxim Cournoyer
` (4 subsequent siblings)
7 siblings, 1 reply; 19+ messages in thread
From: Maxim Cournoyer @ 2022-12-19 22:32 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Maxim Cournoyer, Simon Glass
This allows running the package as a Python module, like e.g.:
$ python -m patman
It also prevents Pytest from attempting to parse main.py, which
would cause errors.
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
---
(no changes since v1)
tools/patman/{main.py => __main__.py} | 0
tools/patman/patman | 2 +-
2 files changed, 1 insertion(+), 1 deletion(-)
rename tools/patman/{main.py => __main__.py} (100%)
diff --git a/tools/patman/main.py b/tools/patman/__main__.py
similarity index 100%
rename from tools/patman/main.py
rename to tools/patman/__main__.py
diff --git a/tools/patman/patman b/tools/patman/patman
index 11a5d8e18a..5a427d1942 120000
--- a/tools/patman/patman
+++ b/tools/patman/patman
@@ -1 +1 @@
-main.py
\ No newline at end of file
+__main__.py
\ No newline at end of file
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v3 4/8] patman: rename main script to __main__.py
2022-12-19 22:32 ` [PATCH v3 4/8] patman: rename main script to __main__.py Maxim Cournoyer
@ 2022-12-21 0:28 ` Simon Glass
2022-12-21 0:30 ` Simon Glass
0 siblings, 1 reply; 19+ messages in thread
From: Simon Glass @ 2022-12-21 0:28 UTC (permalink / raw)
To: Maxim Cournoyer; +Cc: Maxim Cournoyer, Simon Glass, U-Boot Mailing List
This allows running the package as a Python module, like e.g.:
$ python -m patman
It also prevents Pytest from attempting to parse main.py, which
would cause errors.
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
---
(no changes since v1)
tools/patman/{main.py => __main__.py} | 0
tools/patman/patman | 2 +-
2 files changed, 1 insertion(+), 1 deletion(-)
rename tools/patman/{main.py => __main__.py} (100%)
Applied to u-boot-dm/next, thanks!
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v3 4/8] patman: rename main script to __main__.py
2022-12-21 0:28 ` Simon Glass
@ 2022-12-21 0:30 ` Simon Glass
0 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2022-12-21 0:30 UTC (permalink / raw)
To: Maxim Cournoyer; +Cc: Maxim Cournoyer, U-Boot Mailing List
Hi Maxim,
On Tue, 20 Dec 2022 at 17:28, Simon Glass <sjg@chromium.org> wrote:
>
> This allows running the package as a Python module, like e.g.:
>
> $ python -m patman
>
> It also prevents Pytest from attempting to parse main.py, which
> would cause errors.
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
> ---
>
> (no changes since v1)
>
> tools/patman/{main.py => __main__.py} | 0
> tools/patman/patman | 2 +-
> 2 files changed, 1 insertion(+), 1 deletion(-)
> rename tools/patman/{main.py => __main__.py} (100%)
>
> Applied to u-boot-dm/next, thanks!
I did a little fix-up on this one to rename the file in __init__.py
Regards,
Simon
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 5/8] patman: add pytest configuration file
2022-12-19 22:32 [PATCH v3 1/8] patman: cosmetic: Fix PEP 8 warnings for the gitutil module Maxim Cournoyer
` (2 preceding siblings ...)
2022-12-19 22:32 ` [PATCH v3 4/8] patman: rename main script to __main__.py Maxim Cournoyer
@ 2022-12-19 22:32 ` Maxim Cournoyer
2022-12-21 0:28 ` Simon Glass
2022-12-19 22:32 ` [PATCH v3 6/8] patman: hide the 'test' command unless test data is available Maxim Cournoyer
` (3 subsequent siblings)
7 siblings, 1 reply; 19+ messages in thread
From: Maxim Cournoyer @ 2022-12-19 22:32 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Maxim Cournoyer, Simon Glass
With this change, a user can run the patman test suite using Pytest
the same as when using 'patman test':
$ cd tools/patman && pytest
[...]
44 passed, 8 warnings in 8.87s
$ ./patman test
Ran 44 tests in 8.460s
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
---
(no changes since v1)
tools/patman/pytest.ini | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 tools/patman/pytest.ini
diff --git a/tools/patman/pytest.ini b/tools/patman/pytest.ini
new file mode 100644
index 0000000000..df3eb518d0
--- /dev/null
+++ b/tools/patman/pytest.ini
@@ -0,0 +1,2 @@
+[pytest]
+addopts = --doctest-modules
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v3 5/8] patman: add pytest configuration file
2022-12-19 22:32 ` [PATCH v3 5/8] patman: add pytest configuration file Maxim Cournoyer
@ 2022-12-21 0:28 ` Simon Glass
0 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2022-12-21 0:28 UTC (permalink / raw)
To: Maxim Cournoyer; +Cc: Maxim Cournoyer, Simon Glass, U-Boot Mailing List
With this change, a user can run the patman test suite using Pytest
the same as when using 'patman test':
$ cd tools/patman && pytest
[...]
44 passed, 8 warnings in 8.87s
$ ./patman test
Ran 44 tests in 8.460s
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
---
(no changes since v1)
tools/patman/pytest.ini | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 tools/patman/pytest.ini
Applied to u-boot-dm/next, thanks!
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 6/8] patman: hide the 'test' command unless test data is available
2022-12-19 22:32 [PATCH v3 1/8] patman: cosmetic: Fix PEP 8 warnings for the gitutil module Maxim Cournoyer
` (3 preceding siblings ...)
2022-12-19 22:32 ` [PATCH v3 5/8] patman: add pytest configuration file Maxim Cournoyer
@ 2022-12-19 22:32 ` Maxim Cournoyer
2022-12-21 0:28 ` Simon Glass
2022-12-19 22:32 ` [PATCH v3 7/8] patman: document how to run test suite via pytest Maxim Cournoyer
` (2 subsequent siblings)
7 siblings, 1 reply; 19+ messages in thread
From: Maxim Cournoyer @ 2022-12-19 22:32 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Maxim Cournoyer, Simon Glass
Some tests would fail when the test data is not available, so it
doesn't make much sense to expose the action when patman is running
outside of the u-boot git checkout.
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
---
Changes in v3:
- Mention the test command is hidden unless run from the git repo
tools/patman/__main__.py | 9 ++++++---
tools/patman/patman.rst | 4 ++++
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 5a7756a221..82cef4fc0b 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -21,6 +21,7 @@ if __name__ == "__main__":
# Our modules
from patman import command
from patman import control
+from patman import func_test
from patman import gitutil
from patman import project
from patman import settings
@@ -96,9 +97,11 @@ send.add_argument('--smtp-server', type=str,
send.add_argument('patchfiles', nargs='*')
-test_parser = subparsers.add_parser('test', help='Run tests')
-test_parser.add_argument('testname', type=str, default=None, nargs='?',
- help="Specify the test to run")
+# Only add the 'test' action if the test data files are available.
+if os.path.exists(func_test.TEST_DATA_DIR):
+ test_parser = subparsers.add_parser('test', help='Run tests')
+ test_parser.add_argument('testname', type=str, default=None, nargs='?',
+ help="Specify the test to run")
status = subparsers.add_parser('status',
help='Check status of patches in patchwork')
diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst
index 8c5c9cc2cc..ff4c8b3ed2 100644
--- a/tools/patman/patman.rst
+++ b/tools/patman/patman.rst
@@ -680,6 +680,10 @@ them:
$ tools/patman/patman test
+Note that since the test suite depends on data files only available in
+the git checkout, the `test` command is hidden unless `patman` is
+invoked from the U-Boot git repository.
+
Error handling doesn't always produce friendly error messages - e.g.
putting an incorrect tag in a commit may provide a confusing message.
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v3 6/8] patman: hide the 'test' command unless test data is available
2022-12-19 22:32 ` [PATCH v3 6/8] patman: hide the 'test' command unless test data is available Maxim Cournoyer
@ 2022-12-21 0:28 ` Simon Glass
0 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2022-12-21 0:28 UTC (permalink / raw)
To: Maxim Cournoyer; +Cc: Maxim Cournoyer, Simon Glass, U-Boot Mailing List
Some tests would fail when the test data is not available, so it
doesn't make much sense to expose the action when patman is running
outside of the u-boot git checkout.
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
---
Changes in v3:
- Mention the test command is hidden unless run from the git repo
tools/patman/__main__.py | 9 ++++++---
tools/patman/patman.rst | 4 ++++
2 files changed, 10 insertions(+), 3 deletions(-)
Applied to u-boot-dm/next, thanks!
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 7/8] patman: document how to run test suite via pytest
2022-12-19 22:32 [PATCH v3 1/8] patman: cosmetic: Fix PEP 8 warnings for the gitutil module Maxim Cournoyer
` (4 preceding siblings ...)
2022-12-19 22:32 ` [PATCH v3 6/8] patman: hide the 'test' command unless test data is available Maxim Cournoyer
@ 2022-12-19 22:32 ` Maxim Cournoyer
2022-12-21 0:28 ` Simon Glass
2022-12-19 22:32 ` [PATCH v3 8/8] patman: document default 'send' command Maxim Cournoyer
2022-12-21 0:28 ` [PATCH v3 1/8] patman: cosmetic: Fix PEP 8 warnings for the gitutil module Simon Glass
7 siblings, 1 reply; 19+ messages in thread
From: Maxim Cournoyer @ 2022-12-19 22:32 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Maxim Cournoyer, Simon Glass
Pytest offers useful features such as selecting tests by means of a
regular expression, or running the pdb debugger upon encountering a
test failure.
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
---
(no changes since v1)
tools/patman/patman.rst | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst
index ff4c8b3ed2..395fc0cd75 100644
--- a/tools/patman/patman.rst
+++ b/tools/patman/patman.rst
@@ -684,6 +684,12 @@ Note that since the test suite depends on data files only available in
the git checkout, the `test` command is hidden unless `patman` is
invoked from the U-Boot git repository.
+Alternatively, you can run the test suite via Pytest:
+
+.. code-block:: bash
+
+ $ cd tools/patman && pytest
+
Error handling doesn't always produce friendly error messages - e.g.
putting an incorrect tag in a commit may provide a confusing message.
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH v3 8/8] patman: document default 'send' command
2022-12-19 22:32 [PATCH v3 1/8] patman: cosmetic: Fix PEP 8 warnings for the gitutil module Maxim Cournoyer
` (5 preceding siblings ...)
2022-12-19 22:32 ` [PATCH v3 7/8] patman: document how to run test suite via pytest Maxim Cournoyer
@ 2022-12-19 22:32 ` Maxim Cournoyer
2022-12-21 0:28 ` Simon Glass
2022-12-21 0:28 ` [PATCH v3 1/8] patman: cosmetic: Fix PEP 8 warnings for the gitutil module Simon Glass
7 siblings, 1 reply; 19+ messages in thread
From: Maxim Cournoyer @ 2022-12-19 22:32 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Maxim Cournoyer, Simon Glass
Document that this command is the default and what it's intended for.
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
---
(no changes since v1)
tools/patman/__main__.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 82cef4fc0b..11f19281fb 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -56,7 +56,8 @@ parser.add_argument('-H', '--full-help', action='store_true', dest='full_help',
default=False, help='Display the README file')
subparsers = parser.add_subparsers(dest='cmd')
-send = subparsers.add_parser('send')
+send = subparsers.add_parser(
+ 'send', help='Format, check and email patches (default command)')
send.add_argument('-i', '--ignore-errors', action='store_true',
dest='ignore_errors', default=False,
help='Send patches email even if patch errors are found')
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v3 1/8] patman: cosmetic: Fix PEP 8 warnings for the gitutil module.
2022-12-19 22:32 [PATCH v3 1/8] patman: cosmetic: Fix PEP 8 warnings for the gitutil module Maxim Cournoyer
` (6 preceding siblings ...)
2022-12-19 22:32 ` [PATCH v3 8/8] patman: document default 'send' command Maxim Cournoyer
@ 2022-12-21 0:28 ` Simon Glass
7 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2022-12-21 0:28 UTC (permalink / raw)
To: Maxim Cournoyer; +Cc: Maxim Cournoyer, Simon Glass, U-Boot Mailing List
This patch fixes all the PEP 8 warnings reported by Pyflake for the
gitutil module.
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
---
(no changes since v1)
tools/patman/gitutil.py | 106 ++++++++++++++++++++++++----------------
1 file changed, 65 insertions(+), 41 deletions(-)
Applied to u-boot-dm/next, thanks!
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2023-01-13 20:32 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-19 22:32 [PATCH v3 1/8] patman: cosmetic: Fix PEP 8 warnings for the gitutil module Maxim Cournoyer
2022-12-19 22:32 ` [PATCH v3 2/8] patman: locate test data files via __file__ and pathlib Maxim Cournoyer
2022-12-21 0:28 ` Simon Glass
2022-12-19 22:32 ` [PATCH v3 3/8] patman: invoke the checkpatch.pl script with '--u-boot' and '--strict' Maxim Cournoyer
2022-12-21 0:28 ` Simon Glass
2023-01-13 10:19 ` Sjoerd Simons
2023-01-13 13:54 ` Maxim Cournoyer
2022-12-19 22:32 ` [PATCH v3 4/8] patman: rename main script to __main__.py Maxim Cournoyer
2022-12-21 0:28 ` Simon Glass
2022-12-21 0:30 ` Simon Glass
2022-12-19 22:32 ` [PATCH v3 5/8] patman: add pytest configuration file Maxim Cournoyer
2022-12-21 0:28 ` Simon Glass
2022-12-19 22:32 ` [PATCH v3 6/8] patman: hide the 'test' command unless test data is available Maxim Cournoyer
2022-12-21 0:28 ` Simon Glass
2022-12-19 22:32 ` [PATCH v3 7/8] patman: document how to run test suite via pytest Maxim Cournoyer
2022-12-21 0:28 ` Simon Glass
2022-12-19 22:32 ` [PATCH v3 8/8] patman: document default 'send' command Maxim Cournoyer
2022-12-21 0:28 ` Simon Glass
2022-12-21 0:28 ` [PATCH v3 1/8] patman: cosmetic: Fix PEP 8 warnings for the gitutil module Simon Glass
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox