diff --git a/__root__/ccs-flatten/flatten.c b/__root__/ccs-flatten/flatten.c index 9e4940f..08eb283 100644 --- a/__root__/ccs-flatten/flatten.c +++ b/__root__/ccs-flatten/flatten.c @@ -150,14 +150,17 @@ flatten(int argc, char **argv) } while (rawmetadata); if (!rulelist) { fprintf(stderr, "No resource rules available\n"); - goto out; + if (rm) + goto out; + else + goto out_print; } load_resources(&reslist, &rulelist); build_resource_tree(&tree, &rulelist, &reslist); if (!tree) { fprintf(stderr, "No resource trees defined; nothing to do\n"); - goto out; + goto out_print; } #ifdef DEBUG fprintf(stderr, "Resources %p tree %p\n", reslist, tree); @@ -195,11 +198,13 @@ flatten(int argc, char **argv) xmlAddChild(rm, new_rb); } + out_print: xmlDocFormatDump(f, d, 1); + + out: if (f != stdout) fclose(f); - out: conf_close(); destroy_resource_tree(&tree); destroy_resources(&reslist); diff --git a/filters/ccs2ccsflat.py b/filters/ccs2ccsflat.py index 3d850ca..3ecf6c2 100644 --- a/filters/ccs2ccsflat.py +++ b/filters/ccs2ccsflat.py @@ -42,14 +42,7 @@ def ccs2ccsflat(flt_ctxt, in_obj): except OSError: raise FilterError(self, "ccs_flatten binary seems unavailable") out, err = proc.communicate() - if proc.returncode != 0: + if proc.returncode != 0 or out == '' and err != '': raise FilterError(self, "ccs_flatten exit code: {0}\n\t{1}", proc.returncode, err) - elif out == '': - # "No resource trees defined; nothing to do" - try: - with file(in_file, 'r') as f: - out = f.read() - except IOError, e: - raise FilterError(self, e.strerror + ": {0}", e.filename) return ('bytestring', out) diff --git a/tests/filter_manager.py b/tests/filter_manager.py index 85f9635..b72af44 100644 --- a/tests/filter_manager.py +++ b/tests/filter_manager.py @@ -11,6 +11,8 @@ from unittest import TestCase from os.path import dirname, join +from lxml.doctestcompare import norm_whitespace + from .format_manager import FormatManager from .format import formats formats = formats.plugins @@ -52,7 +54,7 @@ def test_run_ccs2ccsflat(self): # XXX print result # CHECK the externalized representation matches the original with file(testfile) as f: - self.assertEqual(result, f.read()) + self.assertEqual(norm_whitespace(result), norm_whitespace(f.read())) class CompositeFormatIO(FilterManagerTestCase): @@ -84,11 +86,12 @@ def test_run_double_ccs2ccsflat(self): # externalize outputs results = out_objs(('composite', ('bytestring', 'bytestring'))) # XXX print results - # CHECK resulting externalized reprezentation is, however, tha same - self.assertEqual(*results) + # CHECK resulting externalized representation is, however, tha same + self.assertEqual(*tuple(norm_whitespace for r in results)) # CHECK picked externalized representation matches the original with file(testfile) as f: - self.assertEqual(results[0], f.read()) + self.assertEqual(norm_whitespace(results[0]), + norm_whitespace(f.read())) execfile(op.join(op.dirname(__file__), '_bootstart.py'))