diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ChangeLog | 6 | ||||
-rw-r--r-- | test/Makefile.am | 45 | ||||
-rw-r--r-- | test/Makefile.in | 45 | ||||
-rw-r--r-- | test/iolint.awk | 71 | ||||
-rw-r--r-- | test/iolint.ok | 37 |
5 files changed, 168 insertions, 36 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index e9199f85..eb3899ca 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,9 @@ +2020-09-21 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (EXTRA_DIST): New test iolint. Sort the list of + files beginning with 'i'. + * iolint.awk, iolint.ok: New files. + 2020-09-04 Arnold D. Robbins <arnold@skeeve.com> * id.ok: Updated after code changes. diff --git a/test/Makefile.am b/test/Makefile.am index dcef19cb..ff2ba120 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -522,9 +522,6 @@ EXTRA_DIST = \ icasers.awk \ icasers.in \ icasers.ok \ - inpref.awk \ - inpref.in \ - inpref.ok \ id.awk \ id.ok \ igncdym.awk \ @@ -542,53 +539,56 @@ EXTRA_DIST = \ ignrcase.awk \ ignrcase.in \ ignrcase.ok \ - incdupe.ok \ incdupe2.ok \ incdupe3.ok \ incdupe4.ok \ incdupe5.ok \ incdupe6.ok \ incdupe7.ok \ + incdupe.ok \ inchello.awk \ inclib.awk \ + include2.ok \ include.awk \ include.ok \ - include2.ok \ indirectbuiltin.awk \ indirectbuiltin.ok \ + indirectcall2.awk \ + indirectcall2.ok \ indirectcall.awk \ indirectcall.in \ indirectcall.ok \ - indirectcall2.awk \ - indirectcall2.ok \ inftest.awk \ inftest.ok \ - inplace.in \ - inplace.1.in \ - inplace.2.in \ - inplace1.ok \ inplace1.1.ok \ inplace1.2.ok \ - inplace2.ok \ - inplace2.1.ok \ + inplace.1.in \ + inplace1.ok \ inplace2.1.bak.ok \ - inplace2.2.ok \ + inplace2.1.ok \ inplace2.2.bak.ok \ + inplace2.2.ok \ inplace2bcomp.1.ok \ inplace2bcomp.1.orig.ok \ inplace2bcomp.2.ok \ inplace2bcomp.2.orig.ok \ inplace2bcomp.ok \ - inplace3.ok \ - inplace3.1.ok \ + inplace.2.in \ + inplace2.ok \ inplace3.1.bak.ok \ - inplace3.2.ok \ + inplace3.1.ok \ inplace3.2.bak.ok \ + inplace3.2.ok \ inplace3bcomp.1.ok \ inplace3bcomp.1.orig.ok \ inplace3bcomp.2.ok \ inplace3bcomp.2.orig.ok \ inplace3bcomp.ok \ + inplace3.ok \ + inplace.in \ + inpref.awk \ + inpref.in \ + inpref.ok \ inputred.awk \ inputred.ok \ intarray.awk \ @@ -601,6 +601,8 @@ EXTRA_DIST = \ intprec.ok \ iobug1.awk \ iobug1.ok \ + iolint.awk \ + iolint.ok \ isarrayunset.awk \ isarrayunset.ok \ jarebug.awk \ @@ -1420,7 +1422,7 @@ GAWK_EXT_TESTS = \ genpot gensub gensub2 gensub3 getlndir gnuops2 gnuops3 gnureops gsubind \ icasefs icasers id igncdym igncfs ignrcas2 ignrcas4 ignrcase incdupe \ incdupe2 incdupe3 incdupe4 incdupe5 incdupe6 incdupe7 include include2 \ - indirectbuiltin indirectcall indirectcall2 intarray isarrayunset \ + indirectbuiltin indirectcall indirectcall2 intarray iolint isarrayunset \ lint lintexp lintindex lintint lintlength lintplus lintold lintset lintwarn \ manyfiles match1 match2 match3 mbstr1 mbstr2 mixed1 mktime muldimposix \ nastyparm negtime next nondec nondec2 nonfatal1 nonfatal2 nonfatal3 \ @@ -2448,6 +2450,13 @@ typedregex4: @$(AWK) -v x=@/foo/ -f "$(srcdir)"/$@.awk y=@/bar/ /dev/null >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +iolint: + @echo $@ + @echo hello > 'echo hello' + @$(AWK) -f "$(srcdir)"/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + @-$(RM) -f cat 'echo hello' f1 f2 md5sum + # Targets generated for other tests: include Maketests diff --git a/test/Makefile.in b/test/Makefile.in index 491daedc..a8848e85 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -785,9 +785,6 @@ EXTRA_DIST = \ icasers.awk \ icasers.in \ icasers.ok \ - inpref.awk \ - inpref.in \ - inpref.ok \ id.awk \ id.ok \ igncdym.awk \ @@ -805,53 +802,56 @@ EXTRA_DIST = \ ignrcase.awk \ ignrcase.in \ ignrcase.ok \ - incdupe.ok \ incdupe2.ok \ incdupe3.ok \ incdupe4.ok \ incdupe5.ok \ incdupe6.ok \ incdupe7.ok \ + incdupe.ok \ inchello.awk \ inclib.awk \ + include2.ok \ include.awk \ include.ok \ - include2.ok \ indirectbuiltin.awk \ indirectbuiltin.ok \ + indirectcall2.awk \ + indirectcall2.ok \ indirectcall.awk \ indirectcall.in \ indirectcall.ok \ - indirectcall2.awk \ - indirectcall2.ok \ inftest.awk \ inftest.ok \ - inplace.in \ - inplace.1.in \ - inplace.2.in \ - inplace1.ok \ inplace1.1.ok \ inplace1.2.ok \ - inplace2.ok \ - inplace2.1.ok \ + inplace.1.in \ + inplace1.ok \ inplace2.1.bak.ok \ - inplace2.2.ok \ + inplace2.1.ok \ inplace2.2.bak.ok \ + inplace2.2.ok \ inplace2bcomp.1.ok \ inplace2bcomp.1.orig.ok \ inplace2bcomp.2.ok \ inplace2bcomp.2.orig.ok \ inplace2bcomp.ok \ - inplace3.ok \ - inplace3.1.ok \ + inplace.2.in \ + inplace2.ok \ inplace3.1.bak.ok \ - inplace3.2.ok \ + inplace3.1.ok \ inplace3.2.bak.ok \ + inplace3.2.ok \ inplace3bcomp.1.ok \ inplace3bcomp.1.orig.ok \ inplace3bcomp.2.ok \ inplace3bcomp.2.orig.ok \ inplace3bcomp.ok \ + inplace3.ok \ + inplace.in \ + inpref.awk \ + inpref.in \ + inpref.ok \ inputred.awk \ inputred.ok \ intarray.awk \ @@ -864,6 +864,8 @@ EXTRA_DIST = \ intprec.ok \ iobug1.awk \ iobug1.ok \ + iolint.awk \ + iolint.ok \ isarrayunset.awk \ isarrayunset.ok \ jarebug.awk \ @@ -1683,7 +1685,7 @@ GAWK_EXT_TESTS = \ genpot gensub gensub2 gensub3 getlndir gnuops2 gnuops3 gnureops gsubind \ icasefs icasers id igncdym igncfs ignrcas2 ignrcas4 ignrcase incdupe \ incdupe2 incdupe3 incdupe4 incdupe5 incdupe6 incdupe7 include include2 \ - indirectbuiltin indirectcall indirectcall2 intarray isarrayunset \ + indirectbuiltin indirectcall indirectcall2 intarray iolint isarrayunset \ lint lintexp lintindex lintint lintlength lintplus lintold lintset lintwarn \ manyfiles match1 match2 match3 mbstr1 mbstr2 mixed1 mktime muldimposix \ nastyparm negtime next nondec nondec2 nonfatal1 nonfatal2 nonfatal3 \ @@ -2894,6 +2896,13 @@ typedregex4: @echo $@ @$(AWK) -v x=@/foo/ -f "$(srcdir)"/$@.awk y=@/bar/ /dev/null >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + +iolint: + @echo $@ + @echo hello > 'echo hello' + @$(AWK) -f "$(srcdir)"/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + @-$(RM) -f cat 'echo hello' f1 f2 md5sum Gt-dummy: # file Maketests, generated from Makefile.am by the Gentests program addcomma: diff --git a/test/iolint.awk b/test/iolint.awk new file mode 100644 index 00000000..e7408151 --- /dev/null +++ b/test/iolint.awk @@ -0,0 +1,71 @@ +BEGIN { + LINT = 1 + + # `%.*s' used for input file and for output file + print "hi" > "f1" + fflush("f1") + getline x < "f1" + print close("f1") + print close("f1") + fflush() + + # `%.*s' used for input file and input pipe + # `%.*s' used for input file and two-way pipe + # `%.*s' used for input pipe and two-way pipe + getline data3 < "echo hello" + "echo hello" |& getline data2 + "echo hello" | getline data + + print data, data2, data3 + + print close("echo hello") + print close("echo hello") + print close("echo hello") + fflush() + + # `%.*s' used for input file and output pipe + getline x < "cat" + print "foo" | "cat" + print close("cat") + print close("cat") + fflush() + + # unnecessary mixing of `>' and `>>' for file `%.*s' + print "foo" > "f2" + print "bar" >> "f2" + print close("f2") + print close("f2") # -1 expected here + fflush() + + # `%.*s' used for output file and output pipe" + print "junk" > "md5sum" + print "hello" | "md5sum" + print close("md5sum") + print close("md5sum") + fflush() + + # `%.*s' used for input pipe and output file + "echo hello" | getline junk + print "hello" > "echo hello" + print close("echo hello") + print close("echo hello") + fflush() + + # `%.*s' used for output file and output pipe + # `%.*s' used for output file and two-way pipe + # `%.*s' used for output pipe and two-way pipe + print "hello" > "cat" + print "hello" | "cat" + print "hello" |& "cat" + print close("cat") + print close("cat") + print close("cat") + fflush() + + # `%.*s' used for input pipe and output pipe + "echo hello" | getline junk + print "hello" | "echo hello" + print close("echo hello") + print close("echo hello") + fflush() +} diff --git a/test/iolint.ok b/test/iolint.ok new file mode 100644 index 00000000..1e325aab --- /dev/null +++ b/test/iolint.ok @@ -0,0 +1,37 @@ +gawk: ./iolint.awk:7: warning: `f1' used for input file and for output file +0 +0 +gawk: ./iolint.awk:16: warning: `echo hello' used for input file and two-way pipe +gawk: ./iolint.awk:17: warning: `echo hello' used for input pipe and two-way pipe +gawk: ./iolint.awk:17: warning: `echo hello' used for input file and input pipe +hello hello hello +0 +0 +0 +foo +0 +gawk: ./iolint.awk:30: warning: close: `cat' is not an open file, pipe or co-process +-1 +gawk: ./iolint.awk:35: warning: unnecessary mixing of `>' and `>>' for file `f2' +0 +gawk: ./iolint.awk:37: warning: close: `f2' is not an open file, pipe or co-process +-1 +gawk: ./iolint.awk:42: warning: `md5sum' used for output file and output pipe +b1946ac92492d2347c6235b4d2611184 - +0 +0 +gawk: ./iolint.awk:49: warning: `echo hello' used for input pipe and output file +0 +0 +gawk: ./iolint.awk:58: warning: `cat' used for output file and output pipe +gawk: ./iolint.awk:59: warning: `cat' used for output pipe and two-way pipe +gawk: ./iolint.awk:59: warning: `cat' used for output file and two-way pipe +hello +gawk: ./iolint.awk:60: warning: failure status (141) on two-way pipe close of `cat': Success +141 +0 +0 +gawk: ./iolint.awk:67: warning: `echo hello' used for input pipe and output pipe +hello +0 +0 |