/
novemus
/
plexus
Обзор
Документация
Войти
/
novemus
/
plexus
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
tests/exec_tests.cpp
35 строк
1 KB
novemus
extend plexus proto
31 мар 2026, 17:00
31 мар 2026, 17:00
c3b3984
Код
Авторство
О чём код?
/* * Copyright (c) 2022 Novemus Band. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * */ #include <boost/test/unit_test.hpp> #include <filesystem> #include <fstream> #include <string> #include <plexus/features.h> BOOST_AUTO_TEST_CASE(exec) { std::filesystem::remove("out.txt"); #ifdef _WIN32 BOOST_REQUIRE_NO_THROW(plexus::exec("C:\\Windows\\System32\\cmd.exe", "/c echo %KEY%", std::filesystem::current_path().string(), "out.txt", "KEY=VALUE", true)); #else BOOST_REQUIRE_NO_THROW(plexus::exec("/bin/sh", "-c \"echo $KEY\"", std::filesystem::current_path().string(), "out.txt", "KEY=VALUE", true)); #endif BOOST_REQUIRE(std::filesystem::exists(std::filesystem::path("out.txt"))); std::ifstream file("out.txt"); std::string text((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>()); BOOST_REQUIRE_EQUAL(text, "VALUE\n"); file.close(); BOOST_REQUIRE(std::filesystem::remove("out.txt")); }