summaryrefslogtreecommitdiff
path: root/tools/patman/func_test.py
AgeCommit message (Collapse)Author
2025-05-27patman: Update status command support cover-letter infoSimon Glass
Add support to the status module for reading and supporting cover letters, including comments. Plumb this through to the patchwork module. The actual support in the latter is not yet integrated. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Move common test code into a new moduleSimon Glass
The func_test file is quite large. In order to allow new tests to be added to a separate file, move the common test code into a separate class, to be inherited by other classes. Drop unnecessary imports in func_test Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Add a test for collecting a PATCH prefixSimon Glass
Add one more test for completeness, since this occurs commonly. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Use python3 with /usr/bin/envSimon Glass
If python2 is available then we must specify python3 here. Update the test to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Add tests for helpSimon Glass
Add a few tests to make sure that help is provided when requested. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Correct some pylint and asyncio issuesSimon Glass
Correct some pylint warnings in this file. Make use of the existing asyncio event loop, instead of creating a new one, since this also destroys it afterwards, making it unavailable for tests which want to share an event loop. Use tools.write_file() to avoid a warning about encoding. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Use git to set up the test configSimon Glass
At present the branch information is dropped when writing the configuration. It is easier to get git to set up the config anyway, so update the test to do this. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Clean up creation of the git treeSimon Glass
The test starts with the HEAD pointing to the wrong place, so that the created files appear to be deleted. Fix this by resetting the tree before tests start. Add a check that the tree is clean. Update pygit2 so that the enums are available.
2025-05-27patman: Use variables for series ID and titleSimon Glass
Rather than hard-coding these values in the sample patches, use variables so that we can refer to these in tests. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Use .git as the git directorySimon Glass
In tests, the 'git' directory is a subdirectory of the temporary directory. Rename it to '.git' so that git will automatically find it when git operations are done in the temporary directory. Set up the config before the first git operation, so that this works correctly. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Use itr instead of lines for iteratorSimon Glass
The variables 'lines' is used to hold a list of output lines within a test, but also to hold an iterator through those lines. Use 'itr' for the latter, to avoid confusion. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27u_boot_pylib: Tidy up quoting of cc and toSimon Glass
The current approach to calling 'git send-email' puts double quotes around each email address to ensure that it will pass the shell correctly. This is a bit cumbersome and requires using a shell to sort it all out. Drop the quotes and use command.run() instead, to simplify things. This will also make it possible to (later) set the current directory. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Update Series.ShowActions() to pass aliasSimon Glass
Instead of using settings.alias pass this value in. This allows tests to work without using settings.alias Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Pass aliases to Series.MakeCcFile()Simon Glass
Rather than accessing settings directly, pass the aliases in, so that we can do the same from tests. With further work this will allow the tests to work without using settings.alias Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Pass the alias dict into gitutil.email_patches()Simon Glass
Rather than accessing the settings module in this function, require the alias dict to be passed in. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Switch over to asyncioSimon Glass
Now that all the pieces are in place, switch over from using an executor to using asyncio. While we are here, import defaultdict to avoid needing to specify its module. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Show patches in yellowSimon Glass
When comments are shown below patches it can be hard to see the patch subject. Use yellow instead of blue, since it stands out better. Pass the colour object into show_responses() rather than creating a new one, since that is tidier. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Simplify test_find_new_responses()Simon Glass
This test uses the find_new_responses() function which combines accessing patchwork and processing the results. Since the test is aimed at testing processing, adjust it to call process_reviews() instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Adjust how the fake request() function is providedSimon Glass
Instead of passing the URL and function to each call, put the fake into the Patchwork object instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Split up check_and_show_status()Simon Glass
This function has three phases: - collecting things from patchwork - doing some processing - showing the results to the user / creating a branch Refactor into two functions so we can eventually have the patchwork part fully separated out. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Rename check_patchwork_status()Simon Glass
This function actually shows the status and does some other things. Rename it to better reflect its purpose. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Move Patch and Review to patchwork moduleSimon Glass
These relate to information obtained from the patchwork server, so move their definition into the new patchwork module. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Move code for sending into its own moduleSimon Glass
The control module includes much of the implementation of patman's 'send' feature. As a first step to separating this out, move the sending code into its own file. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Support extra test featuresSimon Glass
Provide support for the -X flag, which preserves the working directory used by tests. Also support -N which shows captured output for tests. Finally, allow selection of a particular test to run. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Correct a stray quoteSimon Glass
A quote character was added a few years ago, but was not intended. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Move capture_sys_output() into terminal and renameSimon Glass
This function is sometimes useful outside tests. Also it can affect how terminal output is done, e.g. whether ANSI characters should be emitted or not. Move it out of the test_util package and into terminal. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-10patman: Show base commit on each patch when no cover letterSimon Glass
If a series is sent without a cover letter, there is no indication of the base commit. Add support for this, since single patches of small series may not always have a cover letter. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-10patman: Show the base commit and branchSimon Glass
It is helpful to know which commit patches are based on, even if that commit might not be available to readers. Add a tag for this in the cover letter. Also add the local-branch name since that may be useful to the writer. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-17u_boot_pylib: Move gitutil into the librarySimon Glass
Move this file into U-Boot's Python library, so that it is no-longer part of patman. This makes a start on: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/35 Signed-off-by: Simon Glass <sjg@chromium.org>
2024-07-03patman: Add a tag for when a patch gets added to a seriesSean Anderson
When a patch is added to a series after the initial version, there are no changes to note except that it is new. This is typically done to suppress the "(no changes in vN)" message. It's also nice to add a change to the cover letter so reviewers know there is an additional patch. Add a tag to automate this process a bit. There are two nits with the current approach: - It favors '-' as a bullet point, but some people may prefer '*' (or something else) - Tags (e.g. 'patman: ' in 'patman: foo bar') are not stripped. They are probably just noise in most series, but they may be useful for treewide series to distinguish 'gpio: frobnicate' from 'reset: frobnicate', so I've left them in. Suggestions for the above appreciated. Suggested-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Douglas Anderson <dianders@chromium.org>
2024-07-03patman: Add Commit-cc as an alias for Patch-ccSean Anderson
Most tags referring to commits (or patches) are named Commit-something. The exception is Patch-cc. Add a Commit-cc alias so we can use whichever one is convenient. Signed-off-by: Sean Anderson <seanga2@gmail.com>
2024-07-03patman: Fix tests if add_maintainers is set to FalseSean Anderson
If add_maintainers is set to False in the user's ~/.patman config, it will cause the custom_get_maintainer_script to fail since that test expects maintainers to be added. Set add_maintainer to True in the .patman config to prevent this. Fixes: 8c042fb7f9f ("patman: add '--get-maintainer-script' argument") Signed-off-by: Sean Anderson <seanga2@gmail.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-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: 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-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: 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>
2022-03-02patman: Correct pylint errorsSimon Glass
Fix pylint errors that can be fixed and mask those that seem to be incorrect. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Convert camel case in terminal.pySimon Glass
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Convert camel case in gitutil.pySimon Glass
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Convert camel case in func_test.pySimon Glass
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Convert camel case in tools.pySimon Glass
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-10-31patman: Add "postfix" support to patch subjectsSean Anderson
In some communities, it may be necessary to append something after PATCH in the subject line. For example, the Linux networking subsystem expects [1] patch subject prefixes like [RFC PATCH net-next 0/99]. This adds support for such "postfix"s to patman. Although entirely cosmetic, it is still nice to have. [1] https://www.kernel.org/doc/html/latest/networking/netdev-FAQ.html#how-do-i-indicate-which-tree-net-vs-net-next-my-patch-should-be-in Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-08-08patman: Avoid blank lines between tagsSimon Glass
In some cases 'patman status' leaves a blank line between the sign-off and the tags it collects from patchwork. Fix this and add a test. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-08-01patman: add warning for invalid tagPatrick Delaunay
Add a error in patman tool when the commit message contents an invalid tag "Serie-.*" instead of "Series-.*". Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-29patman: Assume we always have pygit2 for testsTom Rini
Given that we have tests that require pygit2 and it can be installed like any other python module, fail much more loudly if it is missing. Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
2021-03-22patman: Quieten down the alias checkingSimon Glass
When a tag is used in a patch subject (e.g. "tag: rest of message") and it cannot be found as an alias, patman currently reports a fatal error, unless -t is provided, in which case it reports a warning. Experience suggest that the fatal error is not very useful. Instead, default to reporting a warning, with -t tell patman to ignore it altogether. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-22patman: Add --no-signoff to suppress adding signoffsPhilipp Tomsich
To enable use of patman with FSF/GNU projects, such as GCC or Binutils, no Signed-off-by may be added. This adds a command line flag '--no-signoff' to suppress adding signoffs in patman when processing commits. Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu> Reviewed-by: Simon Glass <sjg@chromium.org> Fix patman testBranch() test: Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-13patman: Drop unicode helper functionsSimon Glass
We don't need these now that everything uses Python 3. Remove them and the extra code in GetBytes() and ToBytes() too. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-11-14patman: Allow specifying the patchwork URLSimon Glass
Add a new argument to allow the URL of the patchwork server to be speciified. For now this is hard-coded in the main file, but future patches will move it to the settings file. Signed-off-by: Simon Glass <sjg@chromium.org>