diff mbox series

[1/2] patchtest: sort when reading patches from a directory

Message ID 20231019134054.2524949-1-ross.burton@arm.com
State Accepted, archived
Commit 4d6b586d37ab4528ed6dae6779cd730af9ef09c2
Headers show
Series [1/2] patchtest: sort when reading patches from a directory | expand

Commit Message

Ross Burton Oct. 19, 2023, 1:40 p.m. UTC
From: Ross Burton <ross.burton@arm.com>

When reading patches from a directory it's important to sort the output
of os.listdir(), as that returns the files in an effectively random
order.  We can't test the patches apply if they're applied in the wrong
order, and typically patch filenames are prefixed with a counter to
ensure the order is correct.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 scripts/patchtest | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Trevor Gamblin Oct. 19, 2023, 2:35 p.m. UTC | #1
On 2023-10-19 09:40, Ross Burton wrote:
> From: Ross Burton <ross.burton@arm.com>
>
> When reading patches from a directory it's important to sort the output
> of os.listdir(), as that returns the files in an effectively random
> order.  We can't test the patches apply if they're applied in the wrong
> order, and typically patch filenames are prefixed with a counter to
> ensure the order is correct.
Thanks for the patch. I like this as a general improvement and 
preparation for future fixes, but this might not have the results you're 
expecting (right now) - patchtest currently has a known limitation where 
it only tests patches one-at-a-time, so if you have multiple patches 
depending on previous entries in the series, they will not apply them in 
the sequence and you may get erroneous failures for the merge-on-head 
test. That's on the roadmap for upcoming improvements.
>
> Signed-off-by: Ross Burton <ross.burton@arm.com>
> ---
>   scripts/patchtest | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/patchtest b/scripts/patchtest
> index 642486b8c7f..c47b05b7d47 100755
> --- a/scripts/patchtest
> +++ b/scripts/patchtest
> @@ -172,7 +172,7 @@ def main():
>       patch_list = None
>   
>       if os.path.isdir(patch_path):
> -        patch_list = [os.path.join(patch_path, filename) for filename in os.listdir(patch_path)]
> +        patch_list = [os.path.join(patch_path, filename) for filename in sorted(os.listdir(patch_path))]
>       else:
>           patch_list = [patch_path]
>   
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#189459): https://lists.openembedded.org/g/openembedded-core/message/189459
> Mute This Topic: https://lists.openembedded.org/mt/102060105/7611679
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [tgamblin@baylibre.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/scripts/patchtest b/scripts/patchtest
index 642486b8c7f..c47b05b7d47 100755
--- a/scripts/patchtest
+++ b/scripts/patchtest
@@ -172,7 +172,7 @@  def main():
     patch_list = None
 
     if os.path.isdir(patch_path):
-        patch_list = [os.path.join(patch_path, filename) for filename in os.listdir(patch_path)]
+        patch_list = [os.path.join(patch_path, filename) for filename in sorted(os.listdir(patch_path))]
     else:
         patch_list = [patch_path]