Skip to content
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

Add xeus-cling test #69

Merged
merged 29 commits into from
Dec 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,22 @@ jobs:
- name: Base setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Setup conda ${{ matrix.PYTHON_VERSION }}
- name: Setup conda ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
environment-file: environment.yml
activate-environment: jupyter_kernel_test
python-version: ${{ matrix.python-version }}

- name: Install xeus-cling
if: startsWith(runner.os, 'Linux')
run: |
conda install -c conda-forge xeus-cling

- name: Install dependencies
run: pip install -e .[test]
run: |
pip install -e .[test]

- name: Run the tests
run: python -m unittest -v
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include *.py
include *.md
exclude setup_julia.sh
exclude environment.yml
10 changes: 6 additions & 4 deletions jupyter_kernel_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,11 @@ def test_execute_result(self):
found = True
else:
continue
self.assertIn('text/plain', msg['content']['data'])
self.assertEqual(msg['content']['data']['text/plain'],
sample['result'])
mime = sample.get('mime', 'text/plain')
self.assertIn(mime, msg['content']['data'])
if 'result' in sample:
self.assertEqual(msg['content']['data'][mime],
sample['result'])
assert found, 'execute_result message not found'

code_display_data = []
Expand Down Expand Up @@ -281,7 +283,7 @@ def test_history(self):
raise SkipTest

codes = [s['code'] for s in self.code_execute_result]
results = [s['result'] for s in self.code_execute_result]
results = [s.get('result', '') for s in self.code_execute_result]
n = len(codes)

session = start = None
Expand Down
2 changes: 1 addition & 1 deletion jupyter_kernel_test/msgspec_v5.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def validate_message(msg, msg_type=None, parent_id=None):
"text": {"type": "string"},
"url": {"type": "string"}
}}}
}, "required": ["status", "protocol_version", "implementation", "implementation_version", "language_info", "banner"]}
}, "required": ["status", "protocol_version", "implementation", "language_info", "banner"]}

schema_fragments['shutdown_request'] = {"properties": {
"restart": {"type": "boolean"},
Expand Down
43 changes: 43 additions & 0 deletions test_xues_cling.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""
A non-python example, with tests for IRKernel (irkernel.github.io).
(Beware of python quoting/string escaping rules being different to the
language being tested)
"""

import unittest
import shutil

from jupyter_client.kernelspec import NoSuchKernel
import jupyter_kernel_test as jkt


class XeusClingKernelTests(jkt.KernelTests):
kernel_name = "xcpp17"

@classmethod
def setUpClass(cls):
try:
cls.km, cls.kc = jkt.start_new_kernel(kernel_name=cls.kernel_name)
except NoSuchKernel:
raise unittest.SkipTest('Xeus-Cling Kernel not installed')

language_name = "c++"

file_extension = ".cpp"

code_hello_world = '#include <iostream>\nstd::cout << "hello, world!" << std::endl;'

code_stderr = '#include <iostream>\nstd::cerr << "some error" << std::endl;'

complete_code_samples = ['1', "int j=5"]
incomplete_code_samples = ["double sqr(double a"]

code_generate_error = 'throw std::runtime_error("Unknown exception");'

code_execute_result = [
{'code': 'int j = 5;j', 'result': "5"},
]


if __name__ == '__main__':
unittest.main()