From 2d324f247c7a93056b6dd8b61046d98c6da0eb97 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 6 Dec 2013 10:11:13 +0400 Subject: [PATCH] astutil: in test, dump AST before and after on failure R=golang-dev, crawshaw CC=golang-dev https://golang.org/cl/37740043 --- astutil/imports_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/astutil/imports_test.go b/astutil/imports_test.go index 774811cc..279b147c 100644 --- a/astutil/imports_test.go +++ b/astutil/imports_test.go @@ -201,6 +201,8 @@ type T struct { func TestAddImport(t *testing.T) { for _, test := range addTests { file := parse(t, test.name, test.in) + var before bytes.Buffer + ast.Fprint(&before, fset, file, nil) AddNamedImport(file, test.renamedPkg, test.pkg) if got := print(t, test.name, file); got != test.out { if test.broken { @@ -208,6 +210,10 @@ func TestAddImport(t *testing.T) { } else { t.Errorf("%s:\ngot: %s\nwant: %s", test.name, got, test.out) } + var after bytes.Buffer + ast.Fprint(&after, fset, file, nil) + + t.Logf("AST before:\n%s\nAST after:\n%s\n", before.String(), after.String()) } } }