mirror of
https://github.com/NixOS/nix
synced 2025-06-27 16:51:15 +02:00
Move unit tests to the location Meson expects them to be
Everything that is a separate subproject should live in the subprojects
directory.
Progress on #2503
This reverts commit 451f8a8c19
.
This commit is contained in:
parent
1cd48008f0
commit
e65510da56
270 changed files with 158 additions and 168 deletions
36
src/libutil-tests/spawn.cc
Normal file
36
src/libutil-tests/spawn.cc
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "processes.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
#ifdef _WIN32
|
||||
TEST(SpawnTest, spawnEcho)
|
||||
{
|
||||
auto output = runProgram(RunOptions{.program = "cmd.exe", .args = {"/C", "echo", "hello world"}});
|
||||
ASSERT_EQ(output.first, 0);
|
||||
ASSERT_EQ(output.second, "\"hello world\"\r\n");
|
||||
}
|
||||
|
||||
std::string windowsEscape(const std::string & str, bool cmd);
|
||||
|
||||
TEST(SpawnTest, windowsEscape)
|
||||
{
|
||||
auto empty = windowsEscape("", false);
|
||||
ASSERT_EQ(empty, R"("")");
|
||||
// There's no quotes in this argument so the input should equal the output
|
||||
auto backslashStr = R"(\\\\)";
|
||||
auto backslashes = windowsEscape(backslashStr, false);
|
||||
ASSERT_EQ(backslashes, backslashStr);
|
||||
|
||||
auto nestedQuotes = windowsEscape(R"(he said: "hello there")", false);
|
||||
ASSERT_EQ(nestedQuotes, R"("he said: \"hello there\"")");
|
||||
|
||||
auto middleQuote = windowsEscape(R"( \\\" )", false);
|
||||
ASSERT_EQ(middleQuote, R"(" \\\\\\\" ")");
|
||||
|
||||
auto space = windowsEscape("hello world", false);
|
||||
ASSERT_EQ(space, R"("hello world")");
|
||||
}
|
||||
#endif
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue