aboutsummaryrefslogtreecommitdiffstats
path: root/test/getfile.awk
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-03-31 22:35:15 +0300
committerArnold D. Robbins <arnold@skeeve.com>2015-03-31 22:35:15 +0300
commitbbeeb351c73fb1ee4ff20c3774e0477e9e8a7513 (patch)
tree95f926cd9bf02578e9c860726a56441ac00e95b2 /test/getfile.awk
parenteb53fb0398911202d4361b869eefa6c1449ebec8 (diff)
parent902b25a40d5cc612dd7a0becb27a5a48afa49716 (diff)
downloadegawk-bbeeb351c73fb1ee4ff20c3774e0477e9e8a7513.tar.gz
egawk-bbeeb351c73fb1ee4ff20c3774e0477e9e8a7513.tar.bz2
egawk-bbeeb351c73fb1ee4ff20c3774e0477e9e8a7513.zip
Merge branch 'master' into feature/regex-type
Diffstat (limited to 'test/getfile.awk')
-rw-r--r--test/getfile.awk35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/getfile.awk b/test/getfile.awk
new file mode 100644
index 00000000..6ee783f6
--- /dev/null
+++ b/test/getfile.awk
@@ -0,0 +1,35 @@
+function basename(x) {
+ return gensub(/^.*\//, "", 1, x)
+}
+
+BEGIN {
+ print "BEGIN"
+
+ cmd = "echo hello; echo goodbye"
+ rc = get_file(cmd, "<<", -1, res)
+ print "expected error result", rc, ERRNO
+ print "get_file returned", get_file(cmd, "|<", -1, res)
+ print "input_name", basename(res["input_name"])
+ print (cmd | getline x)
+ print x
+
+ # check that calling get_file on "" triggers the BEGINFILE rule
+ print "get_file returned", get_file("", "", -1, res)
+ print "input_name", basename(res["input_name"])
+ print "end BEGIN"
+}
+
+BEGINFILE {
+ printf "BEGINFILE (%s) ERRNO (%s)\n", basename(FILENAME), ERRNO
+}
+
+ENDFILE {
+ printf "ENDFILE (%s) ERRNO (%s)\n", basename(FILENAME), ERRNO
+}
+
+END {
+ print "END"
+ print (cmd | getline x)
+ print x
+ print close(cmd)
+}