mirror of
https://github.com/markqvist/rnsh.git
synced 2025-06-19 19:44:16 -04:00
Test improvements
This commit is contained in:
parent
2b3089ddd5
commit
1f31307307
3 changed files with 24 additions and 11 deletions
|
@ -1,4 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
|
import time
|
||||||
import types
|
import types
|
||||||
import typing
|
import typing
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@ -147,4 +148,16 @@ def test_config_and_cleanup():
|
||||||
assert filedata.index("acehoss test config") > 0
|
assert filedata.index("acehoss test config") > 0
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
filedata.index("22222")
|
filedata.index("22222")
|
||||||
assert not os.path.exists(os.path.join(td, "config"))
|
assert not os.path.exists(os.path.join(td, "config"))
|
||||||
|
|
||||||
|
|
||||||
|
def wait_for_condition(condition: callable, timeout: float):
|
||||||
|
tm = time.time() + timeout
|
||||||
|
while tm > time.time() and not condition():
|
||||||
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
|
||||||
|
async def wait_for_condition_async(condition: callable, timeout: float):
|
||||||
|
tm = time.time() + timeout
|
||||||
|
while tm > time.time() and not condition():
|
||||||
|
await asyncio.sleep(0.01)
|
|
@ -8,7 +8,7 @@ import multiprocessing.pool
|
||||||
logging.getLogger().setLevel(logging.DEBUG)
|
logging.getLogger().setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
|
||||||
# @pytest.mark.skip_ci
|
@pytest.mark.skip_ci
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_echo():
|
async def test_echo():
|
||||||
"""
|
"""
|
||||||
|
@ -30,7 +30,7 @@ async def test_echo():
|
||||||
assert not state.process.running
|
assert not state.process.running
|
||||||
|
|
||||||
|
|
||||||
# @pytest.mark.skip_ci
|
@pytest.mark.skip_ci
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_echo_live():
|
async def test_echo_live():
|
||||||
"""
|
"""
|
||||||
|
@ -52,7 +52,7 @@ async def test_echo_live():
|
||||||
assert not state.process.running
|
assert not state.process.running
|
||||||
|
|
||||||
|
|
||||||
# @pytest.mark.skip_ci
|
@pytest.mark.skip_ci
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_echo_live_pipe_in():
|
async def test_echo_live_pipe_in():
|
||||||
"""
|
"""
|
||||||
|
@ -74,7 +74,7 @@ async def test_echo_live_pipe_in():
|
||||||
assert not state.process.running
|
assert not state.process.running
|
||||||
|
|
||||||
|
|
||||||
# @pytest.mark.skip_ci
|
@pytest.mark.skip_ci
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_echo_live_pipe_out():
|
async def test_echo_live_pipe_out():
|
||||||
"""
|
"""
|
||||||
|
@ -99,7 +99,7 @@ async def test_echo_live_pipe_out():
|
||||||
assert not state.process.running
|
assert not state.process.running
|
||||||
|
|
||||||
|
|
||||||
# @pytest.mark.skip_ci
|
@pytest.mark.skip_ci
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_echo_live_pipe_err():
|
async def test_echo_live_pipe_err():
|
||||||
"""
|
"""
|
||||||
|
@ -121,7 +121,7 @@ async def test_echo_live_pipe_err():
|
||||||
assert not state.process.running
|
assert not state.process.running
|
||||||
|
|
||||||
|
|
||||||
# @pytest.mark.skip_ci
|
@pytest.mark.skip_ci
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_echo_live_pipe_out_err():
|
async def test_echo_live_pipe_out_err():
|
||||||
"""
|
"""
|
||||||
|
@ -147,7 +147,7 @@ async def test_echo_live_pipe_out_err():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# @pytest.mark.skip_ci
|
@pytest.mark.skip_ci
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_echo_live_pipe_all():
|
async def test_echo_live_pipe_all():
|
||||||
"""
|
"""
|
||||||
|
@ -170,7 +170,7 @@ async def test_echo_live_pipe_all():
|
||||||
assert not state.process.running
|
assert not state.process.running
|
||||||
|
|
||||||
|
|
||||||
# @pytest.mark.skip_ci
|
@pytest.mark.skip_ci
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_double_echo_live():
|
async def test_double_echo_live():
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -62,7 +62,8 @@ async def get_id_and_dest(td: str) -> tuple[str, str]:
|
||||||
await asyncio.sleep(0.1)
|
await asyncio.sleep(0.1)
|
||||||
assert wrapper.process.running
|
assert wrapper.process.running
|
||||||
# wait for process to start up
|
# wait for process to start up
|
||||||
await asyncio.sleep(3)
|
await tests.helpers.wait_for_condition_async(lambda: not wrapper.process.running, 5)
|
||||||
|
assert not wrapper.process.running
|
||||||
# read the output
|
# read the output
|
||||||
text = wrapper.read().decode("utf-8").replace("\r", "").replace("\n", "")
|
text = wrapper.read().decode("utf-8").replace("\r", "").replace("\n", "")
|
||||||
assert text.index("Identity") is not None
|
assert text.index("Identity") is not None
|
||||||
|
@ -73,7 +74,6 @@ async def get_id_and_dest(td: str) -> tuple[str, str]:
|
||||||
dh = match.group(2)
|
dh = match.group(2)
|
||||||
assert len(dh) == 32
|
assert len(dh) == 32
|
||||||
await asyncio.sleep(0.1)
|
await asyncio.sleep(0.1)
|
||||||
assert not wrapper.process.running
|
|
||||||
return ih, dh
|
return ih, dh
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue