-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed inspect request and added a framework for testing different imp…
…lementation requests
- Loading branch information
1 parent
ff8c753
commit 396e6a7
Showing
8 changed files
with
167 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
|
@@ -20,3 +20,4 @@ dependencies: | |
- jupyter_kernel_test>=0.4.3 | ||
- nbval | ||
- pytest-rerunfailures | ||
- doctest |
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
############################################################################# | ||
# Copyright (c) 2023, xeus-cpp contributors # | ||
# # | ||
# Distributed under the terms of the BSD 3-Clause License. # | ||
# # | ||
# The full license is in the file LICENSE, distributed with this software. # | ||
############################################################################# | ||
|
||
|
||
# Unit tests | ||
# ========== | ||
|
||
cmake_minimum_required(VERSION 3.1) | ||
|
||
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) | ||
project(xeus-cpp-test) | ||
|
||
enable_testing() | ||
|
||
find_package(xeus-cpp REQUIRED CONFIG) | ||
endif() | ||
|
||
include(CheckCXXCompilerFlag) | ||
|
||
string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE) | ||
|
||
if(CMAKE_CXX_COMPILER_ID MATCHES Clang OR CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Intel) | ||
add_compile_options(-Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion) | ||
|
||
CHECK_CXX_COMPILER_FLAG(-march=native HAS_MARCH_NATIVE) | ||
if (HAS_MARCH_NATIVE) | ||
add_compile_options(-march=native) | ||
endif() | ||
endif() | ||
|
||
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC) | ||
add_compile_options(/EHsc /MP /bigobj) | ||
add_link_options(/MANIFEST:NO) | ||
endif() | ||
|
||
find_package(doctest) | ||
find_package(Threads) | ||
|
||
set(XEUS_CPP_TESTS | ||
main.cpp | ||
test_interpreter.cpp | ||
) | ||
|
||
add_executable(test_xeus_cpp ${XEUS_CPP_TESTS}) | ||
|
||
if (APPLE) | ||
set_target_properties(test_xeus_cpp PROPERTIES | ||
MACOSX_RPATH ON | ||
) | ||
else() | ||
set_target_properties(test_xeus_cpp PROPERTIES | ||
BUILD_WITH_INSTALL_RPATH 1 | ||
SKIP_BUILD_RPATH FALSE | ||
) | ||
endif() | ||
|
||
set_target_properties(test_xeus_cpp PROPERTIES | ||
INSTALL_RPATH_USE_LINK_PATH TRUE | ||
) | ||
|
||
target_link_libraries(test_xeus_cpp xeus-cpp doctest::doctest ${CMAKE_THREAD_LIBS_INIT}) | ||
target_include_directories(test_xeus_cpp PRIVATE ${XEUS_CPP_INCLUDE_DIR}) | ||
|
||
add_custom_target(xtest COMMAND test_xeus_cpp DEPENDS test_xeus_cpp) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/*************************************************************************** | ||
* Copyright (c) 2023, xeus-cpp contributors | ||
* | ||
* Distributed under the terms of the BSD 3-Clause License. | ||
* | ||
* The full license is in the file LICENSE, distributed with this software. | ||
****************************************************************************/ | ||
|
||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN | ||
#include "doctest/doctest.h" |
This file contains 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/*************************************************************************** | ||
* Copyright (c) 2023, xeus-cpp contributors | ||
* | ||
* Distributed under the terms of the BSD 3-Clause License. | ||
* | ||
* The full license is in the file LICENSE, distributed with this software. | ||
****************************************************************************/ | ||
|
||
#include "doctest/doctest.h" | ||
#include "xeus-cpp/xinterpreter.hpp" | ||
|
||
TEST_SUITE("execute_request") | ||
{ | ||
TEST_CASE("fetch_documentation") | ||
{ | ||
|
||
xcpp::interpreter interpreter(0, nullptr); | ||
|
||
std::string code = "?std::vector"; | ||
std::string inspect_result = "https://en.cppreference.com/w/cpp/container/vector"; | ||
nl::json user_expressions = nl::json::object(); | ||
|
||
nl::json result = interpreter.execute_request( | ||
code, | ||
false, | ||
false, | ||
user_expressions, | ||
false | ||
); | ||
|
||
REQUIRE(result["payload"][0]["data"]["text/plain"] == inspect_result); | ||
REQUIRE(result["user_expressions"] == nl::json::object()); | ||
REQUIRE(result["found"] == true); | ||
REQUIRE(result["status"] == "ok"); | ||
} | ||
} |