Author: Armin Rigo <[email protected]>
Branch:
Changeset: r308:c03eaca800d4
Date: 2013-06-27 17:32 +0200
http://bitbucket.org/pypy/stmgc/changeset/c03eaca800d4/
Log: Adapt the tests to the large amount of stderr output
diff --git a/duhton/test/support.py b/duhton/test/support.py
--- a/duhton/test/support.py
+++ b/duhton/test/support.py
@@ -1,4 +1,4 @@
-import py, re
+import py, re, select
import os, subprocess
from cStringIO import StringIO
@@ -12,8 +12,21 @@
stderr = subprocess.PIPE)
popen.stdin.write(stdin)
popen.stdin.close()
- result = popen.stdout.read()
- error = popen.stderr.read()
+ #
+ result = []
+ error = []
+ owait = {popen.stdout: result, popen.stderr: error}
+ while owait:
+ iwtd, _, _ = select.select(owait.keys(), [], [])
+ for o in iwtd:
+ data = os.read(o.fileno(), 4096)
+ if data:
+ owait[o].append(data)
+ else:
+ del owait[o]
+ #
+ result = ''.join(result)
+ error = ''.join(error)
exitcode = popen.wait()
if exitcode:
raise OSError("%r failed (exit code %r)\n" % (cmdargs[0], exitcode) +
diff --git a/duhton/test/test_transaction.py b/duhton/test/test_transaction.py
--- a/duhton/test/test_transaction.py
+++ b/duhton/test/test_transaction.py
@@ -16,11 +16,11 @@
(defun g (thread n)
(set c (+ (get c) 1))
- (if (> (get c) 2000)
+ (if (> (get c) 200)
(print (quote overflow) (get c))
- (if (< n 1000)
+ (if (< n 100)
(transaction f thread (+ n 1))
- (if (< (get c) 2000)
+ (if (< (get c) 200)
(print (quote not-enough))
(print (quote ok))))))
@@ -35,17 +35,18 @@
def test_conflict_list():
for i in range(20):
+ print 'test_conflict_list', i
res = run("""
(setq lst (list 0))
(defun g (thread n)
(set lst 0 (+ (get lst 0) 1))
- (if (> (get lst 0) 2000)
+ (if (> (get lst 0) 200)
(print (quote overflow) (get lst 0))
- (if (< n 1000)
+ (if (< n 100)
(transaction f thread (+ n 1))
- (if (< (get lst 0) 2000)
+ (if (< (get lst 0) 200)
(print (quote not-enough))
(print (quote ok))))))
@@ -63,11 +64,12 @@
def test_list_length():
for i in range(20):
+ print 'test_list_length', i
res = run("""
(setq lst (list))
(defun f ()
(setq n (len lst))
- (if (< n 1000)
+ (if (< n 100)
(transaction f)
(print (quote done)))
(append lst n)
@@ -79,9 +81,10 @@
def test_list_pop():
for i in range(20):
+ print 'test_list_pop', i
res = run("""
(setq lst (list))
- (while (< (len lst) 1000)
+ (while (< (len lst) 100)
(append lst (len lst)))
(defun f ()
(if (== (len lst) 0)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit