1 #ifndef BLANK_TEST_INTEGRATION_TESTINSTANCE_HPP_
2 #define BLANK_TEST_INTEGRATION_TESTINSTANCE_HPP_
4 #include "app/Process.hpp"
5 #include "io/filesystem.hpp"
6 #include "io/LineBuffer.hpp"
16 /// Launch a blank instance with given arguments (program name
17 /// will be prepended by the constructor).
18 /// If connect is true, a command service connection will be
19 /// established during construction.
20 explicit TestInstance(const Process::Arguments &args, bool connect = false);
24 /// Write given text to program's stdin.
25 /// Data is not modified, so if you want to push a line, be
26 /// sure to include a newline character.
27 void WriteInput(const std::string &data);
29 /// read next line from programs stdout
30 void ReadOutputLine(std::string &line);
31 /// assert that the next line the program writes to stdout will
32 /// be the given one (without a trailing newline character)
33 void AssertOutputLine(const std::string &line);
34 /// wait until program writes given line to stdout
35 void WaitOutputLine(const std::string &line);
37 /// read next line from programs stderr
38 void ReadErrorLine(std::string &line);
39 /// assert that the next line the program writes to stderr will
40 /// be the given one (without a trailing newline character)
41 void AssertErrorLine(const std::string &line);
42 /// wait until program writes given line to stderr
43 void WaitErrorLine(const std::string &line);
45 /// make sure the process terminated with given status
46 void AssertExitStatus(int expected);
48 // the following methods are only valid when a command service is connected
50 /// wait for given message on the command service
51 void WaitCommandMessage(const std::string &line);
52 /// wait for given error on the command service
53 void WaitCommandError(const std::string &line);
54 /// wait for given broadcast on the command service
55 void WaitCommandBroadcast(const std::string &line);
56 /// wait for given line on the command service
57 void WaitCommandLine(const std::string &line);
59 /// send command line to program
60 void SendCommand(const std::string &);
67 LineBuffer<BUFSIZ> out_buf;
68 LineBuffer<BUFSIZ> err_buf;
69 LineBuffer<BUFSIZ> cmd_buf;