diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-04-08 12:28:31 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-04-08 14:23:49 +0200 |
commit | 65fc11ff28e6dd29a95391b6700a02d277b539c6 (patch) | |
tree | f659381c3e4a3867f0e863999a3a24dbff89e72a /test | |
parent | d9c587e7feb7d67249b7a3262f62e0dc5ce47e9a (diff) | |
download | justbuild-65fc11ff28e6dd29a95391b6700a02d277b539c6.tar.gz |
Test ["utils/archive", "archive_usage"]: fix assumptions on path
This test, among others, verifies the archive functionality by
creating an archive with our library, extractting it with the
system command-line tools, and comparing the result. In order to not
depend on the host system having installed tools for all possible
compression algorithms, it tacitly drops the extraction test if the
respective tool could not be found under /usr/bin. This, however,
assumes that /usr/bin is in path; ensure this, by extending PATH
accordingly.
Diffstat (limited to 'test')
-rw-r--r-- | test/utils/archive/archive_usage.test.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/test/utils/archive/archive_usage.test.cpp b/test/utils/archive/archive_usage.test.cpp index 6a8eb751..1be69139 100644 --- a/test/utils/archive/archive_usage.test.cpp +++ b/test/utils/archive/archive_usage.test.cpp @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include <cstdlib> #include <string> #include <unordered_map> #include <vector> @@ -358,10 +359,14 @@ TEST_CASE("Read-write archives", "[archive_read_write]") { } if (tools_exist) { + std::string path{"/usr/bin"}; + if (auto* env_path = std::getenv("PATH")) { + path = std::string{env_path} + ":" + path; + } SECTION("Extract via system tools") { - REQUIRE( - system((scenario.cmd + " " + scenario.filename).c_str()) == - 0); + REQUIRE(system(("export PATH=" + path + " && " + scenario.cmd + + " " + scenario.filename) + .c_str()) == 0); compare_extracted(); } } @@ -408,15 +413,18 @@ TEST_CASE("ArchiveOps", "[archive_ops]") { std::string("/usr/bin/") + tool); } if (tools_exist) { + std::string path{"/usr/bin"}; + if (auto* env_path = std::getenv("PATH")) { + path = std::string{env_path} + ":" + path; + } SECTION("Extract via system tools") { REQUIRE( FileSystemManager::RemoveDirectory(scenario.test_dir, /*recursively=*/true)); REQUIRE(FileSystemManager::CreateDirectory(scenario.test_dir)); - - REQUIRE( - system((scenario.cmd + " " + scenario.filename).c_str()) == - 0); + REQUIRE(system(("export PATH=" + path + " && " + scenario.cmd + + " " + scenario.filename) + .c_str()) == 0); compare_extracted(scenario.test_dir); } } |