[yocto] [patchtest-oe][PATCH] test_metadata_src_uri.py: Check if files are added
Amanda Brindle
amanda.r.brindle at intel.com
Fri Apr 27 12:48:34 PDT 2018
Check if files are added to the patchset and not added to the SRC_URI.
This will prevent test_src_uri_left_files from giving a false positive
when patches are renamed in the patchset and not renamed in the SRC_URI.
Also update the fail message from "Patches not removed from tree" to
"Patches not removed from SRC_URI" to be clearer.
[Fixes YOCTO 12636]
Signed-off-by: Amanda Brindle <amanda.r.brindle at intel.com>
---
tests/test_metadata_src_uri.py | 42 +++++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 17 deletions(-)
diff --git a/tests/test_metadata_src_uri.py b/tests/test_metadata_src_uri.py
index a4c5caa..d4d06e2 100644
--- a/tests/test_metadata_src_uri.py
+++ b/tests/test_metadata_src_uri.py
@@ -65,23 +65,31 @@ class SrcUri(base.Metadata):
pretest_files = set([os.path.basename(patch) for patch in pretest_src_uri if patch.startswith('file://')])
test_files = set([os.path.basename(patch) for patch in test_src_uri if patch.startswith('file://')])
- # check if files were removed
- if len(test_files) < len(pretest_files):
+ # check if files were removed or added
+ filesremoved_from_patchset = set()
+ filesadded_to_patchset = set()
+ for patch in self.patchset:
+ if patch.is_removed_file:
+ filesremoved_from_patchset.add(os.path.basename(patch.path))
+ elif patch.is_added_file:
+ filesadded_to_patchset.add(os.path.basename(patch.path))
- # get removals from patchset
- filesremoved_from_patchset = set()
- for patch in self.patchset:
- if patch.is_removed_file:
- filesremoved_from_patchset.add(os.path.basename(patch.path))
+ # get the removed files from the SRC_URI
+ filesremoved_from_usr_uri = pretest_files - test_files
+ # get the patches removed at SRC_URI and not removed from the patchset
+ not_removed = filesremoved_from_usr_uri - filesremoved_from_patchset
+ yeah_removed = filesremoved_from_patchset - filesremoved_from_usr_uri
+ if not_removed:
+ self.fail('Patches not removed from SRC_URI',
+ 'Amend the patch containing the software patch file removal',
+ data=[('Patch', f) for f in not_removed])
- # get the deleted files from the SRC_URI
- filesremoved_from_usr_uri = pretest_files - test_files
-
- # finally, get those patches removed at SRC_URI and not removed from the patchset
- # TODO: we are not taking into account renames, so test may raise false positives
- not_removed = filesremoved_from_usr_uri - filesremoved_from_patchset
- if not_removed:
- self.fail('Patches not removed from tree',
- 'Amend the patch containing the software patch file removal',
- data=[('Patch', f) for f in not_removed])
+ # get the added files from the SRC_URI
+ filesadded_to_usr_uri = test_files - pretest_files
+ # get the patches added to the patchset and not added to the SRC_URI
+ not_added = filesadded_to_patchset - filesadded_to_usr_uri
+ if not_added:
+ self.fail('Patches not added to SRC_URI',
+ 'Amend the patch containing the software patch file addition',
+ data=[('Patch', f) for f in not_added])
--
2.7.4
More information about the yocto
mailing list