diff options
| author | Lexi Winter <lexi@le-fay.org> | 2025-06-30 09:10:16 +0100 |
|---|---|---|
| committer | Lexi Winter <lexi@le-fay.org> | 2025-06-30 09:10:16 +0100 |
| commit | 36427c0966faa7aecd586b397ed9b845f18172f5 (patch) | |
| tree | 0d86c7ca9ac9e2e768b54d491bf596fb84f5e45a /nihil.posix/test.spawn.cc | |
| parent | 034cd404a129103a8dd7747e6bd00ffd5550da93 (diff) | |
| download | nihil-36427c0966faa7aecd586b397ed9b845f18172f5.tar.gz nihil-36427c0966faa7aecd586b397ed9b845f18172f5.tar.bz2 | |
more refactoring; add stat()
Diffstat (limited to 'nihil.posix/test.spawn.cc')
| -rw-r--r-- | nihil.posix/test.spawn.cc | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/nihil.posix/test.spawn.cc b/nihil.posix/test.spawn.cc deleted file mode 100644 index c5b4f53..0000000 --- a/nihil.posix/test.spawn.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This source code is released into the public domain. - */ - -#include <catch2/catch_test_macros.hpp> - -import nihil.posix; - -TEST_CASE("spawn: execv", "[spawn]") { - using namespace nihil; - - auto args = argv({"sh", "-c", "x=1; echo $x"}); - auto exec = execv("/bin/sh", std::move(args)); - - auto output = std::string(); - auto capture = make_capture(stdout_fileno, output); - REQUIRE(capture); - - auto proc = spawn(exec, *capture); - REQUIRE(proc); - - auto status = std::move(*proc).wait(); - if (!status) - FAIL(to_string(status.error())); - - REQUIRE(status->okay()); - REQUIRE(output == "1\n"); -} - -TEST_CASE("spawn: execvp", "[spawn]") { - using namespace nihil; - - auto args = argv({"sh", "-c", "x=1; echo $x"}); - auto exec = execvp("sh", std::move(args)); - REQUIRE(exec); - - auto output = std::string(); - auto capture = make_capture(stdout_fileno, output); - REQUIRE(capture); - - auto proc = spawn(*exec, *capture); - REQUIRE(proc); - - auto status = std::move(*proc).wait(); - REQUIRE(status); - - REQUIRE(status->okay()); - REQUIRE(output == "1\n"); -} - - -TEST_CASE("spawn: execlp", "[spawn]") { - using namespace nihil; - - auto exec = execlp("sh", "sh", "-c", "x=1; echo $x"); - REQUIRE(exec); - - auto output = std::string(); - auto capture = make_capture(stdout_fileno, output); - REQUIRE(capture); - - auto proc = spawn(*exec, *capture); - REQUIRE(proc); - - auto status = std::move(*proc).wait(); - REQUIRE(status); - - REQUIRE(status->okay()); - REQUIRE(output == "1\n"); -} - -TEST_CASE("spawn: execlp failure", "[spawn]") { - using namespace nihil; - - auto exec = execlp("nihil_no_such_executable", "x"); - REQUIRE(!exec); -} |
