[yocto] [patchtest-oe][PATCH] test_python_pylint.py: correct filepath passed to pylint

changqing.li at windriver.com changqing.li at windriver.com
Wed Jul 31 02:35:31 PDT 2019


From: Changqing Li <changqing.li at windriver.com>

we cannot get abspath of the added/modified file from info
which is generated by unidiff, we can only get path like:
"scripts/lib/wic/plugins/source/bootimg-biosplusefi.py"

So pylint will responsed as "scripts/lib/wic/plugins/
source/bootimg-biosplusefi.py does not exist"

For modified file:
both pretest and test result have this error, so patchtest
will take as no new error is introduced, so patchtest result
is PASS

For new added file:
since test result have error "... does not exist", and pretest
is empty, so patchtest will FAIL with error "... does not exist"

Fixed by add abspath like ".../openembedded-core/scripts/lib/wic
/plugins/source/bootimg-biosplusefi.py" for the file

[YOCTO #13428]

Signed-off-by: Changqing Li <changqing.li at windriver.com>
---
 tests/test_python_pylint.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/test_python_pylint.py b/tests/test_python_pylint.py
index df6a5de..b6c8d4d 100644
--- a/tests/test_python_pylint.py
+++ b/tests/test_python_pylint.py
@@ -18,6 +18,7 @@
 import base
 import patchtestdata
 import pylint.epylint as lint
+import os
 
 class PyLint(base.Base):
     pythonpatches  = []
@@ -45,7 +46,8 @@ class PyLint(base.Base):
     def pretest_pylint(self):
         for pythonpatch in self.pythonpatches:
             if pythonpatch.is_modified_file:
-                (pylint_stdout, pylint_stderr) = lint.py_run(command_options = pythonpatch.path + self.pylint_options, return_std=True)
+                filepath = os.path.join(os.path.abspath(patchtestdata.PatchTestInput.repodir), pythonpatch.path)
+                (pylint_stdout, pylint_stderr) = lint.py_run(command_options = filepath + self.pylint_options, return_std=True)
                 for line in pylint_stdout.readlines():
                     if not '*' in line:
                         if line.strip():
@@ -59,12 +61,12 @@ class PyLint(base.Base):
                 path = pythonpatch.target_file[2:]
             else:
                 path = pythonpatch.path
-            (pylint_stdout, pylint_stderr) = lint.py_run(command_options = path + self.pylint_options, return_std=True)
+            filepath = os.path.join(os.path.abspath(patchtestdata.PatchTestInput.repodir), path)
+            (pylint_stdout, pylint_stderr) = lint.py_run(command_options = filepath + self.pylint_options, return_std=True)
             for line in pylint_stdout.readlines():
                     if not '*' in line:
                         if line.strip():
                             self.pylint_test[line.strip().split(' ',1)[0]] = line.strip().split(' ',1)[1]
-
         for issue in self.pylint_test:
              if self.pylint_test[issue] not in self.pylint_pretest.values():
                  self.fail('Errors in your Python code were encountered',
-- 
2.7.4



More information about the yocto mailing list