[augeas-devel] augeas: master - * src/syntax.c: print tests results in the same form we read them
David Lutterkort
lutter at fedoraproject.org
Tue Feb 17 16:42:55 UTC 2009
Gitweb: http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=07ffaf070a8e2be452238b80b4431fa5fc88994c
Commit: 07ffaf070a8e2be452238b80b4431fa5fc88994c
Parent: 1b0fd54d9c0a43e9ca0293914cd31477fcfa0968
Author: David Lutterkort <lutter at redhat.com>
AuthorDate: Mon Feb 16 15:05:32 2009 -0800
Committer: David Lutterkort <lutter at redhat.com>
CommitterDate: Mon Feb 16 15:05:32 2009 -0800
* src/syntax.c: print tests results in the same form we read them
---
src/syntax.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/src/syntax.c b/src/syntax.c
index 7ad7480..d639be1 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -1596,6 +1596,25 @@ static struct value *compile_exp(struct info *info,
return v;
}
+static void print_tree(FILE *out, int indent, struct tree *tree) {
+ list_for_each(t, tree) {
+ for (int i=0; i < indent; i++) fputc(' ', out);
+ fprintf(out, "{ ");
+ if (t->label != NULL)
+ fprintf(out, "\"%s\"", t->label);
+ if (t->value != NULL)
+ fprintf(out, " = \"%s\"", t->value);
+ if (t->children != NULL) {
+ fputc('\n', out);
+ print_tree(out, indent + 2, t->children);
+ for (int i=0; i < indent; i++) fputc(' ', out);
+ } else {
+ fputc(' ', out);
+ }
+ fprintf(out, "}\n");
+ }
+}
+
static int compile_test(struct term *term, struct ctx *ctx) {
struct value *actual = compile_exp(term->info, term->test, ctx);
struct value *expect = NULL;
@@ -1634,7 +1653,11 @@ static int compile_test(struct term *term, struct ctx *ctx) {
printf("Test result: ");
print_info(stdout, term->info);
printf("\n");
- print_value(stdout, actual);
+ if (actual->tag == V_TREE) {
+ print_tree(stdout, 2, actual->origin->children);
+ } else {
+ print_value(stdout, actual);
+ }
printf("\n");
}
}
More information about the augeas-devel
mailing list