pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files pkgtools/pkglint: update source...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/5a67f20f4b8d
branches:  trunk
changeset: 312026:5a67f20f4b8d
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Tue Aug 21 19:21:41 2018 +0000

description:
pkgtools/pkglint: update source files to latest state

diffstat:

 pkgtools/pkglint/files/line_test.go |  46 +++++++++++++++++++++++++++++++++++++
 pkgtools/pkglint/files/tree.go      |  41 --------------------------------
 pkgtools/pkglint/files/tree_test.go |   7 -----
 3 files changed, 46 insertions(+), 48 deletions(-)

diffs (106 lines):

diff -r 45bebfa795b9 -r 5a67f20f4b8d pkgtools/pkglint/files/line_test.go
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkglint/files/line_test.go       Tue Aug 21 19:21:41 2018 +0000
@@ -0,0 +1,46 @@
+package main
+
+import (
+       "gopkg.in/check.v1"
+)
+
+func (s *Suite) Test_Line_log__gcc_format(c *check.C) {
+       t := s.Init(c)
+
+       t.SetupCommandLine("--gcc-output-format")
+       line := t.NewLine("filename", 123, "text")
+
+       line.Notef("Diagnostics can be logged in GCC-style.")
+
+       t.CheckOutputLines(
+               "filename:123: note: Diagnostics can be logged in GCC-style.")
+}
+
+func (s *Suite) Test_Line_log__print_source(c *check.C) {
+       t := s.Init(c)
+
+       t.SetupCommandLine("--show-autofix", "--source")
+       line := t.NewLine("filename", 123, "text")
+
+       fix := line.Autofix()
+       fix.Notef("Diagnostics can show the differences in autofix mode.")
+       fix.InsertBefore("new line before")
+       fix.InsertAfter("new line after")
+       fix.Apply()
+
+       t.CheckOutputLines(
+               "NOTE: filename:123: Diagnostics can show the differences in autofix mode.",
+               "AUTOFIX: filename:123: Inserting a line \"new line before\" before this line.",
+               "AUTOFIX: filename:123: Inserting a line \"new line after\" after this line.",
+               "+\tnew line before",
+               ">\ttext",
+               "+\tnew line after")
+}
+
+func (s *Suite) Test_RawLine_String(c *check.C) {
+       t := s.Init(c)
+
+       line := t.NewLine("filename", 123, "text")
+
+       c.Check(line.raw[0].String(), equals, "123:text\n")
+}
diff -r 45bebfa795b9 -r 5a67f20f4b8d pkgtools/pkglint/files/tree.go
--- a/pkgtools/pkglint/files/tree.go    Tue Aug 21 17:34:58 2018 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-package main
-
-import (
-       "fmt"
-)
-
-type Tree struct {
-       name string
-       args []interface{}
-}
-
-func NewTree(name string, args ...interface{}) *Tree {
-       return &Tree{name, args}
-}
-
-func (t *Tree) String() string {
-       s := "(" + t.name
-       for _, arg := range t.args {
-               if arg, ok := arg.(*Tree); ok {
-                       s += " " + (*arg).String()
-                       continue
-               }
-               if arg, ok := arg.(string); ok {
-                       s += fmt.Sprintf(" %q", arg)
-                       continue
-               }
-               s += fmt.Sprintf(" %v", arg)
-       }
-       return s + ")"
-}
-
-func (t *Tree) Visit(nodename string, action func(t *Tree)) {
-       if t.name == nodename {
-               action(t)
-       }
-       for _, arg := range t.args {
-               if child, ok := arg.(*Tree); ok {
-                       child.Visit(nodename, action)
-               }
-       }
-}
diff -r 45bebfa795b9 -r 5a67f20f4b8d pkgtools/pkglint/files/tree_test.go
--- a/pkgtools/pkglint/files/tree_test.go       Tue Aug 21 17:34:58 2018 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-package main
-
-import "gopkg.in/check.v1"
-
-func (s *Suite) Test_Tree_String(c *check.C) {
-       c.Check(NewTree("not", NewTree("empty", "varname")).String(), equals, "(not (empty \"varname\"))")
-}



Home | Main Index | Thread Index | Old Index