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

Fix it so jupyter_kernel_test runs without error on Windows #92

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
36f4c1f
Fix Windows tests
mcbarton May 13, 2024
504b9fd
Attempt to fix a few tests Windows
mcbarton May 13, 2024
b42cf26
Windows test check
mcbarton May 13, 2024
8f57535
Update kernel.json.in
mcbarton May 13, 2024
732a0af
Revert
mcbarton May 13, 2024
a02cb32
Attempt to fix XCppTests2
mcbarton May 13, 2024
5fe1df3
Try to fix test for Windows (expected to fail Unix)
mcbarton May 13, 2024
fd14ae7
Fix
mcbarton May 13, 2024
d65c9a7
test
mcbarton May 13, 2024
f376788
Revert changes
mcbarton May 13, 2024
990a512
Don't rerun Windows
mcbarton May 13, 2024
dfa9091
Fix codecomplete test Windows
mcbarton May 13, 2024
93cd495
Fix
mcbarton May 13, 2024
0142361
debug
mcbarton May 13, 2024
f0730ee
Update kernel.json.in
mcbarton May 13, 2024
c8816f4
Update kernel.json.in
mcbarton May 13, 2024
21a8631
Merge branch 'main' into Fix-Windows-tests
mcbarton May 13, 2024
ee9f93d
Update CMakeLists.txt
mcbarton May 13, 2024
fe5c764
Update test_xcpp_kernel.py
mcbarton May 13, 2024
65e5b0f
Update test_xcpp_kernel.py
mcbarton May 13, 2024
f1a255a
Update test_xcpp_kernel.py
mcbarton May 13, 2024
12046fa
Update test_xcpp_kernel.py
mcbarton May 13, 2024
18c4ad4
Update test_xcpp_kernel.py
mcbarton May 13, 2024
fa5869d
Update test_xcpp_kernel.py
mcbarton May 13, 2024
66a52d5
Update test_xcpp_kernel.py
mcbarton May 13, 2024
9a1663c
Update test_xcpp_kernel.py
mcbarton May 13, 2024
f046802
Update test_xcpp_kernel.py
mcbarton May 13, 2024
a2f5005
Update test_xcpp_kernel.py
mcbarton May 13, 2024
0fafa6c
Update test_xcpp_kernel.py
mcbarton May 13, 2024
70a597e
Update test_xcpp_kernel.py
mcbarton May 13, 2024
6b759ac
Update test_xcpp_kernel.py
mcbarton May 13, 2024
36c025f
Update test_xcpp_kernel.py
mcbarton May 13, 2024
bac6afa
Update test_xcpp_kernel.py
mcbarton May 13, 2024
03f8a14
Update test_xcpp_kernel.py
mcbarton May 13, 2024
951918f
Update test_xcpp_kernel.py
mcbarton May 13, 2024
777322e
Update test_xcpp_kernel.py
mcbarton May 13, 2024
ad4b4af
Disable failing Windows tests.
mcbarton May 14, 2024
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
20 changes: 18 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,36 @@ jobs:
cd build
make install -j ${{ env.ncpus }}

- name: Test xeus-cpp C++
- name: Test xeus-cpp C++ Unix Systems
if: ${{ runner.os != 'windows' }}
shell: bash -l {0}
run: |
cd build/test
./test_xeus_cpp
timeout-minutes: 4

- name: test
- name: Test xeus-cpp C++ Windows Systems
if: ${{ runner.os == 'windows' }}
shell: cmd /C call {0}
run: |
call C:\Users\runneradmin\micromamba-root\condabin\micromamba.bat activate xeus-cpp
cd build\test
.\test_xeus_cpp.exe

- name: Python tests Unix Systems
if: ${{ runner.os != 'windows' }}
shell: bash -l {0}
run: |
cd test
pytest -sv . --reruns 5

- name: Python tests Windows Systems
if: ${{ runner.os == 'windows' }}
shell: cmd /C call {0}
run: |
call C:\Users\runneradmin\micromamba-root\condabin\micromamba.bat activate xeus-cpp
cd test
pytest -sv test_xcpp_kernel.py

- name: Prepare code coverage report
if: ${{ success() && (matrix.coverage == true) }}
Expand Down
34 changes: 22 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,30 +130,40 @@ function(configure_kernel kernel)
set(XEUS_CPP_PATH "$ENV{PATH}")
set(XEUS_CPP_LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}")
set(XEUS_CPP_RESOURCE_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/clang/${CPPINTEROP_LLVM_VERSION_MAJOR})
set(XEUS_CPP_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)

if (WIN32)
string(REPLACE "\\" "/" kernel "${kernel}")
string(REPLACE "\\" "/" XEUS_CPP_PATH "${XEUS_CPP_PATH}")
string(REPLACE "\\" "/" XEUS_CPP_LD_LIBRARY_PATH "${XEUS_CPP_LD_LIBRARY_PATH}")
string(REPLACE "\\" "/" XEUS_CPP_RESOURCE_DIR "${XEUS_CPP_RESOURCE_DIR}")
string(REPLACE "\\" "/" XEUS_CPP_INCLUDE_DIR "${XEUS_CPP_INCLUDE_DIR}")
endif()

configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/${kernel}/kernel.json.in"
"${CMAKE_CURRENT_BINARY_DIR}/${kernel}/kernel.json")
"${CMAKE_CURRENT_SOURCE_DIR}${kernel}kernel.json.in"
"${CMAKE_CURRENT_BINARY_DIR}${kernel}kernel.json")

configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/${kernel}/logo-32x32.png"
"${CMAKE_CURRENT_BINARY_DIR}/${kernel}/"
"${CMAKE_CURRENT_SOURCE_DIR}${kernel}logo-32x32.png"
"${CMAKE_CURRENT_BINARY_DIR}${kernel}"
COPYONLY)
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/${kernel}/logo-64x64.png"
"${CMAKE_CURRENT_BINARY_DIR}/${kernel}/"
"${CMAKE_CURRENT_SOURCE_DIR}${kernel}logo-64x64.png"
"${CMAKE_CURRENT_BINARY_DIR}${kernel}"
COPYONLY)
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/${kernel}/logo-svg.svg"
"${CMAKE_CURRENT_BINARY_DIR}/${kernel}/"
"${CMAKE_CURRENT_SOURCE_DIR}${kernel}logo-svg.svg"
"${CMAKE_CURRENT_BINARY_DIR}${kernel}"
COPYONLY)
endfunction()

message("Configure kernels: ...")
configure_kernel("share/jupyter/kernels/xcpp11")
configure_kernel("share/jupyter/kernels/xcpp14")
configure_kernel("share/jupyter/kernels/xcpp17")
configure_kernel("share/jupyter/kernels/xcpp20")

configure_kernel("/share/jupyter/kernels/xcpp11/")
configure_kernel("/share/jupyter/kernels/xcpp14/")
configure_kernel("/share/jupyter/kernels/xcpp17/")
configure_kernel("/share/jupyter/kernels/xcpp20/")

# Source files
# ============
Expand Down
2 changes: 1 addition & 1 deletion environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ dependencies:
- jupyter_kernel_test>=0.4.3
- nbval
- pytest-rerunfailures
- doctest
- doctest
1 change: 1 addition & 0 deletions share/jupyter/kernels/xcpp11/kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"-f",
"{connection_file}",
"-resource-dir", "@XEUS_CPP_RESOURCE_DIR@",
"-I", "@XEUS_CPP_INCLUDE_DIR@",
"-std=c++11"@XEUS_CPP_OMP@
],
"language": "cpp",
Expand Down
2 changes: 1 addition & 1 deletion share/jupyter/kernels/xcpp14/kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"-f",
"{connection_file}",
"-resource-dir", "@XEUS_CPP_RESOURCE_DIR@",
"-I", "@CMAKE_INSTALL_PREFIX@/include",
"-I", "@XEUS_CPP_INCLUDE_DIR@",
"-std=c++14",
"-fno-exceptions",
"-O2",
Expand Down
2 changes: 1 addition & 1 deletion share/jupyter/kernels/xcpp17-omp/kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"-f",
"{connection_file}",
"-resource-dir", "@XEUS_CPP_RESOURCE_DIR@",
"-I", "@CMAKE_INSTALL_PREFIX@/include",
"-I", "@XEUS_CPP_INCLUDE_DIR@",
"-std=c++17"@XEUS_CPP_OMP@
],
"language": "cpp",
Expand Down
2 changes: 1 addition & 1 deletion share/jupyter/kernels/xcpp17/kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"-f",
"{connection_file}",
"-resource-dir", "@XEUS_CPP_RESOURCE_DIR@",
"-I", "@CMAKE_INSTALL_PREFIX@/include",
"-I", "@XEUS_CPP_INCLUDE_DIR@",
"-std=c++17"@XEUS_CPP_OMP@
],
"language": "cpp",
Expand Down
2 changes: 1 addition & 1 deletion share/jupyter/kernels/xcpp20/kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"-f",
"{connection_file}",
"-resource-dir", "@XEUS_CPP_RESOURCE_DIR@",
"-I", "@CMAKE_INSTALL_PREFIX@/include",
"-I", "@XEUS_CPP_INCLUDE_DIR@",
"-std=c++20"@XEUS_CPP_OMP@
],
"language": "cpp",
Expand Down
132 changes: 68 additions & 64 deletions test/test_xcpp_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ def test_codecomplete(self) -> None:
reply = self.get_non_kernel_info_reply(timeout=1)
assert reply is not None
self.assertEqual(reply["msg_type"], "complete_reply")
self.assertEqual(str(reply["content"]["matches"]), "['float', 'foo']")
if platform.system() == 'Windows':
self.assertEqual(str(reply["content"]["matches"]), "['fabs', 'fabsf', 'fabsl', 'float', 'foo']")
else:
self.assertEqual(str(reply["content"]["matches"]), "['float', 'foo']")
self.assertEqual(reply["content"]["status"], "ok")

# Continuation
Expand Down Expand Up @@ -64,69 +67,70 @@ def test_continuation(self) -> None:
self.assertEqual(reply["content"]["status"], "complete")


class XCppTests(jupyter_kernel_test.KernelTests):

kernel_name = 'xcpp20'

# language_info.name in a kernel_info_reply should match this
language_name = 'C++'

# Code that should write the exact string `hello, world` to STDOUT
code_hello_world = '#include <iostream>\nstd::cout << "hello, world" << std::endl;'

# Code that should cause (any) text to be written to STDERR
code_stderr = '#include <iostream>\nstd::cerr << "oops" << std::endl;'

# Pager: code that should display something (anything) in the pager
code_page_something = "?std::vector"

# Exception throwing
# TODO: Remove 'if' when test work on MacOS/arm64. Throw Exceptions make
# kernel/test non-workable.
###code_generate_error = 'throw std::runtime_error("Unknown exception");' if platform.system() != "Darwin" or platform.processor() != 'arm' else ''

# Samples of code which generate a result value (ie, some text
# displayed as Out[n])
#code_execute_result = [
# {
# 'code': '6 * 7',
# 'result': '42'
# }
#]

# Samples of code which should generate a rich display output, and
# the expected MIME type
code_display_data = [
{
'code': '#include <string>\n#include "xcpp/xdisplay.hpp"\nstd::string test("foobar");\nxcpp::display(test);',
'mime': 'text/plain'
},
{
'code': """
#include <string>
#include <fstream>
#include "nlohmann/json.hpp"
#include "xtl/xbase64.hpp"
namespace im {
struct image {
inline image(const std::string& filename) {
std::ifstream fin(filename, std::ios::binary);
m_buffer << fin.rdbuf();
}
std::stringstream m_buffer;
};
nlohmann::json mime_bundle_repr(const image& i) {
auto bundle = nlohmann::json::object();
bundle["image/png"] = xtl::base64encode(i.m_buffer.str());
return bundle;
}
}
#include "xcpp/xdisplay.hpp"
im::image marie("../notebooks/images/marie.png");
xcpp::display(marie);""",
'mime': 'image/png'
if platform.system() != 'Windows':
class XCppTests(jupyter_kernel_test.KernelTests):

kernel_name = 'xcpp20'

# language_info.name in a kernel_info_reply should match this
language_name = 'C++'

# Code that should write the exact string `hello, world` to STDOUT
code_hello_world = '#include <iostream>\nstd::cout << "hello, world" << std::endl;'

# Code that should cause (any) text to be written to STDERR
code_stderr = '#include <iostream>\nstd::cerr << "oops" << std::endl;'

# Pager: code that should display something (anything) in the pager
code_page_something = "?std::vector"

# Exception throwing
# TODO: Remove 'if' when test work on MacOS/arm64. Throw Exceptions make
# kernel/test non-workable.
###code_generate_error = 'throw std::runtime_error("Unknown exception");' if platform.system() != "Darwin" or platform.processor() != 'arm' else ''

# Samples of code which generate a result value (ie, some text
# displayed as Out[n])
#code_execute_result = [
# {
# 'code': '6 * 7',
# 'result': '42'
# }
#]

# Samples of code which should generate a rich display output, and
# the expected MIME type
code_display_data = [
{
'code': '#include <string>\n#include "xcpp/xdisplay.hpp"\nstd::string test("foobar");\nxcpp::display(test);',
'mime': 'text/plain'
},
{
'code': """
#include <string>
#include <fstream>
#include "nlohmann/json.hpp"
#include "xtl/xbase64.hpp"
namespace im {
struct image {
inline image(const std::string& filename) {
std::ifstream fin(filename, std::ios::binary);
m_buffer << fin.rdbuf();
}
]
std::stringstream m_buffer;
};
nlohmann::json mime_bundle_repr(const image& i) {
auto bundle = nlohmann::json::object();
bundle["image/png"] = xtl::base64encode(i.m_buffer.str());
return bundle;
}
}
#include "xcpp/xdisplay.hpp"
im::image marie("../notebooks/images/marie.png");
xcpp::display(marie);""",
'mime': 'image/png'
}
]


class XCppTests2(jupyter_kernel_test.KernelTests):
Expand All @@ -141,4 +145,4 @@ class XCppTests2(jupyter_kernel_test.KernelTests):


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