1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
|
package pkglint
import "gopkg.in/check.v1"
// VaralignTester reduces the amount of test code for aligning variable
// assignments in Makefiles.
//
// The most interesting breakpoint for looking at these tests is
// VaralignBlock.optimalWidth.
type VaralignTester struct {
suite *Suite
tester *Tester
input []string // The actual input lines
diagnostics []string // The expected diagnostics in default mode
autofixes []string // The expected diagnostics in --autofix mode
fixed []string // The expected fixed lines, with spaces instead of tabs
ShowSource bool // The --show-source command line option
}
func NewVaralignTester(s *Suite, c *check.C) *VaralignTester {
t := s.Init(c)
return &VaralignTester{suite: s, tester: t}
}
// Input remembers the input lines that are checked and possibly realigned.
func (vt *VaralignTester) Input(lines ...string) { vt.input = lines }
// Diagnostics remembers the expected diagnostics.
func (vt *VaralignTester) Diagnostics(diagnostics ...string) { vt.diagnostics = diagnostics }
// Autofixes remembers the expected diagnostics when pkglint is
// run with the --autofix option.
func (vt *VaralignTester) Autofixes(autofixes ...string) { vt.autofixes = autofixes }
// Fixed remembers the expected fixed lines. To make the layout changes
// clearly visible, the lines given here use spaces instead of tabs.
// The fixed lines that have been written to the file are still using tabs.
func (vt *VaralignTester) Fixed(lines ...string) { vt.fixed = lines }
// Run is called after setting up the data and runs the varalign checks twice.
// Once for getting the diagnostics and once for automatically fixing them.
func (vt *VaralignTester) Run() {
vt.run(false)
vt.run(true)
}
func (vt *VaralignTester) run(autofix bool) {
t := vt.tester
cmdline := []string{"-Wall"}
if autofix {
cmdline = append(cmdline, "--autofix")
}
if vt.ShowSource {
cmdline = append(cmdline, "--source")
}
t.SetUpCommandLine(cmdline...)
mklines := t.SetUpFileMkLines("Makefile", vt.input...)
var varalign VaralignBlock
for _, mkline := range mklines.mklines {
varalign.Process(mkline)
}
varalign.Finish()
if autofix {
t.CheckOutput(vt.autofixes)
SaveAutofixChanges(mklines.lines)
t.CheckFileLinesDetab("Makefile", vt.fixed...)
} else {
t.CheckOutput(vt.diagnostics)
}
}
// Generally, the value in variable assignments is aligned
// at the next tab.
func (s *Suite) Test_Varalign__one_var_tab(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"VAR=\tone tab")
vt.Diagnostics()
vt.Autofixes()
vt.Fixed(
"VAR= one tab")
vt.Run()
}
// Having more tabs than necessary is allowed. This can be for aesthetic
// reasons to align this paragraph with the others in the same file.
func (s *Suite) Test_Varalign__one_var_tabs(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"VAR=\t\t\tseveral tabs")
vt.Diagnostics()
vt.Autofixes()
vt.Fixed(
"VAR= several tabs")
vt.Run()
}
// Indentations with a single space are only allowed in some very few
// places, such as continuation lines or very long variable names.
// In a single paragraph of its own, indentation with a single space
// doesn't make sense, therefore it is replaced with a tab.
func (s *Suite) Test_Varalign__one_var_space(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"VAR= indented with one space")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned with tabs, not spaces, to column 9.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \" \" with \"\\t\".")
vt.Fixed(
"VAR= indented with one space")
vt.Run()
}
// While indentation with a single space is allowed in a few cases,
// indentation with several spaces is never allowed and is replaced
// with tabs.
func (s *Suite) Test_Varalign__one_var_spaces(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"VAR= several spaces")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned with tabs, not spaces, to column 9.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \" \" with \"\\t\".")
vt.Fixed(
"VAR= several spaces")
vt.Run()
}
// Inconsistently aligned lines for variables of the same length are
// replaced with tabs, so that they align nicely.
func (s *Suite) Test_Varalign__two_vars__spaces(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"VAR= indented with one space",
"VAR= indented with two spaces")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned with tabs, not spaces, to column 9.",
"NOTE: ~/Makefile:2: This variable value should be aligned with tabs, not spaces, to column 9.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \" \" with \"\\t\".",
"AUTOFIX: ~/Makefile:2: Replacing \" \" with \"\\t\".")
vt.Fixed(
"VAR= indented with one space",
"VAR= indented with two spaces")
vt.Run()
}
// All variables in a block are aligned to the same depth.
func (s *Suite) Test_Varalign__several_vars__spaces(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"GRP_A= value",
"GRP_AA= value",
"GRP_AAA= value",
"GRP_AAAA= value")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned with tabs, not spaces, to column 17.",
"NOTE: ~/Makefile:2: This variable value should be aligned with tabs, not spaces, to column 17.",
"NOTE: ~/Makefile:3: This variable value should be aligned with tabs, not spaces, to column 17.",
"NOTE: ~/Makefile:4: This variable value should be aligned with tabs, not spaces, to column 17.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \" \" with \"\\t\\t\".",
"AUTOFIX: ~/Makefile:2: Replacing \" \" with \"\\t\\t\".",
"AUTOFIX: ~/Makefile:3: Replacing \" \" with \"\\t\".",
"AUTOFIX: ~/Makefile:4: Replacing \" \" with \"\\t\".")
vt.Fixed(
"GRP_A= value",
"GRP_AA= value",
"GRP_AAA= value",
"GRP_AAAA= value")
vt.Run()
}
// Lines that are continued my be indented with a single space
// if the first line of the variable definition has no value.
func (s *Suite) Test_Varalign__continuation(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"VAR= \\",
"\tvalue")
vt.Diagnostics()
vt.Autofixes()
vt.Fixed(
"VAR= \\",
" value")
vt.Run()
}
// To align these two lines, the first line needs one more tab.
// The second line is further to the right but doesn't count as
// an outlier since it is not far enough.
// Adding one more tab to the indentation is generally considered ok.
func (s *Suite) Test_Varalign__short_tab__long_space(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"BLOCK=\tindented with tab",
"BLOCK_LONGVAR= indented with space")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned to column 17.",
"NOTE: ~/Makefile:2: This variable value should be aligned with tabs, not spaces, to column 17.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \"\\t\" with \"\\t\\t\".",
"AUTOFIX: ~/Makefile:2: Replacing \" \" with \"\\t\".")
vt.Fixed(
"BLOCK= indented with tab",
"BLOCK_LONGVAR= indented with space")
vt.Run()
}
// When the indentation differs, the indentation is adjusted to the
// minimum necessary.
func (s *Suite) Test_Varalign__short_long__tab(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"BLOCK=\tshort",
"BLOCK_LONGVAR=\t\t\t\tlong")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned to column 17.",
"NOTE: ~/Makefile:2: This variable value should be aligned to column 17.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \"\\t\" with \"\\t\\t\".",
"AUTOFIX: ~/Makefile:2: Replacing \"\\t\\t\\t\\t\" with \"\\t\".")
vt.Fixed(
"BLOCK= short",
"BLOCK_LONGVAR= long")
vt.Run()
}
// For differing indentation, it doesn't matter whether the indentation
// is done with tabs or with spaces. It is aligned to the minimum
// necessary depth.
func (s *Suite) Test_Varalign__space_and_tab(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"VAR= space",
"VAR=\ttab ${VAR}")
vt.Diagnostics(
"NOTE: ~/Makefile:1: Variable values should be aligned with tabs, not spaces.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \" \" with \"\\t\".")
vt.Fixed(
"VAR= space",
"VAR= tab ${VAR}")
vt.Run()
}
// There must always be a visible space between the assignment operator
// and the value.
func (s *Suite) Test_Varalign__no_space_at_all(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"PKG_FAIL_REASON+=\"Message\"")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned to column 25.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \"\" with \"\\t\".")
vt.Fixed(
"PKG_FAIL_REASON+= \"Message\"")
vt.Run()
}
// Continuation lines without any content on the first line may use
// a space for variable value alignment.
// They are ignored when calculating the preferred alignment depth.
func (s *Suite) Test_Varalign__continuation_lines(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"DISTFILES+=\tvalue",
"DISTFILES+= \\", // The continuation backslash must be aligned.
"\t\t\tvalue", // The value is already aligned.
"DISTFILES+=\t\t\tvalue",
"DISTFILES+= value",
"",
"DISTFILES= \\",
"value")
vt.Diagnostics(
"NOTE: ~/Makefile:2--3: This variable value should be aligned with tabs, not spaces, to column 17.",
"NOTE: ~/Makefile:2--3: This line should be aligned with \"\\t\\t\".",
"NOTE: ~/Makefile:4: This variable value should be aligned to column 17.",
"NOTE: ~/Makefile:5: This variable value should be aligned with tabs, not spaces, to column 17.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:2: Replacing \" \" with \"\\t\".",
"AUTOFIX: ~/Makefile:3: Replacing indentation \"\\t\\t\\t\" with \"\\t\\t\".",
"AUTOFIX: ~/Makefile:4: Replacing \"\\t\\t\\t\" with \"\\t\".",
"AUTOFIX: ~/Makefile:5: Replacing \" \" with \"\\t\".")
vt.Fixed(
"DISTFILES+= value",
"DISTFILES+= \\",
" value",
"DISTFILES+= value",
"DISTFILES+= value",
"",
"DISTFILES= \\",
"value")
vt.Run()
}
// Ensures that a wrong warning introduced in ccb56a5 is not logged.
func (s *Suite) Test_Varalign__aligned_continuation(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"USE_TOOLS+=\t[ awk \\",
"\t\tsed")
vt.Diagnostics()
vt.Autofixes()
vt.Fixed(
"USE_TOOLS+= [ awk \\",
" sed")
vt.Run()
}
// Shell commands in continuation lines are assumed to be already nicely indented.
// This particular example is not, but pkglint cannot decide this as of
// version 5.5.2 (January 2018).
func (s *Suite) Test_Varalign__shell_command(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"USE_BUILTIN.Xfixes=\tyes",
"USE_BUILTIN.Xfixes!=\t\t\t\t\t\t\t\\",
"\tif ${PKG_ADMIN} pmatch ...; then\t\t\t\t\t\\",
"\t\t:; else :; fi")
vt.Diagnostics()
vt.Autofixes()
vt.Fixed(
"USE_BUILTIN.Xfixes= yes",
"USE_BUILTIN.Xfixes!= \\",
" if ${PKG_ADMIN} pmatch ...; then \\",
" :; else :; fi")
vt.Run()
}
// The most common pattern for laying out continuation lines is to have all
// values in the continuation lines, one value per line, all indented to the same depth.
// The depth is either a single tab (see the test below) or aligns with the other
// variables in the paragraph (this test).
func (s *Suite) Test_Varalign__continuation_value_starts_in_second_line(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"WRKSRC=\t${WRKDIR}",
"DISTFILES=\tdistfile-1.0.0.tar.gz",
"SITES.distfile-1.0.0.tar.gz= \\",
"\t\t\t${MASTER_SITES_SOURCEFORGE} \\",
"\t\t\t${MASTER_SITES_GITHUB}")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned to column 17.",
"NOTE: ~/Makefile:3--5: This line should be aligned with \"\\t\\t\".")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \"\\t\" with \"\\t\\t\".",
"AUTOFIX: ~/Makefile:4: Replacing indentation \"\\t\\t\\t\" with \"\\t\\t\".",
"AUTOFIX: ~/Makefile:5: Replacing indentation \"\\t\\t\\t\" with \"\\t\\t\".")
vt.Fixed(
"WRKSRC= ${WRKDIR}",
"DISTFILES= distfile-1.0.0.tar.gz",
"SITES.distfile-1.0.0.tar.gz= \\",
" ${MASTER_SITES_SOURCEFORGE} \\",
" ${MASTER_SITES_GITHUB}")
vt.Run()
}
// The most common pattern for laying out continuation lines is to have all
// values in the continuation lines, one value per line, all indented to the same depth.
// The depth is either a single tab (this test) or aligns with the other
// variables in the paragraph (see the test above).
func (s *Suite) Test_Varalign__continuation_value_starts_in_second_line_with_single_tab(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"WRKSRC=\t${WRKDIR}",
"DISTFILES=\tdistfile-1.0.0.tar.gz",
"SITES.distfile-1.0.0.tar.gz= \\",
"\t${MASTER_SITES_SOURCEFORGE} \\",
"\t${MASTER_SITES_GITHUB}")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned to column 17.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \"\\t\" with \"\\t\\t\".")
vt.Fixed(
"WRKSRC= ${WRKDIR}",
"DISTFILES= distfile-1.0.0.tar.gz",
"SITES.distfile-1.0.0.tar.gz= \\",
" ${MASTER_SITES_SOURCEFORGE} \\",
" ${MASTER_SITES_GITHUB}")
vt.Run()
}
// Another common pattern is to write the first value in the first line and
// subsequent values indented to the same depth as the value in the first
// line.
func (s *Suite) Test_Varalign__continuation_value_starts_in_first_line(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"WRKSRC=\t${WRKDIR}",
"DISTFILES=\tdistfile-1.0.0.tar.gz",
"SITES.distfile-1.0.0.tar.gz=\t${MASTER_SITES_SOURCEFORGE} \\",
"\t\t\t\t${MASTER_SITES_GITHUB}")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned to column 17.",
"NOTE: ~/Makefile:3--4: This line should be aligned with \"\\t\\t\".")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \"\\t\" with \"\\t\\t\".",
"AUTOFIX: ~/Makefile:4: Replacing indentation \"\\t\\t\\t\\t\" with \"\\t\\t\".")
vt.Fixed(
"WRKSRC= ${WRKDIR}",
"DISTFILES= distfile-1.0.0.tar.gz",
"SITES.distfile-1.0.0.tar.gz= ${MASTER_SITES_SOURCEFORGE} \\",
" ${MASTER_SITES_GITHUB}")
vt.Run()
}
// Continued lines that have mixed indentation are probably on purpose.
// Their minimum indentation should be aligned to the indentation of the
// other lines. The lines that are indented further should keep their
// relative indentation depth, no matter if that is done with spaces or
// with tabs.
func (s *Suite) Test_Varalign__continuation_mixed_indentation_in_second_line(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"WRKSRC=\t${WRKDIR}",
"DISTFILES=\tdistfile-1.0.0.tar.gz",
"AWK_PROGRAM+= \\",
"\t\t\t\t /search/ { \\",
"\t\t\t\t action(); \\",
"\t\t\t\t }")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned to column 17.",
"NOTE: ~/Makefile:3--6: This variable value should be aligned with tabs, not spaces, to column 17.",
"NOTE: ~/Makefile:3--6: This line should be aligned with \"\\t\\t\".")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \"\\t\" with \"\\t\\t\".",
"AUTOFIX: ~/Makefile:3: Replacing \" \" with \"\\t\".",
"AUTOFIX: ~/Makefile:4: Replacing indentation \"\\t\\t\\t\\t \" with \"\\t\\t\".",
"AUTOFIX: ~/Makefile:5: Replacing indentation \"\\t\\t\\t\\t \" with \"\\t\\t \".",
"AUTOFIX: ~/Makefile:6: Replacing indentation \"\\t\\t\\t\\t \" with \"\\t\\t\".")
vt.Fixed(
"WRKSRC= ${WRKDIR}",
"DISTFILES= distfile-1.0.0.tar.gz",
"AWK_PROGRAM+= \\",
" /search/ { \\",
" action(); \\",
" }")
vt.Run()
}
// Continuation lines may also start their values in the first line.
func (s *Suite) Test_Varalign__continuation_mixed_indentation_in_first_line(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"WRKSRC=\t${WRKDIR}",
"DISTFILES=\tdistfile-1.0.0.tar.gz",
"AWK_PROGRAM+=\t\t\t /search/ { \\",
"\t\t\t\t action(); \\",
"\t\t\t\t }")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned to column 17.",
"NOTE: ~/Makefile:3--5: This variable value should be aligned with tabs, not spaces, to column 17.",
"NOTE: ~/Makefile:3--5: This line should be aligned with \"\\t\\t\".")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \"\\t\" with \"\\t\\t\".",
"AUTOFIX: ~/Makefile:3: Replacing \"\\t\\t\\t \" with \"\\t\".",
"AUTOFIX: ~/Makefile:4: Replacing indentation \"\\t\\t\\t\\t \" with \"\\t\\t \".",
"AUTOFIX: ~/Makefile:5: Replacing indentation \"\\t\\t\\t\\t \" with \"\\t\\t\".")
vt.Fixed(
"WRKSRC= ${WRKDIR}",
"DISTFILES= distfile-1.0.0.tar.gz",
"AWK_PROGRAM+= /search/ { \\",
" action(); \\",
" }")
vt.Run()
}
// When there is an outlier, no matter whether indented using space or tab,
// fix the whole block to use the indentation of the second-longest line.
// In this case, all of the remaining lines have the same indentation (there is only 1 line at all).
// Therefore this existing indentation is used instead of the minimum necessary, which would only be a single tab.
func (s *Suite) Test_Varalign__tab_outlier(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"DISTFILES=\t\tvery-very-very-very-long-distfile-name",
"SITES.very-very-very-very-long-distfile-name=\t${MASTER_SITE_LOCAL}")
vt.Diagnostics()
vt.Autofixes()
vt.Fixed(
"DISTFILES= very-very-very-very-long-distfile-name",
"SITES.very-very-very-very-long-distfile-name= ${MASTER_SITE_LOCAL}")
vt.Run()
}
// The SITES.* definition is indented less than the other lines,
// therefore the whole paragraph will be realigned to that depth.
func (s *Suite) Test_Varalign__multiline(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"DIST_SUBDIR= asc",
"DISTFILES= ${DISTNAME}${EXTRACT_SUFX} frontiers.mp3 \\",
" machine_wars.mp3 time_to_strike.mp3",
".for file in frontiers.mp3 machine_wars.mp3 time_to_strike.mp3",
"SITES.${file}= http://asc-hq.org/",
".endfor",
"WRKSRC= ${WRKDIR}/${PKGNAME_NOREV}")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned with tabs, not spaces, to column 17.",
"NOTE: ~/Makefile:2--3: This variable value should be aligned with tabs, not spaces, to column 17.",
"NOTE: ~/Makefile:2--3: This line should be aligned with \"\\t\\t\".",
"NOTE: ~/Makefile:5: Variable values should be aligned with tabs, not spaces.",
"NOTE: ~/Makefile:7: This variable value should be aligned with tabs, not spaces, to column 17.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \" \" with \"\\t\".",
"AUTOFIX: ~/Makefile:2: Replacing \" \" with \"\\t\".",
"AUTOFIX: ~/Makefile:3: Replacing indentation \" \" with \"\\t\\t\".",
"AUTOFIX: ~/Makefile:5: Replacing \" \" with \"\\t\".",
"AUTOFIX: ~/Makefile:7: Replacing \" \" with \"\\t\\t\".")
vt.Fixed(
"DIST_SUBDIR= asc",
"DISTFILES= ${DISTNAME}${EXTRACT_SUFX} frontiers.mp3 \\",
" machine_wars.mp3 time_to_strike.mp3",
".for file in frontiers.mp3 machine_wars.mp3 time_to_strike.mp3",
"SITES.${file}= http://asc-hq.org/",
".endfor",
"WRKSRC= ${WRKDIR}/${PKGNAME_NOREV}")
vt.Run()
}
// The CDROM variables align exactly at a tab position, therefore they must
// be indented by at least one more space. Since that one space is not
// enough to count as an outlier, everything is indented by one more tab.
func (s *Suite) Test_Varalign__single_space(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"RESTRICTED=\tDo not sell, do not rent",
"NO_BIN_ON_CDROM= ${RESTRICTED}",
"NO_BIN_ON_FTP=\t${RESTRICTED}",
"NO_SRC_ON_CDROM= ${RESTRICTED}",
"NO_SRC_ON_FTP=\t${RESTRICTED}")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned to column 25.",
"NOTE: ~/Makefile:2: This variable value should be aligned with tabs, not spaces, to column 25.",
"NOTE: ~/Makefile:3: This variable value should be aligned to column 25.",
"NOTE: ~/Makefile:4: This variable value should be aligned with tabs, not spaces, to column 25.",
"NOTE: ~/Makefile:5: This variable value should be aligned to column 25.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \"\\t\" with \"\\t\\t\".",
"AUTOFIX: ~/Makefile:2: Replacing \" \" with \"\\t\".",
"AUTOFIX: ~/Makefile:3: Replacing \"\\t\" with \"\\t\\t\".",
"AUTOFIX: ~/Makefile:4: Replacing \" \" with \"\\t\".",
"AUTOFIX: ~/Makefile:5: Replacing \"\\t\" with \"\\t\\t\".")
vt.Fixed(
"RESTRICTED= Do not sell, do not rent",
"NO_BIN_ON_CDROM= ${RESTRICTED}",
"NO_BIN_ON_FTP= ${RESTRICTED}",
"NO_SRC_ON_CDROM= ${RESTRICTED}",
"NO_SRC_ON_FTP= ${RESTRICTED}")
vt.Run()
}
// These variables all look nicely aligned, but they use spaces instead of tabs for alignment.
// The spaces are replaced with tabs, which makes the indentation 4 spaces deeper in the first paragraph.
// In the second paragraph it's even 7 additional spaces.
// This is ok though since it is the prevailing indentation style in pkgsrc.
func (s *Suite) Test_Varalign__only_space(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"DISTFILES+= space",
"DISTFILES+= space",
"",
"REPLACE_PYTHON+= *.py",
"REPLACE_PYTHON+= lib/*.py",
"REPLACE_PYTHON+= src/*.py")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned with tabs, not spaces, to column 17.",
"NOTE: ~/Makefile:2: This variable value should be aligned with tabs, not spaces, to column 17.",
"NOTE: ~/Makefile:4: This variable value should be aligned with tabs, not spaces, to column 25.",
"NOTE: ~/Makefile:5: This variable value should be aligned with tabs, not spaces, to column 25.",
"NOTE: ~/Makefile:6: This variable value should be aligned with tabs, not spaces, to column 25.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \" \" with \"\\t\".",
"AUTOFIX: ~/Makefile:2: Replacing \" \" with \"\\t\".",
"AUTOFIX: ~/Makefile:4: Replacing \" \" with \"\\t\".",
"AUTOFIX: ~/Makefile:5: Replacing \" \" with \"\\t\".",
"AUTOFIX: ~/Makefile:6: Replacing \" \" with \"\\t\".")
vt.Fixed(
"DISTFILES+= space",
"DISTFILES+= space",
"",
"REPLACE_PYTHON+= *.py",
"REPLACE_PYTHON+= lib/*.py",
"REPLACE_PYTHON+= src/*.py")
vt.Run()
}
// The indentation is deeper than necessary, but all lines agree on the same column.
// Therefore this indentation depth is kept. It looks good and is probably due to
// some other paragraphs in the file that are indented equally deep.
//
// As of December 2018, pkglint only looks at a single paragraph at a time,
// therefore it cannot reliably decide whether this deep indentation is necessary.
func (s *Suite) Test_Varalign__mixed_tabs_and_spaces_same_column(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"DISTFILES+= space",
"DISTFILES+=\t\ttab")
vt.Diagnostics(
"NOTE: ~/Makefile:1: Variable values should be aligned with tabs, not spaces.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \" \" with \"\\t\\t\".")
vt.Fixed(
"DISTFILES+= space",
"DISTFILES+= tab")
vt.Run()
}
// Both lines are indented to the same column. Therefore none of them is considered an outlier.
func (s *Suite) Test_Varalign__outlier_1(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"V= value",
"V=\tvalue")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned with tabs, not spaces, to column 9.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \" \" with \"\\t\".")
vt.Fixed(
"V= value",
"V= value")
vt.Run()
}
// A single space that ends at the same depth as a tab is replaced with a tab, for consistency.
func (s *Suite) Test_Varalign__outlier_2(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"V.0008= value",
"V=\tvalue")
vt.Diagnostics(
"NOTE: ~/Makefile:1: Variable values should be aligned with tabs, not spaces.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \" \" with \"\\t\".")
vt.Fixed(
"V.0008= value",
"V= value")
vt.Run()
}
// A short line that is indented with spaces is aligned to a longer line
// that is indented with tabs. This is because space-indented lines are
// only allowed when their indentation is much deeper than the tab-indented
// ones (so-called outliers), or as the first line of a continuation line.
func (s *Suite) Test_Varalign__outlier_3(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"V.00009= value",
"V=\tvalue")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned with tabs, not spaces, to column 17.",
"NOTE: ~/Makefile:2: This variable value should be aligned to column 17.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \" \" with \"\\t\".",
"AUTOFIX: ~/Makefile:2: Replacing \"\\t\" with \"\\t\\t\".")
vt.Fixed(
"V.00009= value",
"V= value")
vt.Run()
}
// This space-indented line doesn't count as an outlier yet because it
// is only a single tab away. The limit is two tabs.
// Therefore both lines are indented with tabs.
func (s *Suite) Test_Varalign__outlier_4(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"V.000000000016= value",
"V=\tvalue")
vt.Diagnostics(
"NOTE: ~/Makefile:1: Variable values should be aligned with tabs, not spaces.",
"NOTE: ~/Makefile:2: This variable value should be aligned to column 17.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \" \" with \"\\t\".",
"AUTOFIX: ~/Makefile:2: Replacing \"\\t\" with \"\\t\\t\".")
vt.Fixed(
"V.000000000016= value",
"V= value")
vt.Run()
}
// This space-indented line is an outlier since it is far enough from the
// tab-indented line. The latter would require 2 tabs to align to the former.
// Therefore the short line is not indented to the long line, in order to
// keep the indentation reasonably short for a large amount of the lines.
func (s *Suite) Test_Varalign__outlier_5(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"V.0000000000017= value",
"V=\tvalue")
vt.Diagnostics()
vt.Autofixes()
vt.Fixed(
"V.0000000000017= value",
"V= value")
vt.Run()
}
// Short space-indented lines do not count as outliers. They are are aligned to the longer tab-indented line.
func (s *Suite) Test_Varalign__outlier_6(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"V= value",
"V.000010=\tvalue")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned with tabs, not spaces, to column 17.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \" \" with \"\\t\\t\".")
vt.Fixed(
"V= value",
"V.000010= value")
vt.Run()
}
// The long line is not an outlier but very close. One more space, and it would count.
func (s *Suite) Test_Varalign__outlier_10(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"V.0000000000000000023= value", // Adjust from 23 to 24 (+ 1 tab)
"V.000010=\tvalue") // Adjust from 16 to 24 (+ 1 tab)
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned with tabs, not spaces, to column 25.",
"NOTE: ~/Makefile:2: This variable value should be aligned to column 25.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \" \" with \"\\t\".",
"AUTOFIX: ~/Makefile:2: Replacing \"\\t\" with \"\\t\\t\".")
vt.Fixed(
"V.0000000000000000023= value",
"V.000010= value")
vt.Run()
}
func (s *Suite) Test_Varalign__outlier_11(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"V.00000000000000000024= value", // Keep at 24 (space to tab)
"V.000010=\tvalue") // Adjust from 16 to 24 (+ 1 tab)
vt.Diagnostics(
"NOTE: ~/Makefile:1: Variable values should be aligned with tabs, not spaces.",
"NOTE: ~/Makefile:2: This variable value should be aligned to column 25.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \" \" with \"\\t\".",
"AUTOFIX: ~/Makefile:2: Replacing \"\\t\" with \"\\t\\t\".")
vt.Fixed(
"V.00000000000000000024= value",
"V.000010= value")
vt.Run()
}
func (s *Suite) Test_Varalign__outlier_12(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"V.000000000000000000025= value", // Keep at 25 (outlier)
"V.000010=\tvalue") // Keep at 16 (would require + 2 tabs)
vt.Diagnostics()
vt.Autofixes()
vt.Fixed(
"V.000000000000000000025= value",
"V.000010= value")
vt.Run()
}
// When the lines are indented inconsistently, the indentation is reduced
// to the required minimum.
func (s *Suite) Test_Varalign__outlier_14(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"V.00008=\t\tvalue", // Adjust from 24 to 16 (removes 1 tab)
"V.00008=\t\t\t\tvalue") // Adjust from 40 to 16 (removes 3 tabs)
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned to column 17.",
"NOTE: ~/Makefile:2: This variable value should be aligned to column 17.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \"\\t\\t\" with \"\\t\".",
"AUTOFIX: ~/Makefile:2: Replacing \"\\t\\t\\t\\t\" with \"\\t\".")
vt.Fixed(
"V.00008= value",
"V.00008= value")
vt.Run()
}
// The INSTALLATION_DIRS line is so long that it is considered an outlier,
// since compared to the DIST line, it is at least two tabs away.
// Pkglint before 2018-26-01 suggested that it "should be aligned to column 9",
// which is not possible since the variable name is already longer.
func (s *Suite) Test_Varalign__long_short(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"INSTALLATION_DIRS=\tbin",
"DIST=\t${WRKSRC}/dist")
vt.Diagnostics()
vt.Autofixes()
vt.Fixed(
"INSTALLATION_DIRS= bin",
"DIST= ${WRKSRC}/dist")
vt.Run()
}
// Before 2018-01-26, pkglint wanted to replace the tab in the outlier with
// a space. After this change, the space-indented line would not look like an
// outlier anymore because the other values are aligned very close to the
// outlier value. To fix this case, the indentation of the other lines needs
// to be adjusted to the minimum required.
func (s *Suite) Test_Varalign__tabbed_outlier(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
".if !empty(PKG_OPTIONS:Minspircd-sqloper)",
"INSPIRCD_STORAGE_DRIVER?=\tmysql",
"MODULES+=\t\tm_sqloper.cpp m_sqlutils.cpp",
"HEADERS+=\t\tm_sqlutils.h",
".endif")
vt.Diagnostics()
vt.Autofixes()
vt.Fixed(
".if !empty(PKG_OPTIONS:Minspircd-sqloper)",
"INSPIRCD_STORAGE_DRIVER?= mysql",
"MODULES+= m_sqloper.cpp m_sqlutils.cpp",
"HEADERS+= m_sqlutils.h",
".endif")
vt.Run()
}
// When all continuation lines are indented exactly one tab more than the
// initial line, this is intentional.
func (s *Suite) Test_Varalign__indented_continuation_line(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"CONF_FILES_PERMS=\tsource \\",
"\t\t\t\tdestination \\",
"\t\t\t\tuser group 0644")
vt.Diagnostics()
vt.Autofixes()
vt.Fixed(
"CONF_FILES_PERMS= source \\",
" destination \\",
" user group 0644")
vt.Run()
}
func (s *Suite) Test_Varalign__indented_continuation_line_in_paragraph(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"SUBST_CLASSES+=\t\tfix",
"SUBST_STAGE.fix=\tpost-patch",
"SUBST_SED.fix= \\",
"\t-e 's,1,one,g' \\",
"\t-e 's,2,two,g' \\",
"\t-e 's,3,three,g'")
vt.Diagnostics(
"NOTE: ~/Makefile:3--6: This variable value should be aligned with tabs, not spaces, to column 25.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:3: Replacing \" \" with \"\\t\\t\".")
vt.Fixed(
"SUBST_CLASSES+= fix",
"SUBST_STAGE.fix= post-patch",
"SUBST_SED.fix= \\",
" -e 's,1,one,g' \\",
" -e 's,2,two,g' \\",
" -e 's,3,three,g'")
vt.Run()
}
// Up to 2018-01-27, it could happen that some source code was logged
// without a corresponding diagnostic. This was unintended and confusing.
func (s *Suite) Test_Varalign__fix_without_diagnostic(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"MESSAGE_SUBST+=\t\tRUBY_DISTNAME=${RUBY_DISTNAME}",
"PLIST_SUBST+=\t\tRUBY_SHLIBVER=${RUBY_SHLIBVER:Q} \\",
"\t\t\tRUBY_SHLIBMAJOR=${RUBY_SHLIBMAJOR:Q} \\",
"\t\t\tRUBY_NOSHLIBMAJOR=${RUBY_NOSHLIBMAJOR} \\",
"\t\t\tRUBY_NAME=${RUBY_NAME:Q}")
vt.Diagnostics()
vt.Autofixes()
vt.Fixed(
"MESSAGE_SUBST+= RUBY_DISTNAME=${RUBY_DISTNAME}",
"PLIST_SUBST+= RUBY_SHLIBVER=${RUBY_SHLIBVER:Q} \\",
" RUBY_SHLIBMAJOR=${RUBY_SHLIBMAJOR:Q} \\",
" RUBY_NOSHLIBMAJOR=${RUBY_NOSHLIBMAJOR} \\",
" RUBY_NAME=${RUBY_NAME:Q}")
vt.ShowSource = true
vt.Run()
}
// The two variables look like they were in two separate paragraphs, but
// they aren't. This is because the continuation line from the DISTFILES
// eats up the empty line that would otherwise separate the paragraphs.
func (s *Suite) Test_Varalign__continuation_line_last_empty(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"DISTFILES= \\",
"\ta \\",
"\tb \\",
"\tc \\",
"",
"NEXT_VAR=\tsecond line")
vt.Diagnostics(
"NOTE: ~/Makefile:1--5: This variable value should be aligned with tabs, not spaces, to column 17.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \" \" with \"\\t\".")
vt.Fixed(
"DISTFILES= \\",
" a \\",
" b \\",
" c \\",
"",
"NEXT_VAR= second line")
vt.Run()
}
// Commented-out variables take part in the realignment.
// The TZ=UTC below is part of the two-line comment since make(1) interprets it in the same way.
//
// This is one of the few cases where commented variable assignments are treated specially.
// See MkLine.IsCommentedVarassign.
func (s *Suite) Test_Varalign__realign_commented_single_lines(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"SHORT=\tvalue",
"#DISTFILES=\tdistfile-1.0.0.tar.gz",
"#CONTINUATION= \\",
"#\t\tcontinued",
"#CONFIGURE_ENV+= \\",
"#TZ=UTC",
"SHORT=\tvalue")
vt.Diagnostics(
"NOTE: ~/Makefile:1: This variable value should be aligned to column 17.",
"NOTE: ~/Makefile:5--6: This line should be aligned with \"\\t\\t\".",
"NOTE: ~/Makefile:7: This variable value should be aligned to column 17.")
vt.Autofixes(
"AUTOFIX: ~/Makefile:1: Replacing \"\\t\" with \"\\t\\t\".",
"AUTOFIX: ~/Makefile:6: Replacing indentation \"\" with \"\\t\\t\".",
"AUTOFIX: ~/Makefile:7: Replacing \"\\t\" with \"\\t\\t\".")
vt.Fixed(
"SHORT= value",
"#DISTFILES= distfile-1.0.0.tar.gz",
"#CONTINUATION= \\",
"# continued",
"#CONFIGURE_ENV+= \\",
"# TZ=UTC",
"SHORT= value")
vt.Run()
}
// Commented variable assignments are realigned, too.
// In this case, the BEFORE and COMMENTED variables are already aligned properly.
// The line starting with "AFTER" is actually part of the comment, therefore it is not changed.
func (s *Suite) Test_Varalign__realign_commented_continuation_line(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"BEFORE=\tvalue",
"#COMMENTED= \\",
"#\tvalue1 \\",
"#\tvalue2 \\",
"#\tvalue3 \\",
"AFTER=\tafter")
vt.Diagnostics()
vt.Autofixes()
vt.Fixed(
"BEFORE= value",
"#COMMENTED= \\",
"# value1 \\",
"# value2 \\",
"# value3 \\",
"AFTER= after")
vt.Run()
}
// The HOMEPAGE is completely ignored. Since its value is empty it doesn't
// need any alignment. Whether it is commented out doesn't matter.
//
// If the HOMEPAGE were taken into account, the alignment would differ and
// the COMMENT line would be realigned to column 17, reducing the indentation by one tab.
func (s *Suite) Test_Varalign__realign_variable_without_value(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"COMMENT=\t\tShort description of the package",
"#HOMEPAGE=")
vt.Diagnostics()
vt.Autofixes()
vt.Fixed(
"COMMENT= Short description of the package",
"#HOMEPAGE=")
vt.Run()
}
// This commented multiline variable is already perfectly aligned.
// Nothing needs to be fixed.
// This is a simple case since a paragraph containing only one line
// is always aligned properly, except when the indentation uses spaces instead of tabs.
func (s *Suite) Test_Varalign__realign_commented_multiline(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"#CONF_FILES+=\t\tfile1 \\",
"#\t\t\tfile2")
vt.Diagnostics()
vt.Autofixes()
vt.Fixed(
"#CONF_FILES+= file1 \\",
"# file2")
vt.Run()
}
// The VAR2 line is a continuation line that starts in column 9, just like
// the VAR1 line. Therefore the alignment is correct.
//
// Its continuation line is indented using effectively tab-tab-space, and
// this relative indentation compared to the VAR2 line is preserved since
// it is often used for indenting AWK or shell programs.
func (s *Suite) Test_Varalign__mixed_indentation(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"VAR1=\tvalue1",
"VAR2=\tvalue2 \\",
" \t \t value2 continued")
vt.Diagnostics()
vt.Autofixes()
vt.Fixed(
"VAR1= value1",
"VAR2= value2 \\",
" value2 continued")
vt.Run()
}
func (s *Suite) Test_Varalign__eol_comment(c *check.C) {
vt := NewVaralignTester(s, c)
vt.Input(
"VAR1=\tdefined",
"VAR2=\t# defined",
"VAR3=\t#empty")
vt.Diagnostics()
vt.Autofixes()
vt.Fixed(
"VAR1= defined",
"VAR2= # defined",
"VAR3= #empty")
vt.Run()
}
|