diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2020-10-24 21:33:44 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2020-10-27 00:11:41 +0300 |
commit | a864099ba77157090c4cd12817245122c163ec24 (patch) | |
tree | f15b1f2801219fa9af6111fa28591858d87711ec /test/unit_tests/fixtures.hpp | |
parent | Process: add termination methods (diff) | |
download | winapi-common-a864099ba77157090c4cd12817245122c163ec24.tar.gz winapi-common-a864099ba77157090c4cd12817245122c163ec24.zip |
rework Process API & tests
* Add separate classes ProcessParameters & ShellParameters for
Process::create() and Process::shell() methods.
* Add a separate "worker" executable. It's used in tests via a fairly
complicated scheme, receiving orders to execute via a shared memory
region.
* Add tests that utilize the Console API, reading console window's
screen buffer directly, making for more reliable tests & broader
coverage.
Diffstat (limited to '')
-rw-r--r-- | test/unit_tests/fixtures.hpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/test/unit_tests/fixtures.hpp b/test/unit_tests/fixtures.hpp index 293ad35..aaf6571 100644 --- a/test/unit_tests/fixtures.hpp +++ b/test/unit_tests/fixtures.hpp @@ -5,6 +5,8 @@ #pragma once +#include "shared/command.hpp" + #include <winapi/cmd_line.hpp> #include <winapi/file.hpp> #include <winapi/path.hpp> @@ -34,18 +36,13 @@ private: RemoveFileGuard& operator=(const RemoveFileGuard&) = delete; }; -class WithEchoExe { +class WithParam { public: - WithEchoExe() : m_echo_exe(find_echo_exe()) {} + WithParam(const std::string& param_prefix) : m_value(find_param_value(param_prefix)) {} - const std::string& get_echo_exe() { return m_echo_exe; } + const std::string& get_value() { return m_value; } private: - static std::string find_echo_exe() { - static const std::string prefix{"--echo_exe="}; - return find_param_value(prefix); - } - static std::string find_param_value(const std::string& param_prefix) { const auto cmd_line = winapi::CommandLine::query(); const auto& args = cmd_line.get_args(); @@ -57,5 +54,21 @@ private: throw std::runtime_error{"couldn't find parameter " + param_prefix}; } - std::string m_echo_exe; + std::string m_value; +}; + +class WithEchoExe : public WithParam { +public: + WithEchoExe() : WithParam{"--echo_exe="} {} + + const std::string& get_echo_exe() { return get_value(); } +}; + +class WithWorkerExe : public WithParam { +public: + WithWorkerExe() : WithParam{"--worker_exe="}, m_cmd{worker::Command::create()} {} + + const std::string& get_worker_exe() { return get_value(); } + + worker::Command::Shared m_cmd; }; |