Skip to content

Commit

Permalink
Fix tests and docs on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
coretl committed May 17, 2021
1 parent 48908ea commit 7238690
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
with:
# require all of history to see all tagged versions' docs
fetch-depth: 0
submodules: true

- name: Set up Python
uses: actions/setup-python@v2
Expand Down
2 changes: 2 additions & 0 deletions tests/sim_asyncio_ioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
async def callback(value):
await asyncio.sleep(0.5)
print("async update %s" % value)
# Make sure it goes as epicsExit will not flush this for us
sys.stdout.flush()
sim_records.t_ai.set(value)

t_ao = builder.aOut('AO2', initial_value=12.45, on_update=callback)
Expand Down
11 changes: 7 additions & 4 deletions tests/test_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def asyncio_ioc():
sim_ioc = os.path.join(os.path.dirname(__file__), "sim_asyncio_ioc.py")
cmd = [sys.executable, sim_ioc, PV_PREFIX]
proc = subprocess.Popen(
cmd, env=dict(os.environ, PYTHONUNBUFFERED="1"),
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
cmd, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
yield proc
proc.kill()
out, err = proc.communicate()
Expand All @@ -42,11 +42,14 @@ async def test_asyncio_ioc(asyncio_ioc):
# AO
assert await caget(PV_PREFIX + ":AO2") == 12.45
await caput(PV_PREFIX + ":AO2", 3.56, wait=True)
await asyncio.sleep(0.3)
assert await caget(PV_PREFIX + ":AI") == 12.34
await asyncio.sleep(0.6)
await asyncio.sleep(0.5)
assert await caget(PV_PREFIX + ":AI") == 3.56
# Wait for a bit longer for the print output to flush
await asyncio.sleep(2)
# Stop
out, err = asyncio_ioc.communicate(b"exit\n", timeout=1)
out, err = asyncio_ioc.communicate(b"exit\n", timeout=5)
out = out.decode()
err = err.decode()
# Disconnect
Expand Down

0 comments on commit 7238690

Please sign in to comment.