diff --git a/pkg/cmd/debug.go b/pkg/cmd/debug.go index c0d47531..ae592b5b 100644 --- a/pkg/cmd/debug.go +++ b/pkg/cmd/debug.go @@ -106,6 +106,7 @@ func printStats(hirSchema *hir.Schema, hir bool, mir bool, air bool) { for j := 0; j < len(schemas); j++ { row[j+1] = ith.summary(schemas[j]) } + tbl.SetRow(i, row...) } // diff --git a/pkg/cmd/trace.go b/pkg/cmd/trace.go index 89edc9a0..03065cde 100644 --- a/pkg/cmd/trace.go +++ b/pkg/cmd/trace.go @@ -4,7 +4,7 @@ import ( "fmt" "math" "os" - "strings" + "regexp" "github.com/consensys/go-corset/pkg/trace" "github.com/consensys/go-corset/pkg/util" @@ -63,23 +63,30 @@ func init() { traceCmd.Flags().UintP("end", "e", math.MaxUint, "filter out this and all following rows") traceCmd.Flags().Uint("max-width", 32, "specify maximum display width for a column") traceCmd.Flags().StringP("out", "o", "", "Specify output file to write trace") - traceCmd.Flags().StringP("filter", "f", "", "Filter columns beginning with prefix") + traceCmd.Flags().StringP("filter", "f", "", "Filter columns matching regex") } // Construct a new trace containing only those columns from the original who // name begins with the given prefix. -func filterColumns(cols []trace.RawColumn, prefix string) []trace.RawColumn { +func filterColumns(cols []trace.RawColumn, regex string) []trace.RawColumn { + r, err := regexp.Compile(regex) + // Check for error + if err != nil { + panic(err) + } + // ncols := make([]trace.RawColumn, 0) // Now create the columns. for i := 0; i < len(cols); i++ { name := trace.QualifiedColumnName(cols[i].Module, cols[i].Name) - if strings.HasPrefix(name, prefix) { + if r.MatchString(name) { ncols = append(ncols, cols[i]) } } // Done return ncols } + func printTrace(start uint, end uint, max_width uint, cols []trace.RawColumn) { n := uint(len(cols)) height := min(maxHeightColumns(cols), end) - start @@ -119,6 +126,7 @@ func listColumns(tr []trace.RawColumn) { for j := 0; j < len(colSummarisers); j++ { row[j+1] = colSummarisers[j].summary(tr[i]) } + tbl.SetRow(i, row...) } // diff --git a/pkg/test/ir_test.go b/pkg/test/ir_test.go index 4ad18faf..393e2373 100644 --- a/pkg/test/ir_test.go +++ b/pkg/test/ir_test.go @@ -553,14 +553,12 @@ func checkTrace(t *testing.T, inputs []trace.RawColumn, expand bool, id traceId, // Process what happened versus what was supposed to happen. if !accepted && id.expected { //table.PrintTrace(tr) - msg := fmt.Sprintf("Trace rejected incorrectly (%s, %s.accepts, line %d with padding %d): %s", + t.Errorf("Trace rejected incorrectly (%s, %s.accepts, line %d with padding %d): %s", id.ir, id.test, id.line, id.padding, errs) - t.Errorf(msg) } else if accepted && !id.expected { //printTrace(tr) - msg := fmt.Sprintf("Trace accepted incorrectly (%s, %s.rejects, line %d with padding %d)", + t.Errorf("Trace accepted incorrectly (%s, %s.rejects, line %d with padding %d)", id.ir, id.test, id.line, id.padding) - t.Errorf(msg) } } } diff --git a/pkg/trace/array_trace.go b/pkg/trace/array_trace.go index c4d129f7..0313469a 100644 --- a/pkg/trace/array_trace.go +++ b/pkg/trace/array_trace.go @@ -119,9 +119,11 @@ func (p *ArrayTrace) String() string { id.WriteString(jth.String()) } + id.WriteString("}") } } + id.WriteString("}") // return id.String() diff --git a/pkg/trace/json/writer.go b/pkg/trace/json/writer.go index 09382688..df8d9180 100644 --- a/pkg/trace/json/writer.go +++ b/pkg/trace/json/writer.go @@ -37,6 +37,7 @@ func ToJsonString(columns []trace.RawColumn) string { jth := data.Get(j) builder.WriteString(jth.String()) } + builder.WriteString("]") } // diff --git a/pkg/trace/printer.go b/pkg/trace/printer.go index 7848e3d7..0eb9f93c 100644 --- a/pkg/trace/printer.go +++ b/pkg/trace/printer.go @@ -224,6 +224,7 @@ func printHorizontalRule(widths []int) { for i := 0; i < w; i++ { fmt.Print("-") } + fmt.Print("-+") }