namespace Win32Util {
-std::string
-add_exe_suffix(const std::string& path)
-{
- auto ext = util::to_lowercase(Util::get_extension(path));
- if (ext == ".exe" || ext == ".bat" || ext == ".sh") {
- return path;
- } else {
- return path + ".exe";
- }
-}
-
std::string
error_message(DWORD error_code)
{
namespace Win32Util {
-// Add ".exe" suffix to `program` if it doesn't already end with ".exe", ".bat"
-// or ".sh".
-std::string add_exe_suffix(const std::string& program);
-
// Recreate a Windows command line string based on `argv`. If `prefix` is
// non-empty, add it as the first argument. If `escape_backslashes` is true,
// emit an additional backslash for each backslash that is not preceding '"' and
hash.hash(ctx.config.cpp_extension());
#ifdef _WIN32
- const std::string compiler_path = Win32Util::add_exe_suffix(args[0]);
+ const std::string compiler_path = util::add_exe_suffix(args[0]);
#else
const std::string compiler_path = args[0];
#endif
}
std::string args = Win32Util::argv_to_string(argv, sh);
- std::string full_path = Win32Util::add_exe_suffix(path);
+ std::string full_path = util::add_exe_suffix(path);
fs::path tmp_file_path;
util::Finalizer tmp_file_remover([&tmp_file_path] {
return cwd_str;
}
+std::string
+add_exe_suffix(const std::string& program)
+{
+ auto ext = util::to_lowercase(Util::get_extension(program));
+ if (ext == ".exe" || ext == ".bat" || ext == ".sh") {
+ return program;
+ } else {
+ return program + ".exe";
+ }
+}
+
std::string
apparent_cwd(const std::string& actual_cwd)
{
// normalized path without symlink parts). Returns the empty string on error.
std::string actual_cwd();
+// Add ".exe" suffix to `program` if it doesn't already end with ".exe", ".bat"
+// or ".sh".
+std::string add_exe_suffix(const std::string& program);
+
// Return current working directory (CWD) by reading the environment variable
// PWD (thus keeping any symlink parts in the path and potentially ".." or "//"
// parts). If PWD does not resolve to the same inode as `actual_cwd` then
#include <ostream> // https://github.com/doctest/doctest/issues/618
+TEST_CASE("util::add_exe_suffix")
+{
+ CHECK(util::add_exe_suffix("foo") == "foo.exe");
+ CHECK(util::add_exe_suffix("foo.bat") == "foo.bat");
+ CHECK(util::add_exe_suffix("foo.exe") == "foo.exe");
+ CHECK(util::add_exe_suffix("foo.sh") == "foo.sh");
+}
+
TEST_CASE("util::is_absolute_path")
{
#ifdef _WIN32