Mercurial > hg
comparison tests/test-ssh-proto-unbundle.t @ 37943:45a669bad421
test-ssh: add some flush() to make output deterministic
We shouldn't rely on buffering mode/state of file handles.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 25 Mar 2018 16:39:17 +0900 |
parents | 33af46d639b4 |
children | 565074cc9ac6 |
comparison
equal
deleted
inserted
replaced
37942:32bc3815efae | 37943:45a669bad421 |
---|---|
159 $ cat > $TESTTMP/failhook << EOF | 159 $ cat > $TESTTMP/failhook << EOF |
160 > from __future__ import print_function | 160 > from __future__ import print_function |
161 > import sys | 161 > import sys |
162 > def hook1line(ui, repo, **kwargs): | 162 > def hook1line(ui, repo, **kwargs): |
163 > ui.write(b'ui.write 1 line\n') | 163 > ui.write(b'ui.write 1 line\n') |
164 > ui.flush() | |
164 > return 1 | 165 > return 1 |
165 > def hook2lines(ui, repo, **kwargs): | 166 > def hook2lines(ui, repo, **kwargs): |
166 > ui.write(b'ui.write 2 lines 1\n') | 167 > ui.write(b'ui.write 2 lines 1\n') |
167 > ui.write(b'ui.write 2 lines 2\n') | 168 > ui.write(b'ui.write 2 lines 2\n') |
169 > ui.flush() | |
168 > return 1 | 170 > return 1 |
169 > def hook1lineflush(ui, repo, **kwargs): | 171 > def hook1lineflush(ui, repo, **kwargs): |
170 > ui.write(b'ui.write 1 line flush\n') | 172 > ui.write(b'ui.write 1 line flush\n') |
171 > ui.flush() | 173 > ui.flush() |
172 > return 1 | 174 > return 1 |
179 > def hookwriteandwriteerr(ui, repo, **kwargs): | 181 > def hookwriteandwriteerr(ui, repo, **kwargs): |
180 > ui.write(b'ui.write 1\n') | 182 > ui.write(b'ui.write 1\n') |
181 > ui.write_err(b'ui.write_err 1\n') | 183 > ui.write_err(b'ui.write_err 1\n') |
182 > ui.write(b'ui.write 2\n') | 184 > ui.write(b'ui.write 2\n') |
183 > ui.write_err(b'ui.write_err 2\n') | 185 > ui.write_err(b'ui.write_err 2\n') |
186 > ui.flush() | |
184 > return 1 | 187 > return 1 |
185 > def hookprintstdout(ui, repo, **kwargs): | 188 > def hookprintstdout(ui, repo, **kwargs): |
186 > print('printed line') | 189 > print('printed line') |
190 > sys.stdout.flush() | |
187 > return 1 | 191 > return 1 |
188 > def hookprintandwrite(ui, repo, **kwargs): | 192 > def hookprintandwrite(ui, repo, **kwargs): |
189 > print('print 1') | 193 > print('print 1') |
194 > sys.stdout.flush() | |
190 > ui.write(b'ui.write 1\n') | 195 > ui.write(b'ui.write 1\n') |
196 > ui.flush() | |
191 > print('print 2') | 197 > print('print 2') |
198 > sys.stdout.flush() | |
192 > ui.write(b'ui.write 2\n') | 199 > ui.write(b'ui.write 2\n') |
200 > ui.flush() | |
193 > return 1 | 201 > return 1 |
194 > def hookprintstderrandstdout(ui, repo, **kwargs): | 202 > def hookprintstderrandstdout(ui, repo, **kwargs): |
195 > print('stdout 1') | 203 > print('stdout 1') |
204 > sys.stdout.flush() | |
196 > print('stderr 1', file=sys.stderr) | 205 > print('stderr 1', file=sys.stderr) |
206 > sys.stderr.flush() | |
197 > print('stdout 2') | 207 > print('stdout 2') |
208 > sys.stdout.flush() | |
198 > print('stderr 2', file=sys.stderr) | 209 > print('stderr 2', file=sys.stderr) |
210 > sys.stderr.flush() | |
199 > return 1 | 211 > return 1 |
200 > EOF | 212 > EOF |
201 | 213 |
202 $ hg init failrepo | 214 $ hg init failrepo |
203 $ cd failrepo | 215 $ cd failrepo |
1044 e> read(-1) -> 218: | 1056 e> read(-1) -> 218: |
1045 e> adding changesets\n | 1057 e> adding changesets\n |
1046 e> adding manifests\n | 1058 e> adding manifests\n |
1047 e> adding file changes\n | 1059 e> adding file changes\n |
1048 e> added 1 changesets with 1 changes to 1 files\n | 1060 e> added 1 changesets with 1 changes to 1 files\n |
1061 e> print 1\n | |
1049 e> ui.write 1\n | 1062 e> ui.write 1\n |
1063 e> print 2\n | |
1050 e> ui.write 2\n | 1064 e> ui.write 2\n |
1051 e> print 1\n | |
1052 e> print 2\n | |
1053 e> transaction abort!\n | 1065 e> transaction abort!\n |
1054 e> rollback completed\n | 1066 e> rollback completed\n |
1055 e> abort: pretxnchangegroup.fail hook failed\n | 1067 e> abort: pretxnchangegroup.fail hook failed\n |
1056 | 1068 |
1057 testing ssh2 | 1069 testing ssh2 |
1104 e> read(-1) -> 218: | 1116 e> read(-1) -> 218: |
1105 e> adding changesets\n | 1117 e> adding changesets\n |
1106 e> adding manifests\n | 1118 e> adding manifests\n |
1107 e> adding file changes\n | 1119 e> adding file changes\n |
1108 e> added 1 changesets with 1 changes to 1 files\n | 1120 e> added 1 changesets with 1 changes to 1 files\n |
1121 e> print 1\n | |
1109 e> ui.write 1\n | 1122 e> ui.write 1\n |
1123 e> print 2\n | |
1110 e> ui.write 2\n | 1124 e> ui.write 2\n |
1111 e> print 1\n | |
1112 e> print 2\n | |
1113 e> transaction abort!\n | 1125 e> transaction abort!\n |
1114 e> rollback completed\n | 1126 e> rollback completed\n |
1115 e> abort: pretxnchangegroup.fail hook failed\n | 1127 e> abort: pretxnchangegroup.fail hook failed\n |
1116 | 1128 |
1117 print() to stdout and stderr both get captured | 1129 print() to stdout and stderr both get captured |
1178 e> read(-1) -> 216: | 1190 e> read(-1) -> 216: |
1179 e> adding changesets\n | 1191 e> adding changesets\n |
1180 e> adding manifests\n | 1192 e> adding manifests\n |
1181 e> adding file changes\n | 1193 e> adding file changes\n |
1182 e> added 1 changesets with 1 changes to 1 files\n | 1194 e> added 1 changesets with 1 changes to 1 files\n |
1195 e> stdout 1\n | |
1183 e> stderr 1\n | 1196 e> stderr 1\n |
1197 e> stdout 2\n | |
1184 e> stderr 2\n | 1198 e> stderr 2\n |
1185 e> stdout 1\n | |
1186 e> stdout 2\n | |
1187 e> transaction abort!\n | 1199 e> transaction abort!\n |
1188 e> rollback completed\n | 1200 e> rollback completed\n |
1189 e> abort: pretxnchangegroup.fail hook failed\n | 1201 e> abort: pretxnchangegroup.fail hook failed\n |
1190 | 1202 |
1191 testing ssh2 | 1203 testing ssh2 |
1238 e> read(-1) -> 216: | 1250 e> read(-1) -> 216: |
1239 e> adding changesets\n | 1251 e> adding changesets\n |
1240 e> adding manifests\n | 1252 e> adding manifests\n |
1241 e> adding file changes\n | 1253 e> adding file changes\n |
1242 e> added 1 changesets with 1 changes to 1 files\n | 1254 e> added 1 changesets with 1 changes to 1 files\n |
1255 e> stdout 1\n | |
1243 e> stderr 1\n | 1256 e> stderr 1\n |
1257 e> stdout 2\n | |
1244 e> stderr 2\n | 1258 e> stderr 2\n |
1245 e> stdout 1\n | |
1246 e> stdout 2\n | |
1247 e> transaction abort!\n | 1259 e> transaction abort!\n |
1248 e> rollback completed\n | 1260 e> rollback completed\n |
1249 e> abort: pretxnchangegroup.fail hook failed\n | 1261 e> abort: pretxnchangegroup.fail hook failed\n |
1250 | 1262 |
1251 Shell hook writing to stdout has output captured | 1263 Shell hook writing to stdout has output captured |
1729 e> added 1 changesets with 1 changes to 1 files\n | 1741 e> added 1 changesets with 1 changes to 1 files\n |
1730 e> shell stdout 1\n | 1742 e> shell stdout 1\n |
1731 e> shell stderr 1\n | 1743 e> shell stderr 1\n |
1732 e> shell stdout 2\n | 1744 e> shell stdout 2\n |
1733 e> shell stderr 2\n | 1745 e> shell stderr 2\n |
1746 e> stdout 1\n | |
1734 e> stderr 1\n | 1747 e> stderr 1\n |
1748 e> stdout 2\n | |
1735 e> stderr 2\n | 1749 e> stderr 2\n |
1736 e> stdout 1\n | |
1737 e> stdout 2\n | |
1738 e> transaction abort!\n | 1750 e> transaction abort!\n |
1739 e> rollback completed\n | 1751 e> rollback completed\n |
1740 e> abort: pretxnchangegroup.b hook failed\n | 1752 e> abort: pretxnchangegroup.b hook failed\n |
1741 | 1753 |
1742 testing ssh2 | 1754 testing ssh2 |
1793 e> added 1 changesets with 1 changes to 1 files\n | 1805 e> added 1 changesets with 1 changes to 1 files\n |
1794 e> shell stdout 1\n | 1806 e> shell stdout 1\n |
1795 e> shell stderr 1\n | 1807 e> shell stderr 1\n |
1796 e> shell stdout 2\n | 1808 e> shell stdout 2\n |
1797 e> shell stderr 2\n | 1809 e> shell stderr 2\n |
1810 e> stdout 1\n | |
1798 e> stderr 1\n | 1811 e> stderr 1\n |
1812 e> stdout 2\n | |
1799 e> stderr 2\n | 1813 e> stderr 2\n |
1800 e> stdout 1\n | |
1801 e> stdout 2\n | |
1802 e> transaction abort!\n | 1814 e> transaction abort!\n |
1803 e> rollback completed\n | 1815 e> rollback completed\n |
1804 e> abort: pretxnchangegroup.b hook failed\n | 1816 e> abort: pretxnchangegroup.b hook failed\n |
1805 | 1817 |
1806 $ cd .. | 1818 $ cd .. |