chiark / gitweb /
Testing: Increase timeout
[cgi-auth-flexible.git] / tests / autotest
1 #!/usr/bin/expect -f
2
3 set testfile [lindex $argv 0]
4
5 set tt tests/tmp
6
7 exec rm -rf $tt
8 exec mkdir $tt
9
10 set pwd [pwd]
11
12 set env(HOME) $tt
13 set env(CAFTEST_CAF) $pwd
14 set env(TERM) vt100
15 set env(CAFTEST_NOSRCDUMP) 1
16 set env(LC_ALL) en_GB.utf-8
17
18 log_user 0
19 log_file -a $tt/expect.log
20
21 proc timeout-abort {} {
22      send_log "\r\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
23      error "aborting due to timeout"
24 }
25 set timeout 15
26
27 expect_after timeout timeout-abort
28
29 proc elog {args} {
30      set m "[list expect [lindex $args end]]"
31      puts stderr $m
32 #     send_log "\n$m\n"
33      eval expect $args
34 }
35
36 proc etxt {str} {
37      regsub -all { } $str {\W{0,3}\w?} str
38      elog -re $str
39 }
40
41 proc epage {str} {
42     etxt $str
43 }
44
45 proc dospawn {} {
46      global pwd spawn_id
47
48      spawn -nottycopy \
49      w3m -config /dev/null -o cgi_bin=$pwd/tests file:///cgi-bin/wrap/Tsuffix
50
51      epage {You need to log in}
52 }
53
54 proc fillformfield {value} {
55     send "\t\r$value\r"
56 }
57
58 proc submitform-expect {wanttxt} {
59     send "\r"
60     etxt "loading file"
61     epage $wanttxt
62 }
63
64 proc loginas {user {password sesame} {wanttxt ACCESSGRANTED}} {
65      fillformfield $user
66      fillformfield $password
67      send "\t"
68      submitform-expect $wanttxt
69 }
70
71 source $testfile
72
73 puts ok