aboutsummaryrefslogtreecommitdiff
path: root/tools/patman
AgeCommit message (Collapse)Author
2023-09-23patman: Respect include directive on Git config lookupFei Shao
People may put their user name and email in a local config file and reference it by the include.* directives, however `git config --global` doesn't look up the included configs by default. Enable the --includes option explicitly to support such use cases. Signed-off-by: Fei Shao <fshao@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-09-23tools: Fix patman launcher script.Maxim Cournoyer
There is no "run_patman" procedure in patman's __main__.py file, which would cause the following error at execution: "AttributeError: module 'patman.__main__' has no attribute 'run_patman'" Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-28tools: Fall back to importlib_resources on Python 3.6Jan Kiszka
importlib.resources became part of 3.7 only. Allow using distros with 3.6 and the importlib_resources backport. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-28patman: fix class TestFunctionalHeinrich Schuchardt
Variable orig_dir cannot be used in the finally block if it has not be assigned outside of the try block. tools/patman/func_test.py:523:21: E0601: Using variable 'orig_dir' before assignment (used-before-assignment) tools/patman/func_test.py:691:21: E0601: Using variable 'orig_dir' before assignment (used-before-assignment) Fixes: fd70986a62af ("patman: Add a test that uses gitpython") Fixes: be051c0c7741 ("patman: Detect missing upstream in CountCommitsToBranch") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-23patman: Declare the future Series memorySimon Glass
This member is used in series.MakeCcFile() so should be declared in the Series class. Add a declaration to silence the warning. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08patman: Check patches in parallelSimon Glass
For large series this can take a while. Run checkpatch in parallel to try to reduce the time. The checkpatch information is still reported in sequential order, so a very slow patch at the start can still slow things down. But overall this gives good results. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Douglas Anderson <dianders@chromium.org>
2023-03-08patman: Run get_maintainer.pl in parallelSimon Glass
This script can take ages on some series. Try to limit the time by using threads. If a few stubborn patches remain, show progress so the user has some idea what is going on. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Douglas Anderson <dianders@chromium.org>
2023-03-08patman: Refactor MakeCcFile() into two functionsSimon Glass
This function is quite long. Moving the handling of a commit into a separate function. This will make it easier to do the work in parallel. Update function comments while we are here. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Douglas Anderson <dianders@chromium.org>
2023-03-08patman: Drop an incorrect comment about git amSimon Glass
Patman does not do this anymore, as of this commit: 7428dc14b0f ("patman: Remove the -a option") Drop the comment. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Douglas Anderson <dianders@chromium.org>
2023-03-08doc: Add notes on how to install patman and binmanSimon Glass
These can be installed with 'pip' now. Add the details for those who are interested. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08patman: Add support for building a patman PyPi packageSimon Glass
Create the necessary files to build this new package. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08patman: Avoid importing test_checkpatch before it is neededSimon Glass
Tests are not packaged with patman so this file will not be accessible when installing with pip. Move the import later in the file, when we know the file is present. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08patman: Move library functions into a library directorySimon Glass
The patman directory has a number of modules which are used by other tools in U-Boot. This makes it hard to package the tools using pypi since the common files must be copied along with the tool that uses them. To address this, move these files into a new u_boot_pylib library. This can be packaged separately and listed as a dependency of each tool. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08Remove concurrencytestSimon Glass
While our version is better, it is tricky to use it when we are trying to package things with pip. Drop it. Somewhat reduced functionality is provided by the upstream version[1], along with a rather annoying message each time it is used[2] [3]. [1] pip install concurrencytest [2] https://github.com/cgoldberg/concurrencytest/issues/12 [3] https://github.com/cgoldberg/concurrencytest/pull/14 Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08Revert "patman: test_util: Print test stdout/stderr within test summaries"Simon Glass
Unfortunately this adds a new feature to concurrencytest and it has not made it upstream to the project[1]. Drop it for now so we can use the upstream module. Once it is applied we can bring this functionality back. [1] https://github.com/cgoldberg/concurrencytest This reverts commit ebcaafcded40da8ae6cb4234c2ba9901c7bee644. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-14checkpatch: Add a warning for pre-schema driver model tagsSimon Glass
Help ensure that these don't creep into development by adding a check in checkpatch for them. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18patman: symlink top level .checkpatch.confMaxim Cournoyer
This makes it possible to run the patman test suite simply by invoking 'pytest' from the patman sub-directory: $ cd tools/patman $ pytest Otherwise, the top level .checkpatch.conf would be ignored and multiple test_checkpatch.py tests would fail. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-18Revert "patman: invoke the checkpatch.pl script with '--u-boot' and '--strict'"Maxim Cournoyer
This reverts commit 648d8186dd7f9c444fb07f355090d275dcdd4de4, because it broke usage of patman on Linux, whose check script doesn't know about '--strict' or '--u-boot'. Reported-by: Sjoerd Simons <sjoerd@collabora.com> Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Sjoerd Simons <sjoerd@collabora.com>
2023-01-05patman: add '--get-maintainer-script' argumentMaxim Cournoyer
This makes it possible to configure a project to use some other location or script than the default scripts/get_maintainer.pl one used in the U-Boot and Linux projects. It can be configured via a .patman configuration file and accepts arguments, as documented. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
2023-01-05patman: additionally honor a local .patman config fileMaxim Cournoyer
This enables versioning a project specific patman configuration file. It also makes it possible to declare the project name, which is not a useful thing to do in $HOME/.patman. A new test is added, along updated documentation. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05patman: fail early in Setup when provided config file does not existMaxim Cournoyer
Rationale: if the user explicitly provide this argument, they probably intend for it to be used. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05patman: set the default config_fname argument value to NoneMaxim Cournoyer
This better matches Python conventions, allowing to easily test whether the optional argument is provided. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05patman: import gitutil module where it is neededMaxim Cournoyer
Instead of propagating it from the module entry point (main script). Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05patman: replace deprecated SafeConfigParser with ConfigParserMaxim Cournoyer
The SafeConfigParser class has been renamed in Python 3.2 to ConfigParser, and the old alias has been deprecated since. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05patman: fix pep8 warnings in settings moduleMaxim Cournoyer
Remove extraneous imports, variables and comply to PEP 8 maximum line width, among other PEP 8 changes suggested by Pyflake. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05patman: document default 'send' commandMaxim Cournoyer
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>
2023-01-05patman: document how to run test suite via pytestMaxim Cournoyer
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>
2023-01-05patman: hide the 'test' command unless test data is availableMaxim Cournoyer
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>
2023-01-05patman: add pytest configuration fileMaxim Cournoyer
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>
2023-01-05patman: rename main script to __main__.pyMaxim Cournoyer
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> Fix up main.py in __init__.py: Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-05patman: invoke the checkpatch.pl script with '--u-boot' and '--strict'Maxim Cournoyer
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>
2023-01-05patman: locate test data files via __file__ and pathlibMaxim Cournoyer
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>
2023-01-05patman: cosmetic: Fix PEP 8 warnings for the gitutil module.Maxim Cournoyer
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>
2023-01-05patman: locate README.rst via importlibMaxim Cournoyer
Rationale: this is more robust than assumptions about the file hierarchy layout of the installation of patman, for example on non file-hierarchy standard (FHS) systems such as Guix System or Nix OS. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05patman: fix installation of README.rst data fileMaxim Cournoyer
This fixes a regression introduced in commit 74df491051d6 ("buildman: Convert documentation to rST"). Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05patman: remove extraneous importsMaxim Cournoyer
* tools/patman/main.py: Remove extraneous imports and fix indentation. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05patman: Switch to setuptoolsSean Anderson
distutils is about to meet its demise [1]. Switch to setuptools. [1] https://peps.python.org/pep-0632/ Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-12-23checkpatch.pl: Update CONFIG logic in U-Boot sectionTom Rini
Now that all CONFIG symbols are in Kconfig, checkpatch.pl should check for and error on any case of define/undef CONFIG_*. Signed-off-by: Tom Rini <trini@konsulko.com>
2022-08-26patman: Tidy up unnecessary blank lines and numbersSimon Glass
Quite a few blank lines are not needed here. Drop these and use the # mechanism to number paragraphs. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-26patman: Fix version tableSimon Glass
One of the changes to the version table was made by mistake. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-20patman: Don't buffer test output with a single testSimon Glass
When a single test is run we don't need to buffer the test output. This has the unfortunate side effect of suppressing test output, in particular the binman output directory normally printed with the -X option. This is a huge problem since it blocks debugging of tests. We don't actually know how many tests will be run when we set up the suite, so as a work-around, assume that test_name being specified indicates that there is likely only one. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-20patman: Put the coverage command-line lastSimon Glass
Put this at the end so it is easier to copy it from the terminal. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-13patman: Add documentation to doc/Simon Glass
Link to patman's documentation from the doc/ directory so that it appears in the 'make htmldocs' output. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-07-26patman: By default don't pass "--no-tree" to checkpatch for linuxDouglas Anderson
When you pass "--no-tree" to checkpatch it disables some extra checks that are important for Linux. Specifically I want checks like: warning: DT compatible string "boogie,woogie" appears un-documented check ./Documentation/devicetree/bindings/ Let's make the default for Linux to _not_ pass --no-tree. We'll have a config option and command line flag to override. Signed-off-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-06-28patman: Fix defaults not propagating to subparsersSean Anderson
On python 3.8.10 (and 3.10), subparsers are not updated with defaults. I suspect this is related to [1]. Fix this by explicitly updating subparsers with settings. [1] https://github.com/python/cpython/issues/89398 Fixes: 3145b63513 ("patman: Update defaults in subparsers") Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Tested-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2022-06-28patman: test_util: Print test stdout/stderr within test summariesAlper Nebi Yasak
While running tests for a python tool, the tests' outputs get printed in whatever order they happen to run, without any indication as to which output belongs to which test. Unittest supports capturing these outputs and printing them as part of the test summaries, but when a failure or error occurs it switches back to printing as the tests run. Testtools and subunit tests can do the same as their parts inherit from unittest, but they don't outright expose this functionality. On the unittest side, enable output buffering for the custom test result class. Try to avoid ugly outputs by not printing stdout/stderr before the test summary for low verbosity levels and for successful tests. On the subunit side, implement a custom TestProtocolClient that enables the same underlying functionality and injects the captured streams as additional test details. This causes them to be merged into their test's error traceback message, which is later rebuilt into an exception and passed to our unittest report class. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-06-28patman: test_util: Customize unittest test results for more infoAlper Nebi Yasak
By default, unittest test summaries only print extended info about tests that failed or couldn't run due to an error. Use a custom text result class to print info about more cases: skipped tests, expected failures and unexpected successes. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2022-06-28patman: test_util: Use unittest text runner to print test resultsAlper Nebi Yasak
The python tools' test utilities handle printing test results, but the output is quite bare compared to an ordinary unittest run. Delegate printing the results to a unittest text runner, which gives us niceties like clear separation between each test's result and how long it took to run the test suite. Unfortunately it does not print info for skipped tests by default, but this can be handled later by a custom test result subclass. It also does not print the tool name; manually print a heading that includes the toolname so that the outputs of each tool's tests are distinguishable in the CI output. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-06-28patman: test_util: Handle nonexistent tests while loading testsAlper Nebi Yasak
It's possible to request a specific test to run when trying to run a python tool's tests. If we request a nonexistent test, the unittest loaders generate a fake test that reports this as an error. However, we get these fake tests even when the test exists, because test_util can load tests from multiple places one by one and the test we want only exists in one. The test_util helpers currently remove these fake tests when printing test results, but that's more of a workaround than a proper solution. Instead, don't even try to load the missing tests. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-06-28patman: test_util: Fix printing results for failed testsAlper Nebi Yasak
When printing a python tool's test results, the entire list of failed tests and their tracebacks are reprinted for every failed test. This makes the test output quite unreadable. Fix the loop to print failures and tracebacks one at a time. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>