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

antonvw / wex / 17877007475

20 Sep 2025 07:22AM UTC coverage: 64.153% (+5.5%) from 58.646%
17877007475

push

github

antonvw
Merge branch 'develop'

18261 of 31235 branches covered (58.46%)

Branch coverage included in aggregate %.

14571 of 19943 relevant lines covered (73.06%)

1401.93 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)
262✔
21
  : m_exe(exe)
262✔
22
  , m_args(args)
524✔
23
{
24
}
262✔
25

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

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

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

40
  return to_vector_string(m_exe.substr(pos + 1)).get();
142✔
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
86✔
56
{
57
  const auto& p(path(find_before(m_exe, " ")));
86✔
58

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

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

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

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

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

91
  return exe +
41✔
92
         (!arg_v.empty() ?
119✔
93
            " args:" + std::ranges::fold_left(
78!
94
                         arg_v,
95
                         std::string(""),
78!
96
                         [](const std::string& a, const std::string& b)
58✔
97
                         {
98
                           return a + " " + b;
58✔
99
                         }) :
100
            std::string()) +
82✔
101
         (!m_start_dir.empty() ? " dir: " + m_start_dir : std::string()) +
123✔
102
         (!m_stdin.empty() ? " stdin: " + m_stdin : std::string());
164✔
103
}
41✔
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