[tracker-miners/tracker-miners-2.2: 3/47] functional-tests: Show a better error when we can't extract a file



commit f80a302917bd1ed8ad500294a4c6ee520180bcde
Author: Sam Thursfield <sam afuera me uk>
Date:   Sat May 25 13:03:38 2019 +0200

    functional-tests: Show a better error when we can't extract a file
    
    The functional-tests assume that all necessary dependencies are
    installed. If you are missing one, you'll get an error.
    
    Previously the error looked like this:
    
        ======================================================================
        ERROR: nctional-tests/test-extraction-data/images/xmp-loaded-1.expe 
(__main__.GenericExtractionTestCase)
        ----------------------------------------------------------------------
        Traceback (most recent call last):
          File "/home/parallels/newrepos/tracker-miners/tests/functional-tests/common/utils/extractor.py", 
line 73, in get_tracker_extract_jsonld_output
            data = json.loads(output)
          File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
            return _default_decoder.decode(s)
          File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
            obj, end = self.raw_decode(s, idx=_w(s, 0).end())
          File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
            raise JSONDecodeError("Expecting value", s, err.value) from None
        json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
    
        During handling of the above exception, another exception occurred:
    
        Traceback (most recent call last):
          File "./400-extractor-metadata.py", line 85, in generic_test_extraction
            result = get_tracker_extract_jsonld_output(self.file_to_extract)
          File "/home/parallels/newrepos/tracker-miners/tests/functional-tests/common/utils/extractor.py", 
line 76, in get_tracker_extract_jsonld_output
            "Output was: %s" % (e, output))
        RuntimeError: tracker-extract did not return valid JSON data: Expecting value: line 1 column 1 (char 
0)
        Output was:
    
    Now it is a bit clearer:
    
        ======================================================================
        ERROR: nctional-tests/test-extraction-data/images/test-image-1.expe 
(__main__.GenericExtractionTestCase)
        ----------------------------------------------------------------------
        Traceback (most recent call last):
          File "./400-extractor-metadata.py", line 85, in generic_test_extraction
            result = get_tracker_extract_jsonld_output(self.file_to_extract)
          File "/home/sam/src/tracker-miners/tests/functional-tests/common/utils/extractor.py", line 77, in 
get_tracker_extract_jsonld_output
            "Error output was: %s" % error_output)
        RuntimeError: tracker-extract didn't return any data.
        Error output was: 
file:///home/sam/src/tracker-miners/tests/functional-tests/test-extraction-data/images/test-image-1.jpg: No 
metadata or extractor modules found to handle this file

 tests/functional-tests/common/utils/extractor.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/tests/functional-tests/common/utils/extractor.py 
b/tests/functional-tests/common/utils/extractor.py
index 17148b948..e58128fa0 100644
--- a/tests/functional-tests/common/utils/extractor.py
+++ b/tests/functional-tests/common/utils/extractor.py
@@ -66,10 +66,16 @@ def get_tracker_extract_jsonld_output(filename, mime_type=None):
             "Error output:\n%s\n" % (p.returncode, stderr.decode('unicode-escape').strip()))
 
     if len(stderr) > 0:
-        log("Error output from tracker-extract:\n%s" % stderr.decode('unicode-escape').strip())
+        error_output = stderr.decode('unicode-escape').strip()
+        log("Error output from tracker-extract:\n%s" % error_output)
 
     try:
         output = stdout.decode('utf-8')
+
+        if len(output.strip()) == 0:
+            raise RuntimeError("tracker-extract didn't return any data.\n"
+                               "Error output was: %s" % error_output)
+
         data = json.loads(output)
     except ValueError as e:
         raise RuntimeError("tracker-extract did not return valid JSON data: %s\n"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]