Fix missing @clicksequence problem with older Texinfo versions.
[pspp-builds.git] / tests / command / get-data-txt-examples.sh
1 #!/bin/sh
2
3 # This program tests the examples for GET DATA/TYPE=TXT given in the
4 # PSPP manual.
5
6 TEMPDIR=/tmp/pspp-tst-$$
7
8 # ensure that top_builddir  are absolute
9 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 top_builddir=`cd $top_builddir; pwd`
12 PSPP=$top_builddir/src/ui/terminal/pspp
13
14 # ensure that top_srcdir is absolute
15 top_srcdir=`cd $top_srcdir; pwd`
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20 LANG=C
21 export LANG
22
23 cleanup()
24 {
25      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
26         echo "NOT cleaning $TEMPDIR" 
27         return ; 
28      fi
29      cd /
30      rm -rf $TEMPDIR
31 }
32
33
34 fail()
35 {
36     echo $activity
37     echo FAILED
38     cleanup;
39     exit 1;
40 }
41
42
43 no_result()
44 {
45     echo $activity
46     echo NO RESULT;
47     cleanup;
48     exit 2;
49 }
50
51 pass()
52 {
53     cleanup;
54     exit 0;
55 }
56
57 mkdir -p $TEMPDIR
58
59 cd $TEMPDIR
60
61 activity="create passwd.data"
62 cat > passwd.data <<'EOF'
63 root:$1$nyeSP5gD$pDq/:0:0:,,,:/root:/bin/bash
64 blp:$1$BrP/pFg4$g7OG:1000:1000:Ben Pfaff,,,:/home/blp:/bin/bash
65 john:$1$JBuq/Fioq$g4A:1001:1001:John Darrington,,,:/home/john:/bin/bash
66 jhs:$1$D3li4hPL$88X1:1002:1002:Jason Stover,,,:/home/jhs:/bin/csh
67 EOF
68 if [ $? -ne 0 ] ; then no_result ; fi
69
70 activity="create cars.data"
71 cat > cars.data <<'EOF'
72 model   year    mileage price   type    age
73 Civic   2002    29883   15900   Si      2
74 Civic   2003    13415   15900   EX      1
75 Civic   1992    107000  3800    n/a     12
76 Accord  2002    26613   17900   EX      1
77 EOF
78 if [ $? -ne 0 ] ; then no_result ; fi
79
80 activity="create pets.data"
81 cat > pets.data <<'EOF'
82 'Pet''s Name', "Age", "Color", "Date Received", "Price", "Height", "Type"
83 , (Years), , , (Dollars), ,
84 "Rover", 4.5, Brown, "12 Feb 2004", 80, '1''4"', "Dog"
85 "Charlie", , Gold, "5 Apr 2007", 12.3, "3""", "Fish"
86 "Molly", 2, Black, "12 Dec 2006", 25, '5"', "Cat"
87 "Gilly", , White, "10 Apr 2007", 10, "3""", "Guinea Pig"
88 EOF
89 if [ $? -ne 0 ] ; then no_result ; fi
90
91 activity="create test.pspp"
92 cat > test.pspp <<'EOF'
93 GET DATA /TYPE=TXT /FILE='passwd.data' /DELIMITERS=':'
94         /VARIABLES=username A20
95                    password A40
96                    uid F10
97                    gid F10
98                    gecos A40
99                    home A40
100                    shell A40.
101 LIST.
102
103 GET DATA /TYPE=TXT /FILE='cars.data' /DELIMITERS=' ' /FIRSTCASE=2
104         /VARIABLES=model A8
105                    year F4
106                    mileage F6
107                    price F5
108                    type A4
109                    age F2.
110 LIST.
111
112 GET DATA /TYPE=TXT /FILE='cars.data' /ARRANGEMENT=FIXED /FIRSTCASE=2
113         /VARIABLES=model 0-7 A
114                    year 8-15 F
115                    mileage 16-23 F
116                    price 24-31 F
117                    type 32-39 A
118                    age 40-47 F.
119 LIST.
120
121 GET DATA /TYPE=TXT /FILE='pets.data' /DELIMITERS=', ' /QUALIFIER='''"' /ESCAPE
122         /FIRSTCASE=3
123         /VARIABLES=name A10
124                    age F3.1
125                    color A5
126                    received EDATE10
127                    price F5.2
128                    height a5
129                    type a10.
130 LIST.
131 EOF
132 if [ $? -ne 0 ] ; then no_result ; fi
133
134 activity="run test"
135 $SUPERVISOR $PSPP --testing-mode test.pspp
136 if [ $? -ne 0 ] ; then no_result ; fi
137
138 activity="compare test results"
139 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
140 diff -b  $TEMPDIR/pspp.list - <<'EOF'
141             username                                 password        uid        gid                                    gecos                                     home                                    shell
142 -------------------- ---------------------------------------- ---------- ---------- ---------------------------------------- ---------------------------------------- ----------------------------------------
143 root                 $1$nyeSP5gD$pDq/                                  0          0 ,,,                                      /root                                    /bin/bash
144 blp                  $1$BrP/pFg4$g7OG                               1000       1000 Ben Pfaff,,,                             /home/blp                                /bin/bash
145 john                 $1$JBuq/Fioq$g4A                               1001       1001 John Darrington,,,                       /home/john                               /bin/bash
146 jhs                  $1$D3li4hPL$88X1                               1002       1002 Jason Stover,,,                          /home/jhs                                /bin/csh
147    model year mileage price type age
148 -------- ---- ------- ----- ---- ---
149 Civic    2002   29883 15900 Si     2
150 Civic    2003   13415 15900 EX     1
151 Civic    1992  107000  3800 n/a   12
152 Accord   2002   26613 17900 EX     1
153    model     year  mileage    price     type      age
154 -------- -------- -------- -------- -------- --------
155 Civic        2002    29883    15900 Si              2
156 Civic        2003    13415    15900 EX              1
157 Civic        1992   107000     3800 n/a            12
158 Accord       2002    26613    17900 EX              1
159       name  age color   received  price height       type
160 ---------- ---- ----- ---------- ------ ------ ----------
161 Rover       4.5 Brown 12.02.2004  80.00  1'4"  Dog
162 Charlie      .  Gold  05.04.2007  12.30  3"    Fish
163 Molly       2.0 Black 12.12.2006  25.00  5"    Cat
164 Gilly        .  White 10.04.2007  10.00  3"    Guinea Pig
165 EOF
166 if [ $? -ne 0 ] ; then fail ; fi
167
168
169
170 pass