summaryrefslogtreecommitdiffstats
path: root/meta/lib/patchtest/tests/test_metadata_src_uri.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/patchtest/tests/test_metadata_src_uri.py')
-rw-r--r--meta/lib/patchtest/tests/test_metadata_src_uri.py73
1 files changed, 0 insertions, 73 deletions
diff --git a/meta/lib/patchtest/tests/test_metadata_src_uri.py b/meta/lib/patchtest/tests/test_metadata_src_uri.py
deleted file mode 100644
index 87a24ea937..0000000000
--- a/meta/lib/patchtest/tests/test_metadata_src_uri.py
+++ /dev/null
@@ -1,73 +0,0 @@
1# Checks related to the patch's SRC_URI metadata variable
2#
3# Copyright (C) 2016 Intel Corporation
4#
5# SPDX-License-Identifier: GPL-2.0-only
6
7import base
8import os
9import pyparsing
10from data import PatchTestInput, PatchTestDataStore
11
12class SrcUri(base.Metadata):
13
14 metadata = 'SRC_URI'
15 md5sum = 'md5sum'
16 sha256sum = 'sha256sum'
17 git_regex = pyparsing.Regex('^git\:\/\/.*')
18
19 def setUp(self):
20 # these tests just make sense on patches that can be merged
21 if not PatchTestInput.repo.canbemerged:
22 self.skip('Patch cannot be merged')
23
24 def pretest_src_uri_left_files(self):
25 if not self.modified:
26 self.skip('No modified recipes, skipping pretest')
27
28 # get the proper metadata values
29 for pn in self.modified:
30 # we are not interested in images
31 if 'core-image' in pn:
32 continue
33 rd = self.tinfoil.parse_recipe(pn)
34 PatchTestDataStore['%s-%s-%s' % (self.shortid(), self.metadata, pn)] = rd.getVar(self.metadata)
35
36 def test_src_uri_left_files(self):
37 if not self.modified:
38 self.skip('No modified recipes, skipping pretest')
39
40 # get the proper metadata values
41 for pn in self.modified:
42 # we are not interested in images
43 if 'core-image' in pn:
44 continue
45 rd = self.tinfoil.parse_recipe(pn)
46 PatchTestDataStore['%s-%s-%s' % (self.shortid(), self.metadata, pn)] = rd.getVar(self.metadata)
47
48 for pn in self.modified:
49 pretest_src_uri = PatchTestDataStore['pre%s-%s-%s' % (self.shortid(), self.metadata, pn)].split()
50 test_src_uri = PatchTestDataStore['%s-%s-%s' % (self.shortid(), self.metadata, pn)].split()
51
52 pretest_files = set([os.path.basename(patch) for patch in pretest_src_uri if patch.startswith('file://')])
53 test_files = set([os.path.basename(patch) for patch in test_src_uri if patch.startswith('file://')])
54
55 # check if files were removed
56 if len(test_files) < len(pretest_files):
57
58 # get removals from patchset
59 filesremoved_from_patchset = set()
60 for patch in self.patchset:
61 if patch.is_removed_file:
62 filesremoved_from_patchset.add(os.path.basename(patch.path))
63
64 # get the deleted files from the SRC_URI
65 filesremoved_from_usr_uri = pretest_files - test_files
66
67 # finally, get those patches removed at SRC_URI and not removed from the patchset
68 # TODO: we are not taking into account renames, so test may raise false positives
69 not_removed = filesremoved_from_usr_uri - filesremoved_from_patchset
70 if not_removed:
71 self.fail('Patches not removed from tree. Remove them and amend the submitted mbox',
72 data=[('Patch', f) for f in not_removed])
73