Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/pkgsrc/pkgtools/pkglint/files/Attic/autofix_test.go,v rcsdiff: /ftp/cvs/cvsroot/pkgsrc/pkgtools/pkglint/files/Attic/autofix_test.go,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.23 retrieving revision 1.24 diff -u -p -r1.23 -r1.24 --- pkgsrc/pkgtools/pkglint/files/Attic/autofix_test.go 2019/05/21 17:59:48 1.23 +++ pkgsrc/pkgtools/pkglint/files/Attic/autofix_test.go 2019/05/26 14:05:57 1.24 @@ -965,6 +965,54 @@ func (s *Suite) Test_Autofix_Apply__sour "+\ttext again") } +// After fixing part of a line, the whole line needs to be parsed again. +// +// As of May 2019, this is not done yet. +func (s *Suite) Test_Autofix_Apply__text_after_replacing_string(c *check.C) { + t := s.Init(c) + + t.SetUpCommandLine("-Wall", "--autofix") + mkline := t.NewMkLine("filename.mk", 123, "VAR=\tvalue") + + fix := mkline.Autofix() + fix.Notef("Just a demo.") + fix.Replace("value", "new value") + fix.Apply() + + t.CheckOutputLines( + "AUTOFIX: filename.mk:123: Replacing \"value\" with \"new value\".") + + t.Check(mkline.raw[0].textnl, equals, "VAR=\tnew value\n") + t.Check(mkline.raw[0].orignl, equals, "VAR=\tvalue\n") + t.Check(mkline.Text, equals, "VAR=\tnew value") + // FIXME: should be updated as well. + t.Check(mkline.Value(), equals, "value") +} + +// After fixing part of a line, the whole line needs to be parsed again. +// +// As of May 2019, this is not done yet. +func (s *Suite) Test_Autofix_Apply__text_after_replacing_regex(c *check.C) { + t := s.Init(c) + + t.SetUpCommandLine("-Wall", "--autofix") + mkline := t.NewMkLine("filename.mk", 123, "VAR=\tvalue") + + fix := mkline.Autofix() + fix.Notef("Just a demo.") + fix.ReplaceRegex(`va...`, "new value", -1) + fix.Apply() + + t.CheckOutputLines( + "AUTOFIX: filename.mk:123: Replacing \"value\" with \"new value\".") + + t.Check(mkline.raw[0].textnl, equals, "VAR=\tnew value\n") + t.Check(mkline.raw[0].orignl, equals, "VAR=\tvalue\n") + t.Check(mkline.Text, equals, "VAR=\tnew value") + // FIXME: should be updated as well. + t.Check(mkline.Value(), equals, "value") +} + func (s *Suite) Test_Autofix_Realign__wrong_line_type(c *check.C) { t := s.Init(c)