Commit 2a88ad75 authored by Sam Thursfield's avatar Sam Thursfield

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
parent 10cf95ec
......@@ -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"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment