Skip to content

Commit 4dd47cc

Browse files
committed
fix(cli): use portable popen in tests command
1 parent 7b92e92 commit 4dd47cc

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/commands/TestsCommand.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@
4747
#include <fcntl.h>
4848
#endif
4949

50+
#ifdef _WIN32
51+
#define VIX_TESTS_POPEN _popen
52+
#define VIX_TESTS_PCLOSE _pclose
53+
#else
54+
#define VIX_TESTS_POPEN popen
55+
#define VIX_TESTS_PCLOSE pclose
56+
#endif
57+
5058
using namespace vix::cli::style;
5159
namespace fs = std::filesystem;
5260
namespace build = vix::cli::build;
@@ -592,7 +600,7 @@ namespace
592600

593601
const std::string cmd = shell_join(argv) + " 2>&1";
594602

595-
FILE *pipe = popen(cmd.c_str(), "r");
603+
FILE *pipe = VIX_TESTS_POPEN(cmd.c_str(), "r");
596604
if (!pipe)
597605
{
598606
result.code = 127;
@@ -605,7 +613,7 @@ namespace
605613
while (fgets(buffer, sizeof(buffer), pipe) != nullptr)
606614
result.output += buffer;
607615

608-
const int raw = pclose(pipe);
616+
const int raw = VIX_TESTS_PCLOSE(pipe);
609617
result.code = vix::cli::process::normalize_exit_code(raw);
610618

611619
return result;

0 commit comments

Comments
 (0)