Skip to content

Commit 3149457

Browse files
committed
Attempt to fix failing Windows XCppTests
1 parent 33ad76a commit 3149457

File tree

1 file changed

+81
-1
lines changed

1 file changed

+81
-1
lines changed

test/test_xcpp_kernel.py

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,91 @@ class XCppTests(jupyter_kernel_test.KernelTests):
127127
}
128128
#include "xcpp/xdisplay.hpp"
129129
im::image marie("../notebooks/images/marie.png");
130-
xcpp::display(marie);""",
130+
xcpp::display(marie);
131+
""",
131132
'mime': 'image/png'
132133
}
133134
]
134135

136+
if platform.system() == 'Windows':
137+
class XCppTests(jupyter_kernel_test.KernelTests):
138+
139+
kernel_name = 'xcpp20'
140+
141+
# language_info.name in a kernel_info_reply should match this
142+
language_name = 'C++'
143+
144+
# Code that should write the exact string `hello, world` to STDOUT
145+
code_hello_world = """
146+
#include "stdafx.h"
147+
#include <iostream>
148+
std::cout << "hello, world" << std::endl;
149+
"""
150+
151+
# Code that should cause (any) text to be written to STDERR
152+
code_stderr = """
153+
#include "stdafx.h"
154+
#include <iostream>
155+
std::cerr << "oops" << std::endl;"""
156+
157+
# Pager: code that should display something (anything) in the pager
158+
code_page_something = "?std::vector"
159+
160+
# Exception throwing
161+
# TODO: Remove 'if' when test work on MacOS/arm64. Throw Exceptions make
162+
# kernel/test non-workable.
163+
###code_generate_error = 'throw std::runtime_error("Unknown exception");' if platform.system() != "Darwin" or platform.processor() != 'arm' else ''
164+
165+
# Samples of code which generate a result value (ie, some text
166+
# displayed as Out[n])
167+
#code_execute_result = [
168+
# {
169+
# 'code': '6 * 7',
170+
# 'result': '42'
171+
# }
172+
#]
173+
174+
# Samples of code which should generate a rich display output, and
175+
# the expected MIME type
176+
code_display_data = [
177+
{
178+
'code': """
179+
#include "stdafx.h"
180+
#include <string>
181+
#include "xcpp/xdisplay.hpp"
182+
std::string test("foobar");
183+
xcpp::display(test);
184+
""",
185+
'mime': 'text/plain'
186+
},
187+
{
188+
'code': """
189+
#include "stdafx.h"
190+
#include <string>
191+
#include <fstream>
192+
#include "nlohmann/json.hpp"
193+
#include "xtl/xbase64.hpp"
194+
namespace im {
195+
struct image {
196+
inline image(const std::string& filename) {
197+
std::ifstream fin(filename, std::ios::binary);
198+
m_buffer << fin.rdbuf();
199+
}
200+
std::stringstream m_buffer;
201+
};
202+
nlohmann::json mime_bundle_repr(const image& i) {
203+
auto bundle = nlohmann::json::object();
204+
bundle["image/png"] = xtl::base64encode(i.m_buffer.str());
205+
return bundle;
206+
}
207+
}
208+
#include "xcpp/xdisplay.hpp"
209+
im::image marie("../notebooks/images/marie.png");
210+
xcpp::display(marie);
211+
""",
212+
'mime': 'image/png'
213+
}
214+
]
135215

136216
class XCppTests2(jupyter_kernel_test.KernelTests):
137217

0 commit comments

Comments
 (0)