]> git.draconx.ca Git - cdecl99.git/blobdiff - tests/general.at
tests: Avoid backslashes in awk variable assignment.
[cdecl99.git] / tests / general.at
index 7b34b9d45912ee360e88d8e57b82070df4fdf93a..fd48b062fd49b1c7fa9fbb5eed108d0c3a0244ce 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright © 2012, 2020-2021, 2023 Nick Bowler
+# Copyright © 2012, 2020-2021, 2023-2024 Nick Bowler
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -70,15 +70,14 @@ explain int
 
 # Program to generate expected output based on src/execute.gperf
 AT_DATA([expout.sed],
-[[#n
-/^%%$/,/^%%$/ {
+[[/^%%$/,/^%%$/ {
   s/^exit.*//
   s/,.*//p
 }
 $a\
 type int
 ]])
-sed -f expout.sed "$srcdir/src/execute.gperf" >expout
+sed -n -f expout.sed "$srcdir/src/execute.gperf" >expout
 
 # Program to filter the help output to extract the command list from "help"
 # without any descriptions.
@@ -117,7 +116,7 @@ AT_SETUP([cdecl99 command error messages])
 # This will only get the start of progname if it includes spaces;
 # so we won't worry too hard about the exact format later.
 AT_CHECK([LC_ALL=C cdecl99 --help], [0], [stdout])
-progname=`$AWK 'NR == 1 { print $2; }' stdout`dnl'
+progname=`$AWK 'NR == 1 { gsub(/[[\\\\]]/, "/", $2); print $2; }' stdout`dnl'
 
 # every line is erroneous
 AT_DATA([input],
@@ -129,6 +128,7 @@ bad command
 
 AT_DATA([check.awk],
 [[BEGIN { status=0; }
+{ gsub(/[\\]/, "/"); }
 $1 == progname || $1 == (progname ":") { next; }
 { status=1; print "unprefixed message on line", NR ":", $0; }
 END { exit(status); }
@@ -149,15 +149,13 @@ AT_CLEANUP
 
 AT_SETUP([cdecl99 invalid character error messages])
 
-$AWK -f - >test.dat <<'EOF'
-BEGIN {
+$AWK 'BEGIN {
   print "explain \1";
   print "explain \377";
   print "explain \a";
   print "explain \b";
   print "explain ?";
-}
-EOF
+}' >test.dat </dev/null
 
 AT_CHECK([LC_ALL=C cdecl99 -f test.dat || exit 42], [42], [], [stderr])
 AT_CHECK([$AWK '{ print $NF; }' stderr], [0],
@@ -232,3 +230,12 @@ AT_CHECK([echo >>stdout; sed -f check.sed stdout], [0],
 ])
 
 AT_CLEANUP
+
+AT_SETUP([cdecl99 EOF in batch mode])
+
+AT_CHECK([AS_ECHO_N(["explain int"]) | cdecl99 --batch | head], [0],
+[[type int
+]])
+AT_CHECK([cdecl99 --batch </dev/null])
+
+AT_CLEANUP