on master help sign in
add tests for python2/python3
commit3060b457decd492df8fafb09bca6e2effcb841cc authorMason Clayton <masongclayton@gmail.com> dateWed 24 Oct 2018, 13:00 (8 years ago) parent61733f4
17 files changed+466
run_tests+24 tests/python2/1_plus_1.exp+12 tests/python2/code_print.exp+5 tests/python2/exception.exp+13 tests/python2/expr.exp+5 tests/python2/ps1.exp+12 tests/python2/ps2.exp+24 tests/python2/quiet.exp+11 tests/python2/stdout_stderr.exp+224 tests/python3/1_plus_1.exp+12 tests/python3/eval_code.exp+6 tests/python3/printing.exp+18 tests/python3/run_code.exp+6 tests/python3/set_ps1.exp+12 tests/python3/set_ps2.exp+17 tests/python3/show_header.exp+14 tests/python3/stderr_red.exp+51
run_testsnew file+24
@@ -0,0 +1,24 @@
1+#!/usr/bin/env bash
2+
3+tests=$(find ./tests -printf '%P\n')
4+
5+for t in ${tests}; do
6+ if [[ $t != *.exp ]]; then
7+ echo "$t:"
8+ continue
9+ fi
10+
11+ name=$(echo -n $t | sed -s 's/.*\/\(.*\).exp/\1/' | sed -s 's/_/ /g')
12+
13+ echo -n "... $name"
14+
15+ test_out=$(timeout 10 "./tests/$t" 2>&1)
16+ if [[ $? != 0 ]]; then
17+ echo -e "\n========== \"$t\" failed =========="
18+ echo $test_out
19+ exit 1;
20+ fi
21+
22+ echo -ne '\r'
23+ echo " ✓ $name"
24+done
tests/python2/1_plus_1.expnew file+12
@@ -0,0 +1,12 @@
1+#!/usr/bin/expect -f
2+
3+spawn ./prybar-python2 -i
4+match_max 100000
5+expect "Python 2.*"
6+expect -exact "--> "
7+send -- "1+1\r"
8+expect -exact "1+1\r
9+2\r
10+--> "
11+send -- ""
12+expect eof
tests/python2/code_print.expnew file+5
@@ -0,0 +1,5 @@
1+#!/usr/bin/expect -f
2+
3+spawn ./prybar-python2 -q -c print('hello')
4+match_max 100000
5+expect eof
tests/python2/exception.expnew file+13
@@ -0,0 +1,13 @@
1+#!/usr/bin/expect -f
2+
3+spawn ./prybar-python2 -q -i
4+match_max 100000
5+expect -exact "--> "
6+send -- "ohno\r"
7+expect -exact "ohno\r
8+Traceback (most recent call last):\r
9+ File \"<stdin>\", line 1, in <module>\r
10+NameError: name 'ohno' is not defined\r
11+--> "
12+send -- ""
13+expect eof
tests/python2/expr.expnew file+5
@@ -0,0 +1,5 @@
1+#!/usr/bin/expect -f
2+
3+spawn ./prybar-python2 -e 1+1
4+match_max 100000
5+expect eof
tests/python2/ps1.expnew file+12
@@ -0,0 +1,12 @@
1+#!/usr/bin/expect -f
2+
3+spawn ./prybar-python2 -i -ps1 somethingelse
4+match_max 100000
5+expect "Python 2.*\r"
6+expect -exact "somethingelse"
7+send -- "123\r"
8+expect -exact "123\r
9+123\r
10+somethingelse"
11+send -- ""
12+expect eof
tests/python2/ps2.expnew file+24
@@ -0,0 +1,24 @@
1+#!/usr/bin/expect -f
2+
3+spawn ./prybar-python2 -i -ps2 continuation
4+match_max 100000
5+expect "Python 2.*\r"
6+expect -exact "--> "
7+send -- "if True:\r"
8+expect -exact "if True:\r
9+continuation"
10+send -- " print('we "
11+expect -exact "\[K"
12+send -- ""
13+expect -exact "\[K"
14+send -- ""
15+expect -exact "\[K"
16+send -- "continued!')\r"
17+expect -exact "continued!')\r
18+continuation"
19+send -- ""
20+expect -exact "\r
21+continued!\r
22+--> "
23+send -- ""
24+expect eof
tests/python2/quiet.expnew file+11
@@ -0,0 +1,11 @@
1+#!/usr/bin/expect -f
2+
3+spawn ./prybar-python2 -q -i
4+match_max 100000
5+expect -exact "--> "
6+send -- "1+1\r"
7+expect -exact "1+1\r
8+2\r
9+--> "
10+send -- ""
11+expect eof
tests/python2/stdout_stderr.expnew file+224
@@ -0,0 +1,224 @@
1+#!/usr/bin/expect -f
2+
3+spawn ./prybar-python2 -q -i
4+match_max 100000
5+expect -exact "--> "
6+send -- "import sys\r"
7+expect -exact "import sys\r
8+--> "
9+send -- "for i i"
10+expect -exact "\[K"
11+send -- "in range(0, 100):\r"
12+expect -exact "in range(0, 100):\r
13+... "
14+send -- " sys.stderr.write(str(i) + '\\n')\r"
15+expect -exact " sys.stderr.write(str(i) + '\\n')\r
16+... "
17+send -- " sys.stdout.write(str(i) + '\\n')\r"
18+expect -exact " sys.stdout.write(str(i) + '\\n')\r
19+... "
20+send -- "\r"
21+expect -exact "\r
22+0\r
23+0\r
24+1\r
25+1\r
26+2\r
27+2\r
28+3\r
29+3\r
30+4\r
31+4\r
32+5\r
33+5\r
34+6\r
35+6\r
36+7\r
37+7\r
38+8\r
39+8\r
40+9\r
41+9\r
42+10\r
43+10\r
44+11\r
45+11\r
46+12\r
47+12\r
48+13\r
49+13\r
50+14\r
51+14\r
52+15\r
53+15\r
54+16\r
55+16\r
56+17\r
57+17\r
58+18\r
59+18\r
60+19\r
61+19\r
62+20\r
63+20\r
64+21\r
65+21\r
66+22\r
67+22\r
68+23\r
69+23\r
70+24\r
71+24\r
72+25\r
73+25\r
74+26\r
75+26\r
76+27\r
77+27\r
78+28\r
79+28\r
80+29\r
81+29\r
82+30\r
83+30\r
84+31\r
85+31\r
86+32\r
87+32\r
88+33\r
89+33\r
90+34\r
91+34\r
92+35\r
93+35\r
94+36\r
95+36\r
96+37\r
97+37\r
98+38\r
99+38\r
100+39\r
101+39\r
102+40\r
103+40\r
104+41\r
105+41\r
106+42\r
107+42\r
108+43\r
109+43\r
110+44\r
111+44\r
112+45\r
113+45\r
114+46\r
115+46\r
116+47\r
117+47\r
118+48\r
119+48\r
120+49\r
121+49\r
122+50\r
123+50\r
124+51\r
125+51\r
126+52\r
127+52\r
128+53\r
129+53\r
130+54\r
131+54\r
132+55\r
133+55\r
134+56\r
135+56\r
136+57\r
137+57\r
138+58\r
139+58\r
140+59\r
141+59\r
142+60\r
143+60\r
144+61\r
145+61\r
146+62\r
147+62\r
148+63\r
149+63\r
150+64\r
151+64\r
152+65\r
153+65\r
154+66\r
155+66\r
156+67\r
157+67\r
158+68\r
159+68\r
160+69\r
161+69\r
162+70\r
163+70\r
164+71\r
165+71\r
166+72\r
167+72\r
168+73\r
169+73\r
170+74\r
171+74\r
172+75\r
173+75\r
174+76\r
175+76\r
176+77\r
177+77\r
178+78\r
179+78\r
180+79\r
181+79\r
182+80\r
183+80\r
184+81\r
185+81\r
186+82\r
187+82\r
188+83\r
189+83\r
190+84\r
191+84\r
192+85\r
193+85\r
194+86\r
195+86\r
196+87\r
197+87\r
198+88\r
199+88\r
200+89\r
201+89\r
202+90\r
203+90\r
204+91\r
205+91\r
206+92\r
207+92\r
208+93\r
209+93\r
210+94\r
211+94\r
212+95\r
213+95\r
214+96\r
215+96\r
216+97\r
217+97\r
218+98\r
219+98\r
220+99\r
221+99\r
222+--> "
223+send -- ""
224+expect eof
tests/python3/1_plus_1.expnew file+12
@@ -0,0 +1,12 @@
1+#!/usr/bin/expect -f
2+
3+set timeout -1
4+spawn ./prybar-python3 -i -q
5+match_max 100000
6+expect -exact "--> "
7+send -- "1+1\r"
8+expect -exact "1+1\r
9+2\r
10+--> "
11+send -- ""
12+expect eof
tests/python3/eval_code.expnew file+6
@@ -0,0 +1,6 @@
1+#!/usr/bin/expect -f
2+
3+set timeout -1
4+spawn ./prybar-python3 -e 1+1
5+match_max 100000
6+expect eof
tests/python3/printing.expnew file+18
@@ -0,0 +1,18 @@
1+#!/usr/bin/expect -f
2+
3+set timeout -1
4+spawn ./prybar-python3 -i -q
5+match_max 100000
6+expect -exact "--> "
7+send -- "print('"
8+expect -exact "\[K"
9+send -- "'hello!')\r"
10+expect -exact "'hello!')\r
11+hello!\r
12+--> "
13+send -- "print(1+1)\r"
14+expect -exact "print(1+1)\r
15+2\r
16+--> "
17+send -- ""
18+expect eof
tests/python3/run_code.expnew file+6
@@ -0,0 +1,6 @@
1+#!/usr/bin/expect -f
2+
3+set timeout -1
4+spawn ./prybar-python3 -c print('hello')
5+match_max 100000
6+expect eof
tests/python3/set_ps1.expnew file+12
@@ -0,0 +1,12 @@
1+#!/usr/bin/expect -f
2+
3+set timeout -1
4+spawn ./prybar-python3 -i -q -ps1 custom
5+match_max 100000
6+expect -exact "custom"
7+send -- "print('hit')\r"
8+expect -exact "print('hit')\r
9+hit\r
10+custom"
11+send -- ""
12+expect eof
tests/python3/set_ps2.expnew file+17
@@ -0,0 +1,17 @@
1+#!/usr/bin/expect -f
2+
3+set timeout -1
4+spawn ./prybar-python3 -i -q -ps2 custom
5+match_max 100000
6+expect -exact "--> "
7+send -- "while False:\r"
8+expect -exact "while False:\r
9+custom"
10+send -- " pass\r"
11+expect -exact " pass\r
12+custom"
13+send -- "\r"
14+expect -exact "\r
15+--> "
16+send -- ""
17+expect eof
tests/python3/show_header.expnew file+14
@@ -0,0 +1,14 @@
1+#!/usr/bin/expect -f
2+
3+set timeout -1
4+spawn ./prybar-python3 -i
5+match_max 100000
6+expect -exact "Python 3.6.6 (default, Sep 12 2018, 18:26:19) \r
7+\[GCC 8.0.1 20180414 (experimental) \[trunk revision 259383\]\] on linux\r
8+--> "
9+send -- "1+1\r"
10+expect -exact "1+1\r
11+2\r
12+--> "
13+send -- ""
14+expect eof
tests/python3/stderr_red.expnew file+51
@@ -0,0 +1,51 @@
1+#!/usr/bin/expect -f
2+
3+# red is currently nondeterministic
4+exit 0
5+
6+spawn ./prybar-python3 -i -q -R
7+match_max 100000
8+expect -exact "--> "
9+send -- "import sys\r"
10+expect -exact "import sys\r
11+--> "
12+send -- "sys.stderr.write()\[D"
13+expect -exact ""
14+send -- "'"
15+expect -exact "')"
16+send -- "'"
17+expect -exact "')"
18+send -- "\[D"
19+expect -exact ""
20+send -- "w"
21+expect -exact "w')"
22+send -- "e"
23+expect -exact "e')"
24+send -- "e"
25+expect -exact "e')"
26+send -- "e"
27+expect -exact "e')"
28+send -- "e"
29+expect -exact "e')"
30+send -- "e"
31+expect -exact "e')"
32+send -- "e"
33+expect -exact "e')"
34+send -- "e"
35+expect -exact "e')"
36+send -- "e"
37+expect -exact "e')"
38+send -- "e"
39+expect -exact "e')"
40+send -- "e"
41+expect -exact "e')"
42+send -- "e"
43+expect -exact "e')"
44+send -- "e"
45+expect -exact "e')"
46+send -- "\\"
47+expect -exact "\\')"
48+send -- "n"
49+expect -exact "n')"
50+send -- "\r"
51+expect eof