diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-02-16 16:20:34 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-02-17 16:27:50 +0100 |
commit | 307da10caa951c5e8d6d6f256ee3d81a66ed6bb3 (patch) | |
tree | ad5fcf8650d46957b362326a6956f4c290c2ced8 /test/buildtool/file_system/git_repo.test.cpp | |
parent | ae8db3f7484e5b6e7ef6b0f0f9243d84820c2236 (diff) | |
download | justbuild-307da10caa951c5e8d6d6f256ee3d81a66ed6bb3.tar.gz |
tests: Add proper quoting when system calling the shell
Diffstat (limited to 'test/buildtool/file_system/git_repo.test.cpp')
-rw-r--r-- | test/buildtool/file_system/git_repo.test.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/test/buildtool/file_system/git_repo.test.cpp b/test/buildtool/file_system/git_repo.test.cpp index 23d50f51..632bddb9 100644 --- a/test/buildtool/file_system/git_repo.test.cpp +++ b/test/buildtool/file_system/git_repo.test.cpp @@ -19,6 +19,7 @@ #include "src/buildtool/file_system/file_system_manager.hpp" #include "src/buildtool/file_system/git_repo.hpp" #include "src/utils/cpp/atomic.hpp" +#include "test/utils/shell_quoting.hpp" namespace { @@ -54,10 +55,11 @@ class TestUtils { bool is_bare = false) noexcept -> std::optional<std::filesystem::path> { auto repo_path = CreateTestRepo(is_bare); REQUIRE(repo_path); - auto cmd = fmt::format( - "git --git-dir={} --work-tree={} checkout master", - is_bare ? repo_path->string() : (*repo_path / ".git").string(), - repo_path->string()); + auto cmd = + fmt::format("git --git-dir={} --work-tree={} checkout master", + QuoteForShell(is_bare ? repo_path->string() + : (*repo_path / ".git").string()), + QuoteForShell(repo_path->string())); if (std::system(cmd.c_str()) == 0) { return *repo_path; } @@ -69,8 +71,8 @@ class TestUtils { auto repo_path = GetRepoPath(); auto cmd = fmt::format("git clone {}{} {}", is_bare ? "--bare " : "", - kBundlePath, - repo_path.string()); + QuoteForShell(kBundlePath), + QuoteForShell(repo_path.string())); if (std::system(cmd.c_str()) == 0) { return repo_path; } |