gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] gawk branch, egtests, updated. gawk-4.1.0-4277-g26ac3b0


From: Antonio Giovanni Colombo
Subject: [SCM] gawk branch, egtests, updated. gawk-4.1.0-4277-g26ac3b0
Date: Mon, 17 May 2021 09:52:12 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, egtests has been updated
       via  26ac3b0e5d9b3f399f916e4de8e9cd930e12c4b1 (commit)
      from  b051055ae0662ca2e19d7b9a7eeb9f35aa75cb0e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=26ac3b0e5d9b3f399f916e4de8e9cd930e12c4b1

commit 26ac3b0e5d9b3f399f916e4de8e9cd930e12c4b1
Author: Antonio Giovanni Colombo <azc100@gmail.com>
Date:   Mon May 17 15:49:08 2021 +0200

    First version that uses only gawk to select the tests to perform.

diff --git a/egtests/ChangeLog b/egtests/ChangeLog
new file mode 100644
index 0000000..d87220f
--- /dev/null
+++ b/egtests/ChangeLog
@@ -0,0 +1,12 @@
+2021-04-17         Antonio Giovanni Colombo   <azc100@gmail.com>
+
+       * extracten: Updated.
+       * extractit: Updated.
+       * extractit.awk: Updated.
+       * choose.awk: Added.
+       * egtest: Added.
+       * gawkeg: Removed.
+       * egtest.awk: Added.
+       * gawkeg.awk: Removed.
+       * picksome.awk: Added.
+
diff --git a/egtests/choose.awk b/egtests/choose.awk
new file mode 100755
index 0000000..1bb1857
--- /dev/null
+++ b/egtests/choose.awk
@@ -0,0 +1,196 @@
+# given a list of tests to perform in "list"
+# each name in the list does NOT contain a space char
+# display it by "cols" and accept a choice from the user
+# the display line is always long 80,
+# the visible part of each choice is reduced accordingly
+BEGIN { # number of columns in the display (max 6)
+       if ( cols=="" ) { exit(4) }
+       # check that indeed the cols are between 1 and 6
+       if ( cols>6 || cols<0 ) { cols=6 }
+       # list of alternatives
+       if ( list=="" ) { exit(4) }
+       # directory in which to write the user choices
+       if ( s==""    ) { exit(4) }
+       #print list
+       do_init()
+       size=int(80/cols)
+       nel=split(list,el," ")
+       #print "visualizing",nel,"choices in",cols,"columns, each choice uses 
max",size,"chars"
+       # real size is 5 less... "nnn choice.... "
+       namesize=size-5
+       # size,namesize
+       #print "# size,namesize = " size,namesize;
+       build_rows()
+       # if valid becomes "n", prompt again for input
+       valid="n"
+       msg=""
+       while ( valid=="n" ) {
+               display_rows()
+               if ( msg!="" ) { print "===>",msg }
+               printf "===> Which test(s)? [1-" nel ",q,h,...] "
+               getline
+               build_line()
+               # either line or cmds could be empty (hopefully not both)
+               # line,cmds
+               #print "# line,cmds = " line,cmds;
+               print line "%%" cmds > s "/choice"
+       }
+       exit
+}
+
+function build_rows() {
+       # each element is in col[row,number] last column may be shorter
+       nrows=int(nel/cols)
+       if ( nrows*cols<nel ) { nrows++ }
+       #print nrows,"rows necessary"
+       nrow=1;
+       for ( i=1; i<=nrows*cols; i++ ) {
+               nchoice=i
+               cchoice=i""
+               while ( length(cchoice)<3 ) { cchoice=" " cchoice }
+               cdesc=el[i] ""
+               if    ( length(cdesc)>namesize ) { cdesc= 
substr(cdesc,1,namesize) }
+               while ( length(cdesc)<namesize ) { cdesc= cdesc " " }
+               if ( cdesc==substr(blancs,1,namesize ) ) { cchoice="   " }
+               row[nrow]=row[nrow] cchoice " " cdesc " "
+               nrow++
+               if ( nrow>nrows ) { nrow=1 }
+       }
+       # drop the last character, which is a space anyway
+       for ( i=1; i<=nrows; i++ ) { row[i]=substr(row[i],1,length(row[i])-1) }
+}
+
+function display_rows() {
+       for ( i=1; i<=nrows; i++ ) {
+               print row[i]
+       }
+}
+
+function build_line() {
+       # each file name is in el[1...nel]
+       wrk=$0
+       # it could be a list, to be built, something like:
+       # q  /  ,h  / 1-7,5,49f
+       # each fi[] is either a single digit or a range (or a char)
+       # containing a list of test names
+       # containing a command
+       # if there are commands, they are at the end
+       chk_final_letters()
+       # wrk
+       #print "# wrk = " wrk;
+       cmds=""
+       nfi=split(wrk,fi,",")
+       for ( i=1; i<=nfi; i++ ) {
+               item=fi[i]
+               eval_item()
+       }
+       if ( valid=="n" ) { return }
+       line=""
+       for ( i=1; i<=nel; i++ ){
+               if ( use[i]=="y" ) { line=line el[i] " " }
+       }
+       # drop final space
+       line=substr(line,1,length(line)-1)
+}
+
+function do_init() {
+       numbers="0123456789"
+       commands=" b d e h q Q quit w x ZZ zz "
+       letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+       blancs="                                                                
                                "
+}
+
+function eval_item() {
+       # could be a range, a single number, a single letter or more 
combinations, comma separated
+       # out of range numbers are flagged as invalid
+       #
+       # single number or letter
+       #print "evaluating",item
+       if ( length(item)==1 ) {
+               idx=index(numbers,item)
+               # if it is a number
+               if ( idx>0 ) {
+                       use[item]="y"
+                       valid="y"
+                       return
+               }
+               tmp=" " item " "
+               #print tmp
+               idx=index(commands,tmp)
+               #print idx
+               if ( idx>0 ) {
+                       cmds=cmds item
+                       valid="y"
+                       return
+               } else {
+                       msg="Invalid command " item ", please give a valid one"
+                       valid="n"
+                       return
+               }
+       }
+       #
+       # again a number
+       #
+       if ( length(item)==2 ) {
+               if ( item+0>9 && item+0<=nel ) {
+                       use[item]="y"
+                       valid="y"
+                       return
+               }
+       }
+       # range, or more than one char
+       nra=split(item,ra,"-")
+       if ( nra==2 ) {
+               if ( ra[1]>ra[2] ) {
+                       msg="Invalid range " item ", please give a valid one"
+                       valid="n"
+                       return
+               }
+               if ( ra[1]<1 || ra[2]>nel ) {
+                       msg="Invalid range " item ", please give a valid one"
+                       valid="n"
+                       return
+               }
+               for ( k=ra[1]; k<=ra[2]; k++ ) {
+                       use[k]="y"
+               }
+               valid="y"
+               return
+       }
+       # more than one char
+       wrk=" " item " "
+       idx=index(commands,wrk)
+       if ( idx>0 ) {
+               cmds=cmds item
+               valid="y"
+               return
+       }
+       # everything else is wrong...
+       msg="Invalid input " item ", please give a valid one"
+       valid="n"
+}
+
+function chk_final_letters() {
+       #
+       # just insert a comma after the last digit...
+       #
+       # if the last char is a number, nothing to do
+       ch=substr(wrk,length(wrk),1)
+       idx=index(numbers,ch)
+       if ( idx>0 ) { return }
+       # otherwise, check...
+       final=""
+       for ( l=length(wrk); l>=1; l-- ) {
+               ch=substr(wrk,l,1)
+               idx=index(letters,ch)
+               if ( idx>0 ) {
+                       final=ch final
+                       continue
+               }
+               # if there is already a comma
+               if ( substr(wrk,l,1)=="," ) { return }
+               # insert a comma
+               wrk=substr(wrk,1,l) "," final
+               return
+       }
+}
diff --git a/egtests/gawkeg b/egtests/egtest
similarity index 78%
rename from egtests/gawkeg
rename to egtests/egtest
index 48465e2..6c3ddfc 100755
--- a/egtests/gawkeg
+++ b/egtests/egtest
@@ -1,4 +1,27 @@
 :
+#
+# this script tests all the scripts/programs,
+# contained in the gawk book,
+# that are extracted in the eg directory
+# by the extract.awk script
+#
+# it will work only under Linux/Unix
+# it will work only when invoked in the distribution directory
+# (that way the location of the gawktexi.in files is known)
+#
+# it can be executed by any user, provided it has access
+# to the gawk distribution directories
+# practically useful for the "readable.awk" test
+#
+# to run all the examples it needs:
+# gawk
+# gawkextlib-1.0.4
+# gawk-mbs-snapshot.tar
+# gcc
+# vim/vimdiff
+# the files:
+# /usr/share/dict/words
+#
 # / main
 # ...for customisation
 #
@@ -7,13 +30,13 @@ print_help() {
        echo "Choose by number one or more tests to try"
        echo "e.g.: 1-5,14,26-30"
        echo "If a suffix is given, e.g.: 1e or: h"
-       echo "alone or after the list of numbers"
+       echo "(alone or after a list of numbers)"
        echo "h -- will just print this help text"
        echo "d -- will invoke ${vim}diff for a test file in both languages"
-       echo "b -- will invoke $vim for a test file"
-       echo "e -- will invoke $vim for a test file"
+       echo "b -- will invoke ${vim} for a test file"
+       echo "e -- will invoke ${vim} for a test file"
        echo "w -- will tell where a module is"
-       echo "q,Q,quit,x,ZZ,zz -- will exit from gawkeg"
+       echo "q,Q,quit,x,ZZ,zz -- will exit from egtest"
        echo "Everything else just has no effect"
 }
 
@@ -145,10 +168,10 @@ do_egrep() {
 
 do_extract() {
        echo "*"
-       echo "* extract.awk is implicitly tested when running gawkeg:"
+       echo "* extract.awk is implicitly tested when running $0:"
        echo "* it is used to build the test libraries."
        echo "* If there are problems they should be reported during"
-       echo "* the initialization of the gawkeg shell script"
+       echo "* the initialization of the $0 shell script"
 }
 
 do_findpat() {
@@ -174,6 +197,33 @@ do_ftrans() {
              gawk -f ftrans.awk -f $testpgm wc.awk cut.awk pi.awk
 }
 
+do_gen_float_table() {
+       # the programs are in test-programs
+       echo "*"
+       echo "* testing floating-point management in C, Gawk, Python"
+       echo "* C"
+       echo "gcc -o $tmplib/gen-float-table ../test-programs/gen-float-table.c 
-lm"
+             gcc -o $tmplib/gen-float-table ../test-programs/gen-float-table.c 
-lm
+       echo "$tmplib/gen-float-table >$tmplib/C.out"
+             $tmplib/gen-float-table >$tmplib/C.out
+       echo "*"
+       echo "* Gawk"
+       echo "gawk -f ../test-programs/gen-float-table.awk >$tmplib/Gawk.out"
+             gawk -f ../test-programs/gen-float-table.awk >$tmplib/Gawk.out
+       echo "*"
+       echo "* Python"
+       echo "$python ../test-programs/gen-float-table.py >$tmplib/Python.out" 
+             $python ../test-programs/gen-float-table.py >$tmplib/Python.out 
+       echo "*"
+       echo "...comparing the output from the three programs:"
+       echo "*"
+       echo "$vimdiff $tmplib/*.out"
+       wait_go_ahead
+             $vimdiff $tmplib/*.out
+
+
+}
+
 do_getopt() {
        echo "*"
        echo "gawk -f getopt.awk -v _getopt_test=1 -- -a -cbARG bax -x -y -zfoo"
@@ -210,25 +260,30 @@ do_groupawk() {
 }
 
 do_guide() {
-       # the first time you really convert the messages
+       #
+       # the message is already converted...
+       #
+       echo "*"
+       echo "* beware, the messages have been converted already"
+       echo "* they are shown just to check the conversion"
        echo "*"
        echo "gawk --gen-pot -f guide.awk >$datadir/guide.pot"
              gawk --gen-pot -f guide.awk >$datadir/guide.pot 
-       echo "# if the file is not existing yet, save this file as 
$datadir/$poname.po" >>$datadir/guide.pot
        echo "*"
-       echo "$vim $datadir/guide.pot"
+       echo "$vim -o $datadir/guide.pot $datadir/$poname.po"
              wait_go_ahead
-             $vim $datadir/guide.pot
-       echo "*"
+             $vim -o $datadir/guide.pot $datadir/$poname.po
        echo "*"
        echo "msgfmt $datadir/$poname.po -o $podir/LC_MESSAGES/guide.mo"
              msgfmt $datadir/$poname.po -o $podir/LC_MESSAGES/guide.mo
        echo "*"
        echo "* Translated messages:"
+       echo "*"
        echo "gawk -f guide.awk"
              gawk -f guide.awk
        echo "*"
        echo "* Original messages:"
+       echo "*"
        echo "gawk --posix -f guide.awk -f libintl.awk"
              gawk --posix -f guide.awk -f libintl.awk 
 }
@@ -264,8 +319,8 @@ do_have_mpfr() {
 do_histsort() {
        echo "*"
        # history has a line number before each entry
-       echo "history|tail -30|cut -c8-|gawk -f histsort.awk|sort"
-             history|tail -30|cut -c8-|gawk -f histsort.awk|sort
+       echo "history|tail -20|cut -c8-|gawk -f histsort.awk|sort"
+             history|tail -20|cut -c8-|gawk -f histsort.awk|sort
 }
 
 do_id() {
@@ -316,17 +371,17 @@ do_inplace() {
        echo "echo \"one two three four\"|gawk -i inplace '{ gsub(/three/, "3") 
}; { print }'"
        echo        "one two three four" |gawk -i inplace '{ gsub(/three/, "3") 
}; { print }'
        echo "*"
-       echo "head -5 $datadir/mail-list > $testpgm"
-             head -5 $datadir/mail-list > $testpgm
+       echo "head -5 $datadir/mail-list > $testdata"
+             head -5 $datadir/mail-list > $testdata
        echo "*"
-       echo "cat $testpgm"
-             cat $testpgm
+       echo "cat $testdata"
+             cat $testdata
        echo "*"
-       echo "gawk -i inplace '{ gsub(/gmail/, \"ZZZZZ\") }; { gsub(\"555\", 
\"999\") } { print }' $testpgm"
-             gawk -i inplace '{ gsub(/gmail/,  "ZZZZZ" ) }; { gsub( "555",   
"999" ) } { print }' $testpgm
+       echo "gawk -i inplace '{ gsub(/gmail/, \"ZZZZZ\") }; { gsub(\"555\", 
\"999\") } { print }' $testdata"
+             gawk -i inplace '{ gsub(/gmail/,  "ZZZZZ" ) }; { gsub( "555",   
"999" ) } { print }' $testdata
        echo "*"
-       echo "cat $testpgm"
-             cat $testpgm
+       echo "cat $testdata"
+             cat $testdata
 }
 
 do_intdiv0() {
@@ -358,15 +413,15 @@ do_labels() {
        echo "*"
        echo "BEGIN { for (i=1; i<=35; i++ ) { gen_label(); } exit; } function 
gen_label() { nlab++; printf \"Given-Name \"; for ( j=1; j<=8; j++ ) { printf 
nlab; } print \"\"; print \"Broad Street,\",nlab; print \"12345 Somewhere\"; 
print \"KY\"; print \"\"; }" >$testpgm
        echo "* creating a \"label\" file"
-       echo "gawk -f \$testpgm >../../labels.txt"
-             gawk -f  $testpgm >../../labels.txt
+       echo "gawk -f \$testpgm >$s/$lang/labels.txt"
+             gawk -f  $testpgm >$s/$lang/labels.txt
        echo "* calling the labels.awk program"
-       echo "gawk -f labels.awk ../../labels.txt >../../labels.out"
-             gawk -f labels.awk ../../labels.txt >../../labels.out
+       echo "gawk -f labels.awk $s/$lang/labels.txt >$s/$lang/labels.out"
+             gawk -f labels.awk $s/$lang/labels.txt >$s/$lang/labels.out
        echo "* invoking $vim to view output of labels.awk"
              wait_go_ahead
-             $vim -o ../../labels.txt ../../labels.out
-             rm -f   ../../labels.txt ../../labels.out
+             $vim -o $s/$lang/labels.txt $s/$lang/labels.out
+             rm -f   $s/$lang/labels.txt $s/$lang/labels.out
 
 }
 
@@ -545,18 +600,18 @@ do_simple_csv() {
 do_split() {
        echo "*"
        echo " cleanup just in case"
-       echo " rm -f ../../gawkeg*"
-              rm -f ../../gawkeg*
-       echo "gawk -f getopt.awk -f split.awk -- -l 5 /etc/hosts ../../gawkeg"
-             gawk -f getopt.awk -f split.awk -- -l 5 /etc/hosts ../../gawkeg
-             wc -l ../../gawkeg*
+       echo " rm -f $s/$lang/egtest*"
+              rm -f $s/$lang/egtest*
+       echo "gawk -f getopt.awk -f split.awk -- -l 5 /etc/hosts 
$s/$lang/egtest"
+             gawk -f getopt.awk -f split.awk -- -l 5 /etc/hosts $s/$lang/egtest
+             wc -l $s/$lang/egtest*
        echo "*"
        echo " cleanup just in case"
-       echo " rm -f ../../gawkeg*"
-              rm -f ../../gawkeg*
-       echo "gawk -f getopt.awk -f split.awk -- -b 100 /etc/hosts ../../gawkeg"
-             gawk -f getopt.awk -f split.awk -- -b 100 /etc/hosts ../../gawkeg
-             wc -c ../../gawkeg*
+       echo " rm -f $s/$lang/egtest*"
+              rm -f $s/$lang/egtest*
+       echo "gawk -f getopt.awk -f split.awk -- -b 100 /etc/hosts 
$s/$lang/egtest"
+             gawk -f getopt.awk -f split.awk -- -b 100 /etc/hosts 
$s/$lang/egtest
+             wc -c ../../egtest*
 }
 
 do_strtonum() {
@@ -692,106 +747,174 @@ wait_go_ahead() {
        read nothing
        if [ "$nothing" = "q" -o "$nothing" = "Q" -o "$nothing" = "zz" -o 
"$nothing" = "ZZ" -o "$nothing" = "quit" -o "$nothing" = "x" ]
        then
-               go_away
+               rm -rf $s
+               exit
        fi
 }
 
-go_away() {
-       #echo exiting, as per request
-       if [ -f "$testpgm" ]
-       then
-               rm -f $testpgm
-       fi
-       if [ -f "$testdata" ]
-       then
-               rm -f $testdata
-       fi
-       # this one should always be there
-       rm -f ../../egidx.awk
-       # these could be there or not
-       rm -f ../../gawkeg*
-       figlet done
-       exit
-}
-
 # set -xv
 #
 # main
 #
-# this script tests gawk programs that are in the eg directory
-# needs gawkextlib-1.0.4
-# needs gawk-mbs-snapshot.tar
-#
 # editor to use
 export vim=vim
-# the programs etc are extracted inside this directory
-export s=$t
+export vimdiff=vimdiff
+# version of python
+export python=python3
+if [ "$1" = "it" ]
+then
+       export lang=it
+else
+       export lang=en
+fi
+#
+# everything happens in the directory
+# which is the one that contains
+# the scripts etc.
+# (it does not work elsewhere)
+# and remains in its place inside a gawk distribution
+# the doc distribution library is supposed to be
+# at the same level ($docen and $docit below)
+#
+export updir=`dirname $PWD`
+export docen=${updir}/doc
+export docit=${updir}/doc/it
+# echo $updir $docen $docit
+
+#
+# there must be a doc directory
+#
+if [ ! -d "$docen" ]
+then
+       echo Current directory is $PWD
+       echo This script must be executed in a gawk distribution, in the 
directory egtests
+       echo Nothing done
+       exit
+fi
+
+#
+# it must contain the gawktexi.in file
+#
+if [ ! -s "$docen/gawktexi.in" ]
+then
+       echo Current directory is $PWD
+       echo This script must be executed in a gawk distribution, in the 
directory egtests
+       echo Nothing done
+       exit
+fi
+
+# just to play it safe, let us check Italian as well
+if [ ! -d "$docit" ]
+then
+       echo Current directory is $PWD
+       echo This script must be executed in a gawk distribution, in the 
directory egtests
+       echo Nothing done
+       exit
+fi
+
+#
+# it must contain the gawktexi.in file
+#
+if [ ! -s "$docit/gawktexi.in" ]
+then
+       echo Current directory is $PWD
+       echo This script must be executed in a gawk distribution, in the 
directory egtests
+       echo Nothing done
+       exit
+fi
+
+# current directory
+export b=${PWD}
+#
+# programs etc. are in this directory
+#
+export s=${PWD}/tmp
+
 if [ ! -d "$s" ]
 then
        mkdir $s
+else
+       rm -rf $s
+       mkdir  $s
 fi
-# scripts etc. are in this directory
-export b=$d/dat/bin
-# parms: it or en, defaults to en
-if [ "$1" = "it" ]
+
+# extract both versions, so that all
+# the needed stuff is there
+. $b/extracten
+. $b/extractit
+#
+# LANGUAGE, defaults to en
+#
+if [ "$LANGUAGE" = "" ]
+then
+       export LANGUAGE=en
+fi
+#
+# for internationalization
+#
+mkdir        $s/$lang/eg/prog/$LANGUAGE
+mkdir        $s/$lang/eg/prog/$LANGUAGE/LC_MESSAGES
+export podir=$s/$lang/eg/prog/$LANGUAGE
+#
+# language: it or en, defaults to en
+#
+if [ "$lang" = "it" ]
 then
-       export lang=it
-       export LANGUAGE=it_IT.UTF-8
-       export podir=it_IT.UTF-8
        export poname=guide-it
-       export doclib=$d/cache/gawk/doc/it
-       . $b/extractit
+       export doclib=$docit
 else
-       export lang=en
-       export LANGUAGE=C.UTF-8
-       export podir=C.UTF-8
        export poname=guide-mellow
-       export doclib=$d/cache/gawk/doc
-       . $b/extracten
+       export doclib=$docen
 fi
+#
 # depending on the language...
+#
 export AWKPATH=.:$s/$lang/eg/lib:$s/$lang/eg/misc:$s/$lang/eg/prog
 export AWKLIBPATH=.:/usr/local/lib/gawk
 export datadir=$s/$lang/eg/data
 export miscdir=$s/$lang/eg/misc
+#
 # for testing po / pot -- used only for Italian
-cd $s
-cp $b/guide-it.po $lang/eg/data
-# name of directory where grcat and pwcat are
+# the English translation is available already in guide-mellow.po
+#
+cp $b/guide-it.po $s/it/eg/data
+chmod 644 $s/it/eg/data/guide-it.po
+#
+# name of a directory used as a work area
+#
 export tmplib=$s/$lang
 # name of a temporary program needed sometimes
 export testpgm=$tmplib/testpgm.awk
-# name of a temporary program needed sometimes
+# name of a temporary datafile needed sometimes
 export testdata=$tmplib/testdata.txt
-# working directory during the test
-cd $s/$lang/eg/prog
-# check that the extract.awk pgm is equal to the one from gawktexi.in
-cat extract.awk     >$testpgm
-cat ../lib/join.awk>>$testpgm
-diff $testpgm $b/extract$lang.awk
-if [ "$?" -ne 0 ]
-then
-       echo "*"
-       echo "* Beware, the extract.awk program is not the same contained in 
gawktexi.in"
-       echo "*"
-fi
 
 cd $s/$lang/eg
-list=`find . -type f|gawk -f $b/gawkeg.awk -v lang=$lang|sort`
+#
+# prepare the list of tests to perform
+#
+list=`find . -type f|gawk -f $b/egtest.awk -v s=$s -v lang=$lang|sort`
+#
+# working directory during the tests
+#
 cd $s/$lang/eg/prog
 
 while  [ true ]
 do
        # the parameter for scegli is the number of columns
-       scelta=`$b/scegli $list 4`
-        sublst=`$b/extract 1 "$scelta"`
-       #echo $sublst
-        subcmd=`$b/extract 2 "$scelta"`
-       #echo $subcmd
-       # done with
+       # real output is in $s/choice
+       gawk -f $b/choose.awk -v list="$list" -v cols=4 -v s=$s
+       choice=`cat $s/choice`
+       #echo "choice=$choice"
+        gawk -f $b/picksome.awk -v s=$s -v what=f -v choice="$choice"
+       sublst=`cat $s/sublst`
+       #echo "sublst=|$sublst|"
+        gawk -f $b/picksome.awk -v s=$s -v what=c -v choice="$choice"
+       subcmd=`cat $s/subcmd`
+       #echo "subcmd=|$subcmd|"
        if [ "$subcmd" = "q" -o "$subcmd" = "Q" -o "$subcmd" = "zz" -o 
"$subcmd" = "ZZ" -o "$subcmd" = "quit" -o "$subcmd" = "x" ]
        then
-               go_away
+               rm -rf $s
+               exit
        fi
        # browse/edit
        if [ "$subcmd" = "b" -o "$subcmd" = "e" ]
@@ -799,11 +922,12 @@ do
                #echo $sublst
                for i in $sublst
                do
-                       subrou=`echo $i|gawk -v t="true" -f ../../egidx.awk`
+                       subrou=`echo $i|gawk -v t="true" -f $s/egidx.awk`
                        basename=`basename $subrou`
-                       figlet $basename
+                       echo $basename
                        echo "*"
                        echo "* Browsing/editing $i"
+                       echo "*"
                        $vim $subrou
                        wait_go_ahead
                done
@@ -815,12 +939,12 @@ do
                #echo $sublst
                for i in $sublst
                do
-                       subrou=`echo $i|gawk -v t="true" -f ../../egidx.awk`
-                       figlet $subrou
+                       subrou=`echo $i|gawk -v t="true" -f $s/egidx.awk`
+                       echo $subrou
                        echo "*"
                        echo "* viewing differences in $i"
                        echo "*"
-                       other=`echo $i|gawk -v t="alte" -f ../../egidx.awk`
+                       other=`echo $i|gawk -v t="alte" -f $s/egidx.awk`
                        echo $subrou $other
                        ${vim}diff -c ":color blue" $subrou $other
                        wait_go_ahead
@@ -832,9 +956,9 @@ do
        then
                for i in $sublst
                do
-                       echo $i is:
-                       echo $i|gawk -v t="true" -f ../../egidx.awk
-                       echo $i|gawk -v t="alte" -f ../../egidx.awk
+                       echo "===> $i is:"
+                       echo $i|gawk -v t="true" -f $s/egidx.awk
+                       echo $i|gawk -v t="alte" -f $s/egidx.awk
                done
                wait_go_ahead
                continue
@@ -854,11 +978,10 @@ do
        for i in $sublst
        do
                subrou=`echo $i|cut -f 1 -d"."`
-               figlet $subrou
+               echo $subrou
                echo "*"
                echo "* Testing $i"
                do_$subrou
                wait_go_ahead
        done
 done
-
diff --git a/egtests/gawkeg.awk b/egtests/egtest.awk
similarity index 55%
rename from egtests/gawkeg.awk
rename to egtests/egtest.awk
index 79ec842..3844bc5 100755
--- a/egtests/gawkeg.awk
+++ b/egtests/egtest.awk
@@ -3,7 +3,9 @@
 # secondary output is another gawk program that tells the real name behind the 
"short" filename
 # lang can be "en" or "it"
 BEGIN {
-       egi="../egidx.awk"
+       # in the temporary directory
+       egi=s "/egidx.awk"
+       print "#",s >egi
        if ( lang=="en" ) { altl="it" }
        if ( lang=="it" ) { altl="en" }
        print "BEGIN { do_init() }" >egi
@@ -19,22 +21,21 @@ END { print "}" >egi }
        if ( wrk ~ ".un~"      ) { next }
        if ( wrk ~ ".swp"      ) { next }
        if ( wrk ~ ".swo"      ) { next }
-       if ( wrk ~ "guide-it"  ) { next }
+       # this is not part of the stuff to be tested,
+       # it has been prepared in advance
+       if ( wrk ~ "guide-it.po"  ) { next }
        nel=split(wrk,el,"/")
        if ( nel!=3 ) { next }
-       gsub(".data","_data",el[3])
-       gsub("-","_",el[3])
-       print el[3];
-       if ( el[2]=="prog" ) {
-               print "true[\"" el[3] "\"]=\"" el[3] "\"" >egi
-               print "alte[\"" el[3] "\"]=\"../../../" altl "/eg/prog/" el[3] 
"\"" >egi
-       } else {
-               print "true[\"" el[3] "\"]=\"." $0    "\"" >egi
-               print "alte[\"" el[3] "\"]=\"../../../" altl "/eg/" el[2] "/" 
el[3] "\"" >egi
-       }
+       wrk=el[3]
+       gsub(".data","_data",wrk)
+       gsub("-","_",wrk)
+       print wrk;
+       print "true[\"" wrk "\"]=\"" s "/" lang  "/eg/" el[2] "/" el[3] "\"" 
>egi
+       print "alte[\"" wrk "\"]=\"" s "/" altl  "/eg/" el[2] "/" el[3] "\"" 
>egi
        if ( el[3]=="gettime.awk" ) {
                print "getlocaltime"
-               print "true[\"getlocaltime\"]=\"." $0    "\"" >egi;
-               print "alte[\"getlocaltime\"]=\"../../../" altl "/eg/" el[2] 
"/" el[3] "\"" >egi
+               print "true[\"getlocaltime\"]=\"" s "/" lang  "/eg/" el[2] "/" 
el[3] "\"" >egi
+               print "alte[\"getlocaltime\"]=\"" s "/" altl  "/eg/" el[2] "/" 
el[3] "\"" >egi
        }
 }
+
diff --git a/egtests/extracten b/egtests/extracten
index 8aafe69..a75011d 100755
--- a/egtests/extracten
+++ b/egtests/extracten
@@ -3,12 +3,19 @@
 
 echo "* Extracting in $s/en from the English gawktexi.in"
 cd $s
-# for existing directory, just replace the programs, leave what is there 
already
-from=$doclib
 if [ ! -d "en" ]
 then
        mkdir en
+else
+       rm -r en
+       mkdir en
 fi
 cd en
-cp $doclib/gawktexi.in gawktexi.in
-gawk -f $b/extracten.awk gawktexi.in
+cp $docen/gawktexi.in gawktexi.en
+gawk -f $b/extracten.awk gawktexi.en
+cat $s/en/eg/prog/extract.awk $s/en/eg/lib/join.awk >$s/extract.en
+diff    $b/extracten.awk $s/extract.en
+if [ "$?" -ne "0" ]
+then
+       echo Extracten: the extract.awk script is different from the one in the 
book
+fi
diff --git a/egtests/extractit b/egtests/extractit
index 1157004..461417c 100755
--- a/egtests/extractit
+++ b/egtests/extractit
@@ -1,14 +1,21 @@
 :
 #set -xv
 
-echo "* extracting in $s/it from the Italian gawktexi.in"
+echo "* Extracting in $s/it from the Italian gawktexi.in"
 cd $s
-# for existing directory, just replace the programs, leave what is there 
already
-from=$doclib
 if [ ! -d "it" ]
 then
        mkdir it
+else
+       rm -r it
+       mkdir it
 fi
 cd it
-cp $doclib/gawktexi.in gawktexi.in
-gawk -f $b/extractit.awk gawktexi.in
+cp $docit/gawktexi.in gawktexi.it
+gawk -f $b/extractit.awk gawktexi.it
+cat $s/it/eg/prog/extract.awk $s/it/eg/lib/join.awk >$s/extract.it
+diff    $b/extractit.awk $s/extract.it
+if [ "$?" -ne "0" ]
+then
+       echo Extractit: the extract.awk script is different from the one in the 
book
+fi
diff --git a/egtests/extractit.awk b/egtests/extractit.awk
index 642c3c9..dcc7815 100755
--- a/egtests/extractit.awk
+++ b/egtests/extractit.awk
@@ -3,6 +3,7 @@
 # Arnold Robbins, arnold@skeeve.com, Public Domain
 # May 1993
 # Revised September 2000
+# Antonio Colombo, October 2020, test for Italian accented letters
 
 BEGIN    { IGNORECASE = 1 }
 
diff --git a/egtests/picksome.awk b/egtests/picksome.awk
new file mode 100755
index 0000000..9263166
--- /dev/null
+++ b/egtests/picksome.awk
@@ -0,0 +1,25 @@
+# given a list
+# display it and accept a choice from the user
+BEGIN { # input string
+       if ( choice=="" ) { msg() }
+       # directory in which to write the user choices
+       if ( s==""    )   { msg() }
+       # what to produce, list of names or command
+       if ( what=="" )   { msg() }
+       nel=split(choice,el,"%%")
+       if ( what=="f" )  {
+               print el[1]> s "/sublst"
+               exit
+       }
+       if ( what=="c" )  {
+               print el[2]> s "/subcmd"
+               exit
+       }
+       # if it gets here, something is wrong
+       msg()
+}
+
+function msg() {
+       print "picksome: invoked with wrong or missing parameters, nothing done"
+       exit(4)
+}

-----------------------------------------------------------------------

Summary of changes:
 egtests/ChangeLog                  |  12 ++
 egtests/choose.awk                 | 196 +++++++++++++++++++++
 egtests/{gawkeg => egtest}         | 343 +++++++++++++++++++++++++------------
 egtests/{gawkeg.awk => egtest.awk} |  29 ++--
 egtests/extracten                  |  15 +-
 egtests/extractit                  |  17 +-
 egtests/extractit.awk              |   1 +
 egtests/picksome.awk               |  25 +++
 8 files changed, 505 insertions(+), 133 deletions(-)
 create mode 100644 egtests/ChangeLog
 create mode 100755 egtests/choose.awk
 rename egtests/{gawkeg => egtest} (78%)
 rename egtests/{gawkeg.awk => egtest.awk} (55%)
 create mode 100755 egtests/picksome.awk


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]