From d6ebb9cb4151bd3ecac4d28f1ad14cefe4e1ea66 Mon Sep 17 00:00:00 2001 From: kr-2003 Date: Sun, 27 Apr 2025 12:31:03 +0530 Subject: [PATCH 1/3] removed build_interpreter from main() --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 6eeb5a0c..5fab0008 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -59,7 +59,7 @@ int main(int argc, char* argv[]) signal(SIGINT, xcpp::stop_handler); std::string file_name = xeus::extract_filename(argc, argv); - interpreter_ptr interpreter = xcpp::build_interpreter(argc, argv); + auto interpreter = std::unique_ptr(new xcpp::interpreter(argc, argv)); std::unique_ptr context = xeus::make_zmq_context(); if (!file_name.empty()) From cce9ca46e680d192444b82247821ad290e7725e2 Mon Sep 17 00:00:00 2001 From: kr-2003 Date: Sun, 27 Apr 2025 12:34:55 +0530 Subject: [PATCH 2/3] removed tests for build_interpreter --- include/xeus-cpp/xutils.hpp | 3 --- src/xutils.cpp | 15 --------------- test/test_interpreter.cpp | 18 ------------------ 3 files changed, 36 deletions(-) diff --git a/include/xeus-cpp/xutils.hpp b/include/xeus-cpp/xutils.hpp index a80bab8a..fb79cb72 100644 --- a/include/xeus-cpp/xutils.hpp +++ b/include/xeus-cpp/xutils.hpp @@ -24,9 +24,6 @@ namespace xcpp XEUS_CPP_API void stop_handler(int sig); - XEUS_CPP_API - interpreter_ptr build_interpreter(int argc, char** argv); - XEUS_CPP_API std::string retrieve_tagconf_dir(); diff --git a/src/xutils.cpp b/src/xutils.cpp index fef82bac..2ab4adb1 100644 --- a/src/xutils.cpp +++ b/src/xutils.cpp @@ -50,21 +50,6 @@ namespace xcpp exit(0); } - interpreter_ptr build_interpreter(int argc, char** argv) - { - std::vector interpreter_argv(argc); - interpreter_argv[0] = "xeus-cpp"; - - // Copy all arguments in the new vector excepting the process name. - for (int i = 1; i < argc; i++) - { - interpreter_argv[i] = argv[i]; - } - - interpreter_ptr interp_ptr = std::make_unique(argc, interpreter_argv.data()); - return interp_ptr; - } - std::string retrieve_tagconf_dir() { const char* tagconf_dir_env = std::getenv("XCPP_TAGCONFS_DIR"); diff --git a/test/test_interpreter.cpp b/test/test_interpreter.cpp index 3ffdb5e3..61d5f5d7 100644 --- a/test/test_interpreter.cpp +++ b/test/test_interpreter.cpp @@ -344,24 +344,6 @@ TEST_SUITE("trim"){ } -TEST_SUITE("build_interpreter") -{ - // This test case checks if the function `build_interpreter` returns a non-null pointer - // when valid arguments are passed. It sets up a scenario with valid command line arguments - // and checks if the function returns a non-null pointer. - TEST_CASE("build_interpreter_pointer_not_null") - { - char arg1[] = "program_name"; - char arg2[] = "-option1"; - char* argv[] = {arg1, arg2}; - int argc = 2; - - interpreter_ptr interp_ptr = xcpp::build_interpreter(argc, argv); - - REQUIRE(interp_ptr != nullptr); - } -} - TEST_SUITE("is_match_magics_manager") { // This test case checks if the function `is_match` correctly identifies strings that match From bd365e7b5c3271099884abbf353da4d011246c8f Mon Sep 17 00:00:00 2001 From: Abhinav Kumar <96587705+kr-2003@users.noreply.github.com> Date: Sun, 27 Apr 2025 12:55:43 +0530 Subject: [PATCH 3/3] used make_unique instead of unique_ptr Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 5fab0008..00d52d28 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -59,7 +59,7 @@ int main(int argc, char* argv[]) signal(SIGINT, xcpp::stop_handler); std::string file_name = xeus::extract_filename(argc, argv); - auto interpreter = std::unique_ptr(new xcpp::interpreter(argc, argv)); + auto interpreter = std::make_unique(argc, argv); std::unique_ptr context = xeus::make_zmq_context(); if (!file_name.empty())