-
Notifications
You must be signed in to change notification settings - Fork 9
Changes required for integration into tickit simulation framework #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8b71667
Make sure we use epicscorelibs libca in cothread
coretl 6f0fe54
Allow AsyncioDispatcher to take existing event loop
coretl c33d49f
Add ability to add arbitrary lines to Db file and test
coretl df90f39
Move test fixtures around to avoid imports
coretl 8b868eb
Make tests work on windows
coretl 8158b5d
Switch to tempfile + dbLoadRecords as a strategy
coretl b2cbcff
Skip test that doesn't work on MacOS
coretl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,67 @@ | ||
| import atexit | ||
| import os | ||
| import random | ||
| import string | ||
| import subprocess | ||
| import sys | ||
|
|
||
| import pytest | ||
|
|
||
| if sys.version_info < (3,): | ||
| # Python2 has no asyncio, so ignore these tests | ||
| collect_ignore = ["test_asyncio.py", "sim_asyncio_ioc.py"] | ||
| collect_ignore = [ | ||
| "test_asyncio.py", "sim_asyncio_ioc.py", "sim_asyncio_ioc_override.py" | ||
| ] | ||
|
|
||
| class SubprocessIOC: | ||
| def __init__(self, ioc_py): | ||
| self.pv_prefix = "".join( | ||
| random.choice(string.ascii_uppercase) for _ in range(12) | ||
| ) | ||
| sim_ioc = os.path.join(os.path.dirname(__file__), ioc_py) | ||
| cmd = [sys.executable, sim_ioc, self.pv_prefix] | ||
| self.proc = subprocess.Popen( | ||
| cmd, stdin=subprocess.PIPE, | ||
| stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
|
|
||
| def kill(self): | ||
| if self.proc.returncode is None: | ||
| # still running, kill it and print the output | ||
| self.proc.kill() | ||
| out, err = self.proc.communicate() | ||
| print(out.decode()) | ||
| print(err.decode()) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def cothread_ioc(): | ||
| ioc = SubprocessIOC("sim_cothread_ioc.py") | ||
| yield ioc | ||
| ioc.kill() | ||
|
|
||
|
|
||
| def aioca_cleanup(): | ||
| from aioca import purge_channel_caches, _catools | ||
| # Unregister the aioca atexit handler as it conflicts with the one installed | ||
| # by cothread. If we don't do this we get a seg fault. This is not a problem | ||
| # in production as we won't mix aioca and cothread, but we do mix them in | ||
| # the tests so need to do this. | ||
| atexit.unregister(_catools._catools_atexit) | ||
| # purge the channels before the event loop goes | ||
| purge_channel_caches() | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def asyncio_ioc(): | ||
| ioc = SubprocessIOC("sim_asyncio_ioc.py") | ||
| yield ioc | ||
| ioc.kill() | ||
| aioca_cleanup() | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def asyncio_ioc_override(): | ||
| ioc = SubprocessIOC("sim_asyncio_ioc_override.py") | ||
| yield ioc | ||
| ioc.kill() | ||
| aioca_cleanup() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.