mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-10-08 01:40:31 +00:00
Fix log_call test to not give random outcomes.
We shouldn't play around with the carriage return char, seems like using that together with readline gives undefined results (wrt ordering).
This commit is contained in:
parent
f1994fab1e
commit
6302d5d962
2 changed files with 14 additions and 12 deletions
|
@ -6,9 +6,9 @@
|
|||
#
|
||||
# (cat <<EOF
|
||||
# 2 1 one\\\\n
|
||||
# 1 2 two\\\\n
|
||||
# 1 5 four
|
||||
# 1 6 \\\\rNo, three..\\\\n
|
||||
# 1 1 two\\\\n
|
||||
# 1 3 four
|
||||
# 1 1 \\\\rNo, three..\\\\n
|
||||
# EOF
|
||||
# ) | ./subprocess.sh
|
||||
#
|
||||
|
@ -24,6 +24,7 @@ while read line; do
|
|||
rest=${line#* *}
|
||||
delay=${rest%% *}
|
||||
message=${rest#* }
|
||||
eval "sleep $delay; printf \"$message\" >&$stream" &
|
||||
sleep $delay
|
||||
printf "$message" >&$stream
|
||||
done
|
||||
wait
|
||||
|
|
|
@ -21,19 +21,20 @@ def setup_logger():
|
|||
def test_log_call_output_order():
|
||||
logged = setup_logger()
|
||||
fixture = """
|
||||
2 0.1 one\\\\n
|
||||
1 0.2 two\\\\n
|
||||
1 0.5 four
|
||||
2 0.6 \\\\rNo, three..
|
||||
1 0.8 \\\\rthree
|
||||
2 0.00 one\\\\n
|
||||
1 0.02 two\\\\n
|
||||
1 0.02 four\\\\n
|
||||
2 0.02 No, three..\\\\n
|
||||
1 0.02 three\\\\n
|
||||
"""
|
||||
status, stdout, stderr = log_call([subprocess_path], stdin=fixture)
|
||||
eq_(status, 0)
|
||||
eq_(stderr, ['one', 'No, three..'])
|
||||
eq_(stdout, ['two', 'four\rthree'])
|
||||
eq_(stdout, ['two', 'four', 'three'])
|
||||
expected_order = ['one',
|
||||
'two',
|
||||
'four\rthree',
|
||||
'four',
|
||||
'No, three..',
|
||||
'three',
|
||||
]
|
||||
eq_(logged.getvalue().split("\n")[8:-1], expected_order)
|
||||
eq_(expected_order, logged.getvalue().split("\n")[8:-1])
|
||||
|
|
Loading…
Add table
Reference in a new issue