# HG changeset patch # User Ludovic Chabant # Date 1439617419 25200 # Node ID b95977d97652331f9ca8c1e3e6d454eac0ac3890 # Parent 9ab005db25922695446959f25c6395028ed04b6f tests: Print more information when a bake test fails to find an output file. diff -r 9ab005db2592 -r b95977d97652 tests/conftest.py --- a/tests/conftest.py Fri Aug 14 21:26:51 2015 -0700 +++ b/tests/conftest.py Fri Aug 14 22:43:39 2015 -0700 @@ -99,8 +99,11 @@ actual = fs.getFileEntry('kitchen/_counter/' + key.lstrip('/')) except Exception as e: + lines = print_fs_tree(fs.path('kitchen/_counter')) raise error_type([ - "Can't access output file %s: %s" % (key, e)]) + "Can't access output file %s: %s" % (key, e), + "Got output directory:"] + + lines) expected = expected_partial_files[key] # HACK because for some reason PyYAML adds a new line for @@ -113,6 +116,21 @@ raise error_type(cmpres) +def print_fs_tree(rootpath): + import os + import os.path + lines = [] + offset = len(rootpath) + for pathname, dirnames, filenames in os.walk(rootpath): + level = pathname[offset:].count(os.sep) + indent = ' ' * 4 * (level) + lines.append(indent + os.path.basename(pathname) + '/') + indent2 = ' ' * 4 * (level + 1) + for f in filenames: + lines.append(indent2 + f) + return lines + + class ChefTestItem(YamlTestItemBase): __initialized_logging__ = False