From 7d94668a6a917da363acfc9294ab0f257b72fc8c Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Mon, 8 May 2023 17:29:56 +0200 Subject: test: Do not rely on shell built-in behavior ... in particular echo(1), which behaves different on dash and sh. --- .../file_system/file_system_manager.test.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'test/buildtool/file_system/file_system_manager.test.cpp') diff --git a/test/buildtool/file_system/file_system_manager.test.cpp b/test/buildtool/file_system/file_system_manager.test.cpp index f627bf02..4b48308e 100644 --- a/test/buildtool/file_system/file_system_manager.test.cpp +++ b/test/buildtool/file_system/file_system_manager.test.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "catch2/catch_test_macros.hpp" @@ -510,22 +511,10 @@ TEST_CASE("FileSystemManager", "[file_system]") { auto anchor = FileSystemManager::ChangeDirectory(test_file.parent_path()); - // assemble file creation command (escape null character) - std::string create_file_cmd{}; - create_file_cmd += "echo -n \""; - std::for_each( - test_content.begin(), test_content.end(), [&](auto const& c) { - if (c == '\0') { - create_file_cmd += std::string{"\\0"}; - } - else { - create_file_cmd += c; - } - }); - create_file_cmd += "\" > " + test_file.filename().string(); - - // run file creation command - std::system(create_file_cmd.c_str()); + std::ofstream file{test_file.filename()}; + REQUIRE(file); + file << test_content; + file.close(); // check if file exists REQUIRE(FileSystemManager::IsFile(test_file.filename())); -- cgit v1.2.3