• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

antonvw / wex / 16076627703

04 Jul 2025 03:07PM UTC coverage: 63.275% (+0.3%) from 62.987%
16076627703

push

github

antonvw
Merge remote-tracking branch 'origin/develop' into 865-msw-tests

18021 of 31282 branches covered (57.61%)

Branch coverage included in aggregate %.

14413 of 19977 relevant lines covered (72.15%)

1385.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.8
/src/factory/process-data.cpp
1
////////////////////////////////////////////////////////////////////////////////
2
// Name:      process-data.cpp
3
// Purpose:   Implementation of class wex::factory::process_data
4
// Author:    Anton van Wezenbeek
5
// Copyright: (c) 2022-2025 Anton van Wezenbeek
6
////////////////////////////////////////////////////////////////////////////////
7

8
#include <filesystem>
9
#include <numeric>
10

11
#include <boost/process/v2/environment.hpp>
12

13
#include <wex/common/tostring.h>
14
#include <wex/core/core.h>
15
#include <wex/core/path.h>
16
#include <wex/factory/process-data.h>
17

18
namespace bp = boost::process::v2;
19

20
wex::process_data::process_data(const std::string& exe, const std::string& args)
150✔
21
  : m_exe(exe)
150✔
22
  , m_args(args)
300✔
23
{
24
}
150✔
25

26
const std::vector<std::string> wex::process_data::args() const
89✔
27
{
28
  if (!m_args.empty())
89✔
29
  {
30
    return to_vector_string(m_args).get();
2✔
31
  }
32

33
  const auto pos = m_exe.find(' ');
88✔
34

35
  if (pos == std::string::npos)
88✔
36
  {
37
    return std::vector<std::string>{};
15✔
38
  }
39

40
  return to_vector_string(m_exe.substr(pos + 1)).get();
146✔
41
}
42

43
wex::process_data& wex::process_data::args(const std::string& rhs)
3✔
44
{
45
  m_args = rhs;
3✔
46
  return *this;
3✔
47
}
48

49
wex::process_data& wex::process_data::exe(const std::string& rhs)
4✔
50
{
51
  m_exe = rhs;
4✔
52
  return *this;
4✔
53
}
54

55
const std::string wex::process_data::exe_path() const
87✔
56
{
57
  const auto& p(path(find_before(m_exe, " ")));
87✔
58

59
  if (p.string().empty())
87✔
60
  {
61
    throw std::invalid_argument("Cannot execute empty string");
1✔
62
  }
63
  if (!p.file_exists())
86!
64
  {
65
    if (const auto& bop(bp::environment::find_executable(p.string()));
86✔
66
        !bop.empty())
86✔
67
    {
68
      return bop.string();
72✔
69
    }
86✔
70

71
    throw std::invalid_argument("Could not find: " + p.string());
14✔
72
  }
73

74
  return p.string();
×
75
}
87✔
76

77
const std::string wex::process_data::log() const
42✔
78
{
79
  const auto& arg_v(args());
42✔
80
  std::string exe("exe: ");
42✔
81

82
  try
83
  {
84
    exe += exe_path();
42✔
85
  }
86
  catch (std::exception& e)
7!
87
  {
88
    exe += e.what();
7✔
89
  }
7✔
90

91
  return exe +
42✔
92
         (!arg_v.empty() ?
122✔
93
            " args:" + std::ranges::fold_left(
80!
94
                         arg_v,
95
                         std::string(""),
80!
96
                         [](const std::string& a, const std::string& b)
60✔
97
                         {
98
                           return a + " " + b;
60✔
99
                         }) :
100
            std::string()) +
84✔
101
         (!m_start_dir.empty() ? " dir: " + m_start_dir : std::string()) +
126✔
102
         (!m_stdin.empty() ? " stdin: " + m_stdin : std::string());
168✔
103
}
42✔
104

105
wex::process_data& wex::process_data::start_dir(const std::string& rhs)
37✔
106
{
107
  m_start_dir = rhs;
37✔
108
  return *this;
37✔
109
}
110

111
wex::process_data& wex::process_data::std_in(const std::string& rhs)
4✔
112
{
113
  m_stdin = rhs;
4✔
114
  return *this;
4✔
115
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc