From c54ff48ac3abb62a40eb1a438da8e3e7ef139797 Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Sat, 28 Jun 2025 20:40:25 +0100 Subject: posix: add tempfile() --- nihil.posix/test_spawn.cc | 117 ---------------------------------------------- 1 file changed, 117 deletions(-) delete mode 100644 nihil.posix/test_spawn.cc (limited to 'nihil.posix/test_spawn.cc') diff --git a/nihil.posix/test_spawn.cc b/nihil.posix/test_spawn.cc deleted file mode 100644 index da321ff..0000000 --- a/nihil.posix/test_spawn.cc +++ /dev/null @@ -1,117 +0,0 @@ -/* - * This source code is released into the public domain. - */ - -#include - -import nihil.posix; - -TEST_CASE("spawn: system", "[spawn]") -{ - using namespace nihil; - - auto exec = shell("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: execv", "[spawn]") { - using namespace nihil; - - auto args = argv({"sh", "-c", "x=1; echo $x"}); - auto exec = execv("/bin/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: 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: execl", "[spawn]") { - using namespace nihil; - - auto exec = execl("/bin/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", "[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); -} -- cgit v1.2.3