aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2013-01-10 13:12:01 -0500
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2013-01-10 13:12:01 -0500
commit8a64478e8d953ed249ecd18a8ec7fb19f69c167c (patch)
tree5fa88ab07fe0f023b7772eadb4a0f36f0c8ee96d /test
parent81df0ef6c9ae780d1b4a9f784a611e9c8a07789f (diff)
downloadegawk-8a64478e8d953ed249ecd18a8ec7fb19f69c167c.tar.gz
egawk-8a64478e8d953ed249ecd18a8ec7fb19f69c167c.tar.bz2
egawk-8a64478e8d953ed249ecd18a8ec7fb19f69c167c.zip
Add tests for inplace extension.
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog10
-rw-r--r--test/Makefile.am52
-rw-r--r--test/Makefile.in52
-rw-r--r--test/inplace.1.in2
-rw-r--r--test/inplace.2.in2
-rw-r--r--test/inplace.in3
-rw-r--r--test/inplace1.1.ok2
-rw-r--r--test/inplace1.2.ok2
-rw-r--r--test/inplace1.ok6
-rw-r--r--test/inplace2.1.bak.ok2
-rw-r--r--test/inplace2.1.ok2
-rw-r--r--test/inplace2.2.bak.ok2
-rw-r--r--test/inplace2.2.ok2
-rw-r--r--test/inplace2.ok6
-rw-r--r--test/inplace3.1.bak.ok2
-rw-r--r--test/inplace3.1.ok2
-rw-r--r--test/inplace3.2.bak.ok2
-rw-r--r--test/inplace3.2.ok2
-rw-r--r--test/inplace3.ok12
19 files changed, 161 insertions, 4 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index b9a29c1b..914a0fd1 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,13 @@
+2013-01-10 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * inplace.1.in, inplace.2.in, inplace.in, inplace1.1.ok, inplace1.2.ok,
+ inplace1.ok, inplace2.1.bak.ok, inplace2.1.ok, inplace2.2.bak.ok,
+ inplace2.2.ok, inplace2.ok, inplace3.1.bak.ok, inplace3.1.ok,
+ inplace3.2.bak.ok, inplace3.2.ok, inplace3.ok: New files.
+ * Makefile.am (EXTRA_DIST): Add new files.
+ (SHLIB_TESTS): Add inplace1, inplace2, and inplace3.
+ (inplace1, inplace2, inplace3): New tests.
+
2012-12-25 Arnold D. Robbins <arnold@skeeve.com>
* assignconst.awk, assignconst.ok: Removed.
diff --git a/test/Makefile.am b/test/Makefile.am
index da67b059..7a541f97 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -403,6 +403,22 @@ EXTRA_DIST = \
indirectcall.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 \
+ inplace2.1.bak.ok \
+ inplace2.2.ok \
+ inplace2.2.bak.ok \
+ inplace3.ok \
+ inplace3.1.ok \
+ inplace3.1.bak.ok \
+ inplace3.2.ok \
+ inplace3.2.bak.ok \
inputred.awk \
inputred.ok \
intest.awk \
@@ -953,8 +969,8 @@ LOCALE_CHARSET_TESTS = \
mbprintf1 mbprintf2 mbprintf3 rebt8b2 rtlenmb sort1 sprintfc
SHLIB_TESTS = \
- fnmatch filefuncs fork fork2 fts ordchr ordchr2 \
- readdir readfile revout revtwoway rwarray testext time
+ fnmatch filefuncs fork fork2 fts inplace1 inplace2 inplace3 \
+ ordchr ordchr2 readdir readfile revout revtwoway rwarray testext time
# List of the tests which should be run with --lint option:
NEED_LINT = \
@@ -1675,6 +1691,38 @@ incdupe7::
@AWKPATH=$(srcdir) $(AWK) --lint -f hello -i inchello >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+inplace1::
+ @echo $@
+ @cp $(srcdir)/inplace.1.in _$@.1
+ @cp $(srcdir)/inplace.2.in _$@.2
+ @AWKPATH=$(srcdir)/../awklib/eg/lib $(AWK) -i inplace 'BEGIN {print "before"} {gsub(/foo/, "bar"); print} END {print "after"}' _$@.1 - _$@.2 < $(srcdir)/inplace.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+ @-$(CMP) $(srcdir)/$@.1.ok _$@.1 && rm -f _$@.1
+ @-$(CMP) $(srcdir)/$@.2.ok _$@.2 && rm -f _$@.2
+
+inplace2::
+ @echo $@
+ @cp $(srcdir)/inplace.1.in _$@.1
+ @cp $(srcdir)/inplace.2.in _$@.2
+ @AWKPATH=$(srcdir)/../awklib/eg/lib $(AWK) -i inplace -v INPLACE_SUFFIX=.bak 'BEGIN {print "before"} {gsub(/foo/, "bar"); print} END {print "after"}' _$@.1 - _$@.2 < $(srcdir)/inplace.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+ @-$(CMP) $(srcdir)/$@.1.ok _$@.1 && rm -f _$@.1
+ @-$(CMP) $(srcdir)/$@.1.bak.ok _$@.1.bak && rm -f _$@.1.bak
+ @-$(CMP) $(srcdir)/$@.2.ok _$@.2 && rm -f _$@.2
+ @-$(CMP) $(srcdir)/$@.2.bak.ok _$@.2.bak && rm -f _$@.2.bak
+
+inplace3::
+ @echo $@
+ @cp $(srcdir)/inplace.1.in _$@.1
+ @cp $(srcdir)/inplace.2.in _$@.2
+ @AWKPATH=$(srcdir)/../awklib/eg/lib $(AWK) -i inplace -v INPLACE_SUFFIX=.bak 'BEGIN {print "before"} {gsub(/foo/, "bar"); print} END {print "after"}' _$@.1 - _$@.2 < $(srcdir)/inplace.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @AWKPATH=$(srcdir)/../awklib/eg/lib $(AWK) -i inplace -v INPLACE_SUFFIX=.bak 'BEGIN {print "Before"} {gsub(/bar/, "foo"); print} END {print "After"}' _$@.1 - _$@.2 < $(srcdir)/inplace.in >>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+ @-$(CMP) $(srcdir)/$@.1.ok _$@.1 && rm -f _$@.1
+ @-$(CMP) $(srcdir)/$@.1.bak.ok _$@.1.bak && rm -f _$@.1.bak
+ @-$(CMP) $(srcdir)/$@.2.ok _$@.2 && rm -f _$@.2
+ @-$(CMP) $(srcdir)/$@.2.bak.ok _$@.2.bak && rm -f _$@.2.bak
+
testext::
@echo $@
@$(AWK) '/^(@load|BEGIN)/,/^}/' $(top_srcdir)/extension/testext.c > testext.awk
diff --git a/test/Makefile.in b/test/Makefile.in
index e4b22fd8..52d8edc5 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -615,6 +615,22 @@ EXTRA_DIST = \
indirectcall.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 \
+ inplace2.1.bak.ok \
+ inplace2.2.ok \
+ inplace2.2.bak.ok \
+ inplace3.ok \
+ inplace3.1.ok \
+ inplace3.1.bak.ok \
+ inplace3.2.ok \
+ inplace3.2.bak.ok \
inputred.awk \
inputred.ok \
intest.awk \
@@ -1160,8 +1176,8 @@ LOCALE_CHARSET_TESTS = \
mbprintf1 mbprintf2 mbprintf3 rebt8b2 rtlenmb sort1 sprintfc
SHLIB_TESTS = \
- fnmatch filefuncs fork fork2 fts ordchr ordchr2 \
- readdir readfile revout revtwoway rwarray testext time
+ fnmatch filefuncs fork fork2 fts inplace1 inplace2 inplace3 \
+ ordchr ordchr2 readdir readfile revout revtwoway rwarray testext time
# List of the tests which should be run with --lint option:
@@ -2056,6 +2072,38 @@ incdupe7::
@AWKPATH=$(srcdir) $(AWK) --lint -f hello -i inchello >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+inplace1::
+ @echo $@
+ @cp $(srcdir)/inplace.1.in _$@.1
+ @cp $(srcdir)/inplace.2.in _$@.2
+ @AWKPATH=$(srcdir)/../awklib/eg/lib $(AWK) -i inplace 'BEGIN {print "before"} {gsub(/foo/, "bar"); print} END {print "after"}' _$@.1 - _$@.2 < $(srcdir)/inplace.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+ @-$(CMP) $(srcdir)/$@.1.ok _$@.1 && rm -f _$@.1
+ @-$(CMP) $(srcdir)/$@.2.ok _$@.2 && rm -f _$@.2
+
+inplace2::
+ @echo $@
+ @cp $(srcdir)/inplace.1.in _$@.1
+ @cp $(srcdir)/inplace.2.in _$@.2
+ @AWKPATH=$(srcdir)/../awklib/eg/lib $(AWK) -i inplace -v INPLACE_SUFFIX=.bak 'BEGIN {print "before"} {gsub(/foo/, "bar"); print} END {print "after"}' _$@.1 - _$@.2 < $(srcdir)/inplace.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+ @-$(CMP) $(srcdir)/$@.1.ok _$@.1 && rm -f _$@.1
+ @-$(CMP) $(srcdir)/$@.1.bak.ok _$@.1.bak && rm -f _$@.1.bak
+ @-$(CMP) $(srcdir)/$@.2.ok _$@.2 && rm -f _$@.2
+ @-$(CMP) $(srcdir)/$@.2.bak.ok _$@.2.bak && rm -f _$@.2.bak
+
+inplace3::
+ @echo $@
+ @cp $(srcdir)/inplace.1.in _$@.1
+ @cp $(srcdir)/inplace.2.in _$@.2
+ @AWKPATH=$(srcdir)/../awklib/eg/lib $(AWK) -i inplace -v INPLACE_SUFFIX=.bak 'BEGIN {print "before"} {gsub(/foo/, "bar"); print} END {print "after"}' _$@.1 - _$@.2 < $(srcdir)/inplace.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @AWKPATH=$(srcdir)/../awklib/eg/lib $(AWK) -i inplace -v INPLACE_SUFFIX=.bak 'BEGIN {print "Before"} {gsub(/bar/, "foo"); print} END {print "After"}' _$@.1 - _$@.2 < $(srcdir)/inplace.in >>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+ @-$(CMP) $(srcdir)/$@.1.ok _$@.1 && rm -f _$@.1
+ @-$(CMP) $(srcdir)/$@.1.bak.ok _$@.1.bak && rm -f _$@.1.bak
+ @-$(CMP) $(srcdir)/$@.2.ok _$@.2 && rm -f _$@.2
+ @-$(CMP) $(srcdir)/$@.2.bak.ok _$@.2.bak && rm -f _$@.2.bak
+
testext::
@echo $@
@$(AWK) '/^(@load|BEGIN)/,/^}/' $(top_srcdir)/extension/testext.c > testext.awk
diff --git a/test/inplace.1.in b/test/inplace.1.in
new file mode 100644
index 00000000..d87f79a1
--- /dev/null
+++ b/test/inplace.1.in
@@ -0,0 +1,2 @@
+is foo replaced?
+and again foo here?
diff --git a/test/inplace.2.in b/test/inplace.2.in
new file mode 100644
index 00000000..4644a915
--- /dev/null
+++ b/test/inplace.2.in
@@ -0,0 +1,2 @@
+another input file containing foo and foo and more foo
+but nothing to replace here
diff --git a/test/inplace.in b/test/inplace.in
new file mode 100644
index 00000000..bf2cf989
--- /dev/null
+++ b/test/inplace.in
@@ -0,0 +1,3 @@
+stdin start
+is foo replaced?
+stdin end
diff --git a/test/inplace1.1.ok b/test/inplace1.1.ok
new file mode 100644
index 00000000..8faa542e
--- /dev/null
+++ b/test/inplace1.1.ok
@@ -0,0 +1,2 @@
+is bar replaced?
+and again bar here?
diff --git a/test/inplace1.2.ok b/test/inplace1.2.ok
new file mode 100644
index 00000000..64427be3
--- /dev/null
+++ b/test/inplace1.2.ok
@@ -0,0 +1,2 @@
+another input file containing bar and bar and more bar
+but nothing to replace here
diff --git a/test/inplace1.ok b/test/inplace1.ok
new file mode 100644
index 00000000..ffcb768d
--- /dev/null
+++ b/test/inplace1.ok
@@ -0,0 +1,6 @@
+before
+gawk: inplace:9: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-'
+stdin start
+is bar replaced?
+stdin end
+after
diff --git a/test/inplace2.1.bak.ok b/test/inplace2.1.bak.ok
new file mode 100644
index 00000000..d87f79a1
--- /dev/null
+++ b/test/inplace2.1.bak.ok
@@ -0,0 +1,2 @@
+is foo replaced?
+and again foo here?
diff --git a/test/inplace2.1.ok b/test/inplace2.1.ok
new file mode 100644
index 00000000..8faa542e
--- /dev/null
+++ b/test/inplace2.1.ok
@@ -0,0 +1,2 @@
+is bar replaced?
+and again bar here?
diff --git a/test/inplace2.2.bak.ok b/test/inplace2.2.bak.ok
new file mode 100644
index 00000000..4644a915
--- /dev/null
+++ b/test/inplace2.2.bak.ok
@@ -0,0 +1,2 @@
+another input file containing foo and foo and more foo
+but nothing to replace here
diff --git a/test/inplace2.2.ok b/test/inplace2.2.ok
new file mode 100644
index 00000000..64427be3
--- /dev/null
+++ b/test/inplace2.2.ok
@@ -0,0 +1,2 @@
+another input file containing bar and bar and more bar
+but nothing to replace here
diff --git a/test/inplace2.ok b/test/inplace2.ok
new file mode 100644
index 00000000..ffcb768d
--- /dev/null
+++ b/test/inplace2.ok
@@ -0,0 +1,6 @@
+before
+gawk: inplace:9: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-'
+stdin start
+is bar replaced?
+stdin end
+after
diff --git a/test/inplace3.1.bak.ok b/test/inplace3.1.bak.ok
new file mode 100644
index 00000000..8faa542e
--- /dev/null
+++ b/test/inplace3.1.bak.ok
@@ -0,0 +1,2 @@
+is bar replaced?
+and again bar here?
diff --git a/test/inplace3.1.ok b/test/inplace3.1.ok
new file mode 100644
index 00000000..d87f79a1
--- /dev/null
+++ b/test/inplace3.1.ok
@@ -0,0 +1,2 @@
+is foo replaced?
+and again foo here?
diff --git a/test/inplace3.2.bak.ok b/test/inplace3.2.bak.ok
new file mode 100644
index 00000000..64427be3
--- /dev/null
+++ b/test/inplace3.2.bak.ok
@@ -0,0 +1,2 @@
+another input file containing bar and bar and more bar
+but nothing to replace here
diff --git a/test/inplace3.2.ok b/test/inplace3.2.ok
new file mode 100644
index 00000000..4644a915
--- /dev/null
+++ b/test/inplace3.2.ok
@@ -0,0 +1,2 @@
+another input file containing foo and foo and more foo
+but nothing to replace here
diff --git a/test/inplace3.ok b/test/inplace3.ok
new file mode 100644
index 00000000..7cd960bc
--- /dev/null
+++ b/test/inplace3.ok
@@ -0,0 +1,12 @@
+before
+gawk: inplace:9: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-'
+stdin start
+is bar replaced?
+stdin end
+after
+Before
+gawk: inplace:9: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-'
+stdin start
+is foo replaced?
+stdin end
+After