From 56b4f131c4bc89452e9a7ce6472a822a467ffda0 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 5 Feb 2024 15:38:36 -0600 Subject: [PATCH 1/2] Lint (#124) Signed-off-by: Michael Carroll --- include/gz/utils/detail/subprocess.h | 4 ++-- src/Environment.cc | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/gz/utils/detail/subprocess.h b/include/gz/utils/detail/subprocess.h index 7077ffe..137aa14 100644 --- a/include/gz/utils/detail/subprocess.h +++ b/include/gz/utils/detail/subprocess.h @@ -187,7 +187,7 @@ subprocess_weak int subprocess_terminate(struct subprocess_s *const process); /// /// The only safe way to read from the standard output of a process during it's /// execution is to use the `subprocess_option_enable_async` option in -/// conjuction with this method. +/// conjunction with this method. subprocess_weak unsigned subprocess_read_stdout(struct subprocess_s *const process, char *const buffer, unsigned size); @@ -201,7 +201,7 @@ subprocess_read_stdout(struct subprocess_s *const process, char *const buffer, /// /// The only safe way to read from the standard error of a process during it's /// execution is to use the `subprocess_option_enable_async` option in -/// conjuction with this method. +/// conjunction with this method. subprocess_weak unsigned subprocess_read_stderr(struct subprocess_s *const process, char *const buffer, unsigned size); diff --git a/src/Environment.cc b/src/Environment.cc index d477414..7daace5 100644 --- a/src/Environment.cc +++ b/src/Environment.cc @@ -20,6 +20,7 @@ #include #include #include +#include #include #ifdef _WIN32 @@ -189,7 +190,9 @@ EnvironmentStrings envMapToStrings(const EnvironmentMap &_envMap) std::sort(sorted.begin(), sorted.end()); for (auto [key, value] : sorted) { - ret.push_back(key + "=" + value); + key += '='; + key += value; + ret.push_back(key); } return ret; } From f9281920e64f597750dd88b73e194cb982d8fd40 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Tue, 6 Feb 2024 16:24:55 -0600 Subject: [PATCH 2/2] bazel: build and test subprocess functionality (#123) Signed-off-by: Michael Carroll --- BUILD.bazel | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/BUILD.bazel b/BUILD.bazel index cafd9c2..435829a 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -41,6 +41,7 @@ gz_export_header( public_headers_no_gen = glob([ "include/gz/utils/*.hh", "include/gz/utils/detail/*.hh", + "include/gz/utils/detail/*.h", ]) gz_include_header( @@ -110,3 +111,23 @@ cc_test( "@gtest//:gtest_main", ], ) + +cc_binary( + name = "subprocess_main", + srcs = ["test/integration/subprocess/subprocess_main.cc"], + deps = [ + GZ_ROOT + "utils/cli", + ] +) + +cc_test( + name = "subprocess_TEST", + srcs = ["test/integration/subprocess_TEST.cc"], + deps = [ + ":utils", + ":subprocess_main", + "@gtest", + "@gtest//:gtest_main", + ], + local_defines = ['SUBPROCESS_EXECUTABLE_PATH=\\"utils/subprocess_main\\"'], +)