[test-oe] test_python_pylint.py: correct filepath passed to pylint

Submitted by changqing.li@windriver.com on July 31, 2019, 9:35 a.m. | Patch ID: 163533

Details

Message ID 1564565731-436468-1-git-send-email-changqing.li@windriver.com
State New
Headers show

Commit Message

changqing.li@windriver.com July 31, 2019, 9:35 a.m.
From: Changqing Li <changqing.li@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@windriver.com>
---
 tests/test_python_pylint.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

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',