changeset 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 32bc3815efae
children dc1ed7fe33e4
files tests/test-ssh-proto-unbundle.t tests/test-ssh.t
diffstat 2 files changed, 27 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-ssh-proto-unbundle.t	Thu May 10 21:08:32 2018 +0900
+++ b/tests/test-ssh-proto-unbundle.t	Sun Mar 25 16:39:17 2018 +0900
@@ -161,10 +161,12 @@
   > import sys
   > def hook1line(ui, repo, **kwargs):
   >     ui.write(b'ui.write 1 line\n')
+  >     ui.flush()
   >     return 1
   > def hook2lines(ui, repo, **kwargs):
   >     ui.write(b'ui.write 2 lines 1\n')
   >     ui.write(b'ui.write 2 lines 2\n')
+  >     ui.flush()
   >     return 1
   > def hook1lineflush(ui, repo, **kwargs):
   >     ui.write(b'ui.write 1 line flush\n')
@@ -181,21 +183,31 @@
   >     ui.write_err(b'ui.write_err 1\n')
   >     ui.write(b'ui.write 2\n')
   >     ui.write_err(b'ui.write_err 2\n')
+  >     ui.flush()
   >     return 1
   > def hookprintstdout(ui, repo, **kwargs):
   >     print('printed line')
+  >     sys.stdout.flush()
   >     return 1
   > def hookprintandwrite(ui, repo, **kwargs):
   >     print('print 1')
+  >     sys.stdout.flush()
   >     ui.write(b'ui.write 1\n')
+  >     ui.flush()
   >     print('print 2')
+  >     sys.stdout.flush()
   >     ui.write(b'ui.write 2\n')
+  >     ui.flush()
   >     return 1
   > def hookprintstderrandstdout(ui, repo, **kwargs):
   >     print('stdout 1')
+  >     sys.stdout.flush()
   >     print('stderr 1', file=sys.stderr)
+  >     sys.stderr.flush()
   >     print('stdout 2')
+  >     sys.stdout.flush()
   >     print('stderr 2', file=sys.stderr)
+  >     sys.stderr.flush()
   >     return 1
   > EOF
 
@@ -1046,10 +1058,10 @@
   e>     adding manifests\n
   e>     adding file changes\n
   e>     added 1 changesets with 1 changes to 1 files\n
+  e>     print 1\n
   e>     ui.write 1\n
+  e>     print 2\n
   e>     ui.write 2\n
-  e>     print 1\n
-  e>     print 2\n
   e>     transaction abort!\n
   e>     rollback completed\n
   e>     abort: pretxnchangegroup.fail hook failed\n
@@ -1106,10 +1118,10 @@
   e>     adding manifests\n
   e>     adding file changes\n
   e>     added 1 changesets with 1 changes to 1 files\n
+  e>     print 1\n
   e>     ui.write 1\n
+  e>     print 2\n
   e>     ui.write 2\n
-  e>     print 1\n
-  e>     print 2\n
   e>     transaction abort!\n
   e>     rollback completed\n
   e>     abort: pretxnchangegroup.fail hook failed\n
@@ -1180,10 +1192,10 @@
   e>     adding manifests\n
   e>     adding file changes\n
   e>     added 1 changesets with 1 changes to 1 files\n
+  e>     stdout 1\n
   e>     stderr 1\n
+  e>     stdout 2\n
   e>     stderr 2\n
-  e>     stdout 1\n
-  e>     stdout 2\n
   e>     transaction abort!\n
   e>     rollback completed\n
   e>     abort: pretxnchangegroup.fail hook failed\n
@@ -1240,10 +1252,10 @@
   e>     adding manifests\n
   e>     adding file changes\n
   e>     added 1 changesets with 1 changes to 1 files\n
+  e>     stdout 1\n
   e>     stderr 1\n
+  e>     stdout 2\n
   e>     stderr 2\n
-  e>     stdout 1\n
-  e>     stdout 2\n
   e>     transaction abort!\n
   e>     rollback completed\n
   e>     abort: pretxnchangegroup.fail hook failed\n
@@ -1731,10 +1743,10 @@
   e>     shell stderr 1\n
   e>     shell stdout 2\n
   e>     shell stderr 2\n
+  e>     stdout 1\n
   e>     stderr 1\n
+  e>     stdout 2\n
   e>     stderr 2\n
-  e>     stdout 1\n
-  e>     stdout 2\n
   e>     transaction abort!\n
   e>     rollback completed\n
   e>     abort: pretxnchangegroup.b hook failed\n
@@ -1795,10 +1807,10 @@
   e>     shell stderr 1\n
   e>     shell stdout 2\n
   e>     shell stderr 2\n
+  e>     stdout 1\n
   e>     stderr 1\n
+  e>     stdout 2\n
   e>     stderr 2\n
-  e>     stdout 1\n
-  e>     stdout 2\n
   e>     transaction abort!\n
   e>     rollback completed\n
   e>     abort: pretxnchangegroup.b hook failed\n
--- a/tests/test-ssh.t	Thu May 10 21:08:32 2018 +0900
+++ b/tests/test-ssh.t	Sun Mar 25 16:39:17 2018 +0900
@@ -272,12 +272,14 @@
   $ cat <<EOF > $TESTTMP/badhook
   > import sys
   > sys.stdout.write("KABOOM\n")
+  > sys.stdout.flush()
   > EOF
 
   $ cat <<EOF > $TESTTMP/badpyhook.py
   > import sys
   > def hook(ui, repo, hooktype, **kwargs):
   >     sys.stdout.write("KABOOM IN PROCESS\n")
+  >     sys.stdout.flush()
   > EOF
 
   $ cat <<EOF >> ../remote/.hg/hgrc
@@ -456,6 +458,7 @@
   > def wrappedpush(orig, repo, *args, **kwargs):
   >     res = orig(repo, *args, **kwargs)
   >     repo.ui.write('local stdout\n')
+  >     repo.ui.flush()
   >     return res
   > 
   > def extsetup(ui):