All of lore.kernel.org
 help / color / mirror / Atom feed
* [patchtest][PATCH 1/2] patchtest: Fix printing of exception tracebacks
@ 2019-11-15 13:23 Paul Barker
  2019-11-15 13:23 ` [patchtest][PATCH 2/2] patchtest: Allow tests to import helper modules Paul Barker
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Paul Barker @ 2019-11-15 13:23 UTC (permalink / raw)
  To: yocto

The addError() handler is called outside of an actual exception handler
so sys.exc_info() doesn't actually return an exception. This means that
traceback.print_exc() doesn't know what to print. Instead we need to use
traceback.print_exception() with the err object we've been given.

Signed-off-by: Paul Barker <paul@betafive.co.uk>
---
 patchtest | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/patchtest b/patchtest
index 592f73e..59b19f5 100755
--- a/patchtest
+++ b/patchtest
@@ -101,8 +101,7 @@ def getResult(patch, mergepatch):
 
         def addError(self, test, err):
             self.test_error = True
-            (ty, va, trace) = err
-            logger.error(traceback.print_exc())
+            logger.error(traceback.print_exception(*err))
 
         def addFailure(self, test, err):
             self.test_failure = True
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [patchtest][PATCH 2/2] patchtest: Allow tests to import helper modules
  2019-11-15 13:23 [patchtest][PATCH 1/2] patchtest: Fix printing of exception tracebacks Paul Barker
@ 2019-11-15 13:23 ` Paul Barker
  2019-11-29 16:09 ` [patchtest][PATCH 1/2] patchtest: Fix printing of exception tracebacks Paul Barker
       [not found] ` <15DBAE02AEF74F96.7552@lists.yoctoproject.org>
  2 siblings, 0 replies; 5+ messages in thread
From: Paul Barker @ 2019-11-15 13:23 UTC (permalink / raw)
  To: yocto

When running patchtest locally to figure out what was wrong with my
patch, I saw the similar exceptions for each test module:

    Traceback (most recent call last):
      File "/usr/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
        yield
      File "/usr/lib/python3.6/unittest/case.py", line 605, in run
        testMethod()
      File "/usr/lib/python3.6/unittest/loader.py", line 34, in testFailure
        raise self._exception
    ImportError: Failed to import test module: tests.test_python_pylint
    Traceback (most recent call last):
      File "/usr/lib/python3.6/unittest/loader.py", line 428, in _find_test_path
        module = self._get_module_from_name(name)
      File "/usr/lib/python3.6/unittest/loader.py", line 369, in _get_module_from_name
        __import__(name)
      File "/mnt/build/Projects/Konsulko/patchtest/patchtest-oe/tests/test_python_pylint.py", line 18, in <module>
        import base
    ModuleNotFoundError: No module named 'base'

To fix this the import patch used when loading test modules has been
extended.

Signed-off-by: Paul Barker <paul@betafive.co.uk>
---
 patchtest | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/patchtest b/patchtest
index 59b19f5..a204479 100755
--- a/patchtest
+++ b/patchtest
@@ -138,6 +138,10 @@ def _runner(resultklass, prefix=None):
     if prefix:
         loader.testMethodPrefix = prefix
 
+    # allow tests to import helper modules
+    sys.path.insert(0, pti.startdir)
+    sys.path.insert(0, os.path.join(pti.startdir, 'tests'))
+
     # create the suite with discovered tests and the corresponding runner
     suite = loader.discover(start_dir=pti.startdir, pattern=pti.pattern, top_level_dir=pti.topdir)
     ntc = suite.countTestCases()
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [patchtest][PATCH 1/2] patchtest: Fix printing of exception tracebacks
  2019-11-15 13:23 [patchtest][PATCH 1/2] patchtest: Fix printing of exception tracebacks Paul Barker
  2019-11-15 13:23 ` [patchtest][PATCH 2/2] patchtest: Allow tests to import helper modules Paul Barker
@ 2019-11-29 16:09 ` Paul Barker
       [not found] ` <15DBAE02AEF74F96.7552@lists.yoctoproject.org>
  2 siblings, 0 replies; 5+ messages in thread
From: Paul Barker @ 2019-11-29 16:09 UTC (permalink / raw)
  To: Yocto discussion list

On Fri, 15 Nov 2019, at 13:23, Paul Barker wrote:
> The addError() handler is called outside of an actual exception handler
> so sys.exc_info() doesn't actually return an exception. This means that
> traceback.print_exc() doesn't know what to print. Instead we need to use
> traceback.print_exception() with the err object we've been given.
> 
> Signed-off-by: Paul Barker <paul@betafive.co.uk>
> ---
>  patchtest | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/patchtest b/patchtest
> index 592f73e..59b19f5 100755
> --- a/patchtest
> +++ b/patchtest
> @@ -101,8 +101,7 @@ def getResult(patch, mergepatch):
>  
>          def addError(self, test, err):
>              self.test_error = True
> -            (ty, va, trace) = err
> -            logger.error(traceback.print_exc())
> +            logger.error(traceback.print_exception(*err))
>  
>          def addFailure(self, test, err):
>              self.test_failure = True
> -- 
> 2.17.1
> 
>

Ping on this and the following patch.

-- 
Paul Barker

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [yocto] [patchtest][PATCH 1/2] patchtest: Fix printing of exception tracebacks
       [not found] ` <15DBAE02AEF74F96.7552@lists.yoctoproject.org>
@ 2019-12-05 12:56   ` Paul Barker
  2019-12-05 16:54     ` Leonardo Sandoval
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Barker @ 2019-12-05 12:56 UTC (permalink / raw)
  To: Yocto discussion list; +Cc: Leo Sandoval, Paul Eggleton, Changqing Li

On Fri, 29 Nov 2019, at 16:09, Paul Barker wrote:
> On Fri, 15 Nov 2019, at 13:23, Paul Barker wrote:
> > The addError() handler is called outside of an actual exception handler
> > so sys.exc_info() doesn't actually return an exception. This means that
> > traceback.print_exc() doesn't know what to print. Instead we need to use
> > traceback.print_exception() with the err object we've been given.
> > 
> > Signed-off-by: Paul Barker <paul@betafive.co.uk>
> > ---
> > patchtest | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/patchtest b/patchtest
> > index 592f73e..59b19f5 100755
> > --- a/patchtest
> > +++ b/patchtest
> > @@ -101,8 +101,7 @@ def getResult(patch, mergepatch):
> > 
> > def addError(self, test, err):
> > self.test_error = True
> > - (ty, va, trace) = err
> > - logger.error(traceback.print_exc())
> > + logger.error(traceback.print_exception(*err))
> > 
> > def addFailure(self, test, err):
> > self.test_failure = True
> > -- 
> > 2.17.1
> > 
> >
> 
> Ping on this and the following patch.

Cc'ing the maintainers listed in the readme along with Changqing Li as discussed during the Yocto Project call on Tuesday.

Could you confirm who's maintaining patchtest these days and update the readme? I've got a few ideas for enhancements and I may be able to assist with maintaining these repositories after the new year but I'd like to get these initial changes in first.

-- 
Paul Barker

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [yocto] [patchtest][PATCH 1/2] patchtest: Fix printing of exception tracebacks
  2019-12-05 12:56   ` [yocto] " Paul Barker
@ 2019-12-05 16:54     ` Leonardo Sandoval
  0 siblings, 0 replies; 5+ messages in thread
From: Leonardo Sandoval @ 2019-12-05 16:54 UTC (permalink / raw)
  To: Paul Barker, Yocto discussion list; +Cc: Paul Eggleton, Changqing Li

LGTM

On 12/5/2019 6:56 AM, Paul Barker wrote:
> On Fri, 29 Nov 2019, at 16:09, Paul Barker wrote:
>> On Fri, 15 Nov 2019, at 13:23, Paul Barker wrote:
>>> The addError() handler is called outside of an actual exception handler
>>> so sys.exc_info() doesn't actually return an exception. This means that
>>> traceback.print_exc() doesn't know what to print. Instead we need to use
>>> traceback.print_exception() with the err object we've been given.
>>>
>>> Signed-off-by: Paul Barker <paul@betafive.co.uk>
>>> ---
>>> patchtest | 3 +--
>>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>>
>>> diff --git a/patchtest b/patchtest
>>> index 592f73e..59b19f5 100755
>>> --- a/patchtest
>>> +++ b/patchtest
>>> @@ -101,8 +101,7 @@ def getResult(patch, mergepatch):
>>>
>>> def addError(self, test, err):
>>> self.test_error = True
>>> - (ty, va, trace) = err
>>> - logger.error(traceback.print_exc())
>>> + logger.error(traceback.print_exception(*err))
>>>
>>> def addFailure(self, test, err):
>>> self.test_failure = True
>>> -- 
>>> 2.17.1
>>>
>>>
>> Ping on this and the following patch.
> Cc'ing the maintainers listed in the readme along with Changqing Li as discussed during the Yocto Project call on Tuesday.
>
> Could you confirm who's maintaining patchtest these days and update the readme? I've got a few ideas for enhancements and I may be able to assist with maintaining these repositories after the new year but I'd like to get these initial changes in first.
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-12-05 16:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-15 13:23 [patchtest][PATCH 1/2] patchtest: Fix printing of exception tracebacks Paul Barker
2019-11-15 13:23 ` [patchtest][PATCH 2/2] patchtest: Allow tests to import helper modules Paul Barker
2019-11-29 16:09 ` [patchtest][PATCH 1/2] patchtest: Fix printing of exception tracebacks Paul Barker
     [not found] ` <15DBAE02AEF74F96.7552@lists.yoctoproject.org>
2019-12-05 12:56   ` [yocto] " Paul Barker
2019-12-05 16:54     ` Leonardo Sandoval

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.