All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [RFC PATCH 08/16] patman: Add a 'test' subcommand
Date: Sun,  5 Jul 2020 21:41:55 -0600	[thread overview]
Message-ID: <20200706034203.2171077-9-sjg@chromium.org> (raw)
In-Reply-To: <20200706034203.2171077-1-sjg@chromium.org>

At present we use --test to indicate that tests should be run. It is
better to use a subcommand for list, like binman. Change it and adjust
the existing code to fit under a 'send' subcommand, the default.

Give this subcommand the same default arguments as the others.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 .azure-pipelines.yml      |  2 +-
 .gitlab-ci.yml            |  2 +-
 .travis.yml               |  2 +-
 test/run                  |  2 +-
 tools/patman/main.py      | 75 +++++++++++++++++++++------------------
 tools/patman/test_util.py |  2 +-
 6 files changed, 45 insertions(+), 40 deletions(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 9f88a539c0..45f0fabd6d 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -158,7 +158,7 @@ jobs:
           ./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test
           ./tools/buildman/buildman -t
           ./tools/dtoc/dtoc -t
-          ./tools/patman/patman --test
+          ./tools/patman/patman test
           make O=${UBOOT_TRAVIS_BUILD_DIR} testconfig
           EOF
           cat build.sh
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a685a7879d..c3d8ef6543 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -167,7 +167,7 @@ Run binman, buildman, dtoc, Kconfig and patman testsuites:
       ./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test;
       ./tools/buildman/buildman -t;
       ./tools/dtoc/dtoc -t;
-      ./tools/patman/patman --test;
+      ./tools/patman/patman test;
       make testconfig
 
 Run tests for Nokia RX-51 (aka N900):
diff --git a/.travis.yml b/.travis.yml
index a042aa2c7d..4ce760d938 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -257,7 +257,7 @@ script:
        export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt";
        export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}";
        ./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test &&
-       ./tools/patman/patman --test &&
+       ./tools/patman/patman test &&
        ./tools/buildman/buildman -t &&
        ./tools/dtoc/dtoc -t &&
        make testconfig;
diff --git a/test/run b/test/run
index 27331a8e40..de87e7530b 100755
--- a/test/run
+++ b/test/run
@@ -48,7 +48,7 @@ export DTC=${DTC_DIR}/dtc
 TOOLS_DIR=build-sandbox_spl/tools
 
 run_test "binman" ./tools/binman/binman --toolpath ${TOOLS_DIR} test
-run_test "patman" ./tools/patman/patman --test
+run_test "patman" ./tools/patman/patman test
 
 run_test "buildman" ./tools/buildman/buildman -t ${skip}
 run_test "fdt" ./tools/dtoc/test_fdt -t
diff --git a/tools/patman/main.py b/tools/patman/main.py
index fee9bc848b..77f187e769 100755
--- a/tools/patman/main.py
+++ b/tools/patman/main.py
@@ -27,6 +27,16 @@ from patman import terminal
 from patman import test_util
 from patman import test_checkpatch
 
+def AddCommonArgs(parser):
+    parser.add_argument('-b', '--branch', type=str,
+        help="Branch to process (by default, the current branch)")
+    parser.add_argument('-c', '--count', dest='count', type=int,
+        default=-1, help='Automatically create patches from top n commits')
+    parser.add_argument('-e', '--end', type=int, default=0,
+        help='Commits to skip at end of patch list')
+    parser.add_argument('-s', '--start', dest='start', type=int,
+        default=0, help='Commit to start creating patches from (0 = HEAD)')
+
 epilog = '''Create patches from commits in a branch, check them and email them
 as specified by tags you place in the commits. Use -n to do a dry run first.'''
 
@@ -35,12 +45,6 @@ subparsers = parser.add_subparsers(dest='cmd')
 send = subparsers.add_parser('send')
 send.add_argument('-H', '--full-help', action='store_true', dest='full_help',
        default=False, help='Display the README file')
-send.add_argument('-b', '--branch', type=str,
-                  help="Branch to process (by default, the current branch)")
-send.add_argument('-c', '--count', dest='count', type=int,
-       default=-1, help='Automatically create patches from top n commits')
-send.add_argument('-e', '--end', type=int, default=0,
-                  help='Commits to skip at end of patch list')
 send.add_argument('-i', '--ignore-errors', action='store_true',
        dest='ignore_errors', default=False,
        help='Send patches email even if patch errors are found')
@@ -56,8 +60,6 @@ send.add_argument('-p', '--project', default=project.DetectProject(),
                   "aliases [default: %(default)s]")
 send.add_argument('-r', '--in-reply-to', type=str, action='store',
                   help="Message ID that this series is in reply to")
-send.add_argument('-s', '--start', dest='start', type=int,
-       default=0, help='Commit to start creating patches from (0 = HEAD)')
 send.add_argument('-t', '--ignore-bad-tags', action='store_true',
                   default=False, help='Ignore bad tags / aliases')
 send.add_argument('-v', '--verbose', action='store_true', dest='verbose',
@@ -76,11 +78,13 @@ send.add_argument('--no-tags', action='store_false', dest='process_tags',
                   default=True, help="Don't process subject tags as aliases")
 send.add_argument('--smtp-server', type=str,
                   help="Specify the SMTP server to 'git send-email'")
-send.add_argument('--test', action='store_true', dest='test',
-                  default=False, help='run tests')
+AddCommonArgs(send)
 
 send.add_argument('patchfiles', nargs='*')
 
+test_parser = subparsers.add_parser('test', help='Run tests')
+AddCommonArgs(test_parser)
+
 # Parse options twice: first to get the project and second to handle
 # defaults properly (which depends on project).
 argv = sys.argv[1:]
@@ -95,7 +99,7 @@ if __name__ != "__main__":
     pass
 
 # Run our meagre tests
-elif args.test:
+if args.cmd == 'test':
     import doctest
     from patman import func_test
 
@@ -111,28 +115,29 @@ elif args.test:
 
     sys.exit(test_util.ReportResult('patman', None, result))
 
-# Called from git with a patch filename as argument
-# Printout a list of additional CC recipients for this patch
-elif args.cc_cmd:
-    fd = open(args.cc_cmd, 'r')
-    re_line = re.compile('(\S*) (.*)')
-    for line in fd.readlines():
-        match = re_line.match(line)
-        if match and match.group(1) == args.patchfiles[0]:
-            for cc in match.group(2).split('\0'):
-                cc = cc.strip()
-                if cc:
-                    print(cc)
-    fd.close()
-
-elif args.full_help:
-    pager = os.getenv('PAGER')
-    if not pager:
-        pager = 'more'
-    fname = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
-                         'README')
-    command.Run(pager, fname)
-
 # Process commits, produce patches files, check them, email them
-else:
-    control.send(args)
+elif args.cmd == 'send':
+    # Called from git with a patch filename as argument
+    # Printout a list of additional CC recipients for this patch
+    if args.cc_cmd:
+        fd = open(args.cc_cmd, 'r')
+        re_line = re.compile('(\S*) (.*)')
+        for line in fd.readlines():
+            match = re_line.match(line)
+            if match and match.group(1) == args.patchfiles[0]:
+                for cc in match.group(2).split('\0'):
+                    cc = cc.strip()
+                    if cc:
+                        print(cc)
+        fd.close()
+
+    elif args.full_help:
+        pager = os.getenv('PAGER')
+        if not pager:
+            pager = 'more'
+        fname = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
+                             'README')
+        command.Run(pager, fname)
+
+    else:
+        control.send(args)
diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py
index 0827488f33..a87d3cc8f3 100644
--- a/tools/patman/test_util.py
+++ b/tools/patman/test_util.py
@@ -47,7 +47,7 @@ def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None):
         glob_list = []
     glob_list += exclude_list
     glob_list += ['*libfdt.py', '*site-packages*', '*dist-packages*']
-    test_cmd = 'test' if 'binman' in prog else '-t'
+    test_cmd = 'test' if 'binman' in prog or 'patman' in prog else '-t'
     prefix = ''
     if build_dir:
         prefix = 'PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools ' % build_dir
-- 
2.27.0.212.ge8ba1cc988-goog

  parent reply	other threads:[~2020-07-06  3:41 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06  3:41 [RFC PATCH 00/16] RFC: patman: Collect review tags and comments from Patchwork Simon Glass
2020-07-06  3:41 ` [RFC PATCH 01/16] patman: Use test_util to show test results Simon Glass
2020-07-06  4:46   ` Daniel Axtens
2020-07-06  4:50     ` Daniel Axtens
2020-07-06 14:52       ` Simon Glass
2020-07-07  1:09         ` Daniel Axtens
2020-07-08 17:42           ` Stephen Finucane
2020-07-19 20:49           ` Simon Glass
2020-07-06  3:41 ` [RFC PATCH 02/16] patman: Move main code out to a control module Simon Glass
2020-07-06  3:41 ` [RFC PATCH 03/16] patman: Add a test that uses gitpython Simon Glass
2020-07-06  3:41 ` [RFC PATCH 04/16] patman: Allow creating patches for another branch Simon Glass
2020-07-06  3:41 ` [RFC PATCH 05/16] patman: Allow skipping patches at the end Simon Glass
2020-07-06  3:41 ` [RFC PATCH 06/16] patman: Convert to ArgumentParser Simon Glass
2020-07-06  3:41 ` [RFC PATCH 07/16] patman: Allow different commands Simon Glass
2020-07-06  3:41 ` Simon Glass [this message]
2020-07-06  3:41 ` [RFC PATCH 09/16] patman: Allow disabling 'bright' mode with Print output Simon Glass
2020-07-06  3:41 ` [RFC PATCH 10/16] patman: Support collecting response tags in Patchstream Simon Glass
2020-07-06  3:41 ` [RFC PATCH 11/16] patman: Allow linking a series with patchwork Simon Glass
2020-07-06  3:41 ` [RFC PATCH 12/16] patman: Add a -D option to enable debugging Simon Glass
2020-07-06  3:42 ` [RFC PATCH 13/16] patchstream: Support parsing of review snippets Simon Glass
2020-07-06  3:42 ` [RFC PATCH 14/16] patman: Support checking for review tags in patchwork Simon Glass
2020-07-06  3:42 ` [RFC PATCH 15/16] patman: Support updating a branch with review tags Simon Glass
2020-07-06  3:42 ` [RFC PATCH 16/16] patman: Support listing comments from patchwork Simon Glass
2020-07-15  9:10 ` [RFC PATCH 00/16] RFC: patman: Collect review tags and comments from Patchwork Michal Simek
2020-07-19 20:49 ` [RFC PATCH 10/16] patman: Support collecting response tags in Patchstream Simon Glass
2020-07-19 20:49 ` [RFC PATCH 09/16] patman: Allow disabling 'bright' mode with Print output Simon Glass
2020-07-19 20:49 ` [RFC PATCH 08/16] patman: Add a 'test' subcommand Simon Glass
2020-07-19 20:49 ` [RFC PATCH 07/16] patman: Allow different commands Simon Glass
2020-07-19 20:49 ` [RFC PATCH 06/16] patman: Convert to ArgumentParser Simon Glass
2020-07-19 20:49 ` [RFC PATCH 05/16] patman: Allow skipping patches at the end Simon Glass
2020-07-19 20:49 ` [RFC PATCH 04/16] patman: Allow creating patches for another branch Simon Glass
2020-07-19 20:49 ` [RFC PATCH 03/16] patman: Add a test that uses gitpython Simon Glass
2020-07-19 20:49 ` [RFC PATCH 02/16] patman: Move main code out to a control module Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200706034203.2171077-9-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.