diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2024-03-01 18:07:04 +0100 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2024-03-08 14:18:43 +0100 |
commit | 274ee28fb5d8d5dea123eaa9fc51fd83eeda145a (patch) | |
tree | 0a048dbcc85c9372703ec7f388699002ac88ca2c /test | |
parent | 2ebf355989eb92ac9967eceee0af14d39477afe0 (diff) | |
download | justbuild-274ee28fb5d8d5dea123eaa9fc51fd83eeda145a.tar.gz |
SystemCommand: Transfer outfile responsibility to caller
Diffstat (limited to 'test')
-rw-r--r-- | test/buildtool/system/system_command.test.cpp | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/test/buildtool/system/system_command.test.cpp b/test/buildtool/system/system_command.test.cpp index 292f437f..e14a7657 100644 --- a/test/buildtool/system/system_command.test.cpp +++ b/test/buildtool/system/system_command.test.cpp @@ -53,9 +53,9 @@ TEST_CASE("SystemCommand", "[filesystem]") { auto output = system.Execute( {"echo"}, {}, FileSystemManager::GetCurrentDirectory(), tmpdir); REQUIRE(output.has_value()); - CHECK(output->return_value == 0); - CHECK(*FileSystemManager::ReadFile(output->stdout_file) == "\n"); - CHECK(FileSystemManager::ReadFile(output->stderr_file)->empty()); + CHECK(*output == 0); + CHECK(*FileSystemManager::ReadFile(tmpdir / "stdout") == "\n"); + CHECK(FileSystemManager::ReadFile(tmpdir / "stderr")->empty()); } SECTION( @@ -68,10 +68,10 @@ TEST_CASE("SystemCommand", "[filesystem]") { FileSystemManager::GetCurrentDirectory(), tmpdir); REQUIRE(output.has_value()); - CHECK(output->return_value == 0); - CHECK(*FileSystemManager::ReadFile(output->stdout_file) == + CHECK(*output == 0); + CHECK(*FileSystemManager::ReadFile(tmpdir / "stdout") == "${MY_MESSAGE}\n"); - CHECK(FileSystemManager::ReadFile(output->stderr_file)->empty()); + CHECK(FileSystemManager::ReadFile(tmpdir / "stderr")->empty()); tmpdir = testdir / "simple_env1"; REQUIRE(FileSystemManager::CreateDirectoryExclusive(tmpdir)); @@ -81,11 +81,9 @@ TEST_CASE("SystemCommand", "[filesystem]") { FileSystemManager::GetCurrentDirectory(), tmpdir); REQUIRE(output_wrapped.has_value()); - CHECK(output_wrapped->return_value == 0); - CHECK(*FileSystemManager::ReadFile(output_wrapped->stdout_file) == - "hello\n"); - CHECK( - FileSystemManager::ReadFile(output_wrapped->stderr_file)->empty()); + CHECK(*output_wrapped == 0); + CHECK(*FileSystemManager::ReadFile(tmpdir / "stdout") == "hello\n"); + CHECK(FileSystemManager::ReadFile(tmpdir / "stderr")->empty()); } SECTION("executable, producing std output, std error and return value") { @@ -99,10 +97,10 @@ TEST_CASE("SystemCommand", "[filesystem]") { FileSystemManager::GetCurrentDirectory(), tmpdir); REQUIRE(output.has_value()); - CHECK(output->return_value == 5); - CHECK(*FileSystemManager::ReadFile(output->stdout_file) == + CHECK(*output == 5); + CHECK(*FileSystemManager::ReadFile(tmpdir / "stdout") == "this is stdout\n"); - CHECK(*FileSystemManager::ReadFile(output->stderr_file) == + CHECK(*FileSystemManager::ReadFile(tmpdir / "stderr") == "this is stderr\n"); } @@ -121,10 +119,8 @@ TEST_CASE("SystemCommand", "[filesystem]") { FileSystemManager::GetCurrentDirectory(), tmpdir); REQUIRE(output.has_value()); - CHECK(output->return_value == 5); - CHECK(*FileSystemManager::ReadFile(output->stdout_file) == - stdout + '\n'); - CHECK(*FileSystemManager::ReadFile(output->stderr_file) == - stderr + '\n'); + CHECK(*output == 5); + CHECK(*FileSystemManager::ReadFile(tmpdir / "stdout") == stdout + '\n'); + CHECK(*FileSystemManager::ReadFile(tmpdir / "stderr") == stderr + '\n'); } } |