From 1fd18503cdbde4ea407aaf391d675b052dab6532 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Thu, 24 Nov 2022 00:32:31 +0100 Subject: [PATCH 1/2] Successfully fail when running cmkr subcommands --- include/arguments.hpp | 2 -- src/arguments.cpp | 16 +++------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/include/arguments.hpp b/include/arguments.hpp index 6662261..7eec36c 100644 --- a/include/arguments.hpp +++ b/include/arguments.hpp @@ -7,5 +7,3 @@ const char *handle_args(int argc, char **argv); } // namespace args } // namespace cmkr - -const char *cmkr_args_handle_args(int, char **); diff --git a/src/arguments.cpp b/src/arguments.cpp index a2796ab..952b28a 100644 --- a/src/arguments.cpp +++ b/src/arguments.cpp @@ -37,17 +37,17 @@ const char *handle_args(int argc, char **argv) { } else if (main_arg == "build") { auto ret = build::run(argc, argv); if (ret) - return "CMake build error!"; + throw std::runtime_error("CMake build failed!"); return "CMake build completed!"; } else if (main_arg == "install") { auto ret = build::install(); if (ret) - return "CMake install error!"; + throw std::runtime_error("CMake install failed!"); return "CMake install completed!"; } else if (main_arg == "clean") { auto ret = build::clean(); if (ret) - return "CMake clean error!"; + throw std::runtime_error("CMake clean failed!"); return "Cleaned build directory!"; } else { throw std::runtime_error(cmkr::help::message()); @@ -55,13 +55,3 @@ const char *handle_args(int argc, char **argv) { } } // namespace args } // namespace cmkr - -const char *cmkr_args_handle_args(int argc, char **argv) { - try { - return cmkr::args::handle_args(argc, argv); - } catch (const std::exception &e) { - return e.what(); - } catch (...) { - return "Unknown error!"; - } -} From 05e21f734ab5d5241dbe2b8b0a8239f802012226 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Tue, 29 Nov 2022 10:03:12 +0100 Subject: [PATCH 2/2] Fix the tests --- docs/examples/vcpkg.md | 2 +- tests/conditions/src/{win32.cpp => windows_specific.cpp} | 0 tests/interface/src/main.cpp | 4 ++-- tests/vcpkg/cmake.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename tests/conditions/src/{win32.cpp => windows_specific.cpp} (100%) diff --git a/docs/examples/vcpkg.md b/docs/examples/vcpkg.md index 9ebb048..a76aa26 100644 --- a/docs/examples/vcpkg.md +++ b/docs/examples/vcpkg.md @@ -19,7 +19,7 @@ description = "Dependencies from vcpkg" # See https://github.com/microsoft/vcpkg/releases for vcpkg versions # See https://vcpkg.io/en/packages.html for available packages [vcpkg] -version = "2021.05.12" +version = "2022.11.14" packages = ["fmt"] [find-package] diff --git a/tests/conditions/src/win32.cpp b/tests/conditions/src/windows_specific.cpp similarity index 100% rename from tests/conditions/src/win32.cpp rename to tests/conditions/src/windows_specific.cpp diff --git a/tests/interface/src/main.cpp b/tests/interface/src/main.cpp index 9d8c418..d181c04 100644 --- a/tests/interface/src/main.cpp +++ b/tests/interface/src/main.cpp @@ -4,5 +4,5 @@ int main() { - printf("mylib version: %s\n", mylib::version()) -} \ No newline at end of file + printf("mylib version: %s\n", mylib::version()); +} diff --git a/tests/vcpkg/cmake.toml b/tests/vcpkg/cmake.toml index 9207dbf..66a34f3 100644 --- a/tests/vcpkg/cmake.toml +++ b/tests/vcpkg/cmake.toml @@ -7,7 +7,7 @@ description = "Dependencies from vcpkg" # See https://github.com/microsoft/vcpkg/releases for vcpkg versions # See https://vcpkg.io/en/packages.html for available packages [vcpkg] -version = "2021.05.12" +version = "2022.11.14" packages = ["fmt"] [find-package]