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"
19 /// Launch a blank instance with given arguments (program name
20 /// will be prepended by the constructor).
21 /// If connect is true, a command service connection will be
22 /// established during construction.
23 explicit TestInstance(const Process::Arguments &args, bool connect = false, bool temp_save = true);
27 /// Write given text to program's stdin.
28 /// Data is not modified, so if you want to push a line, be
29 /// sure to include a newline character.
30 void WriteInput(const std::string &data);
32 /// read next line from program's stdout
33 void ReadOutputLine(std::string &line);
34 /// assert that the next line the program writes to stdout will
35 /// be the given one (without a trailing newline character)
36 void AssertOutputLine(const std::string &line);
37 /// wait until program writes given line to stdout
38 void WaitOutputLine(const std::string &line);
39 /// read from program's stdout until EOF
40 void ExhaustOutput(std::string &output);
41 /// assert that the program produces no more output
42 void AssertNoOutput();
44 /// read next line from program's stderr
45 void ReadErrorLine(std::string &line);
46 /// assert that the next line the program writes to stderr will
47 /// be the given one (without a trailing newline character)
48 void AssertErrorLine(const std::string &line);
49 /// wait until program writes given line to stderr
50 void WaitErrorLine(const std::string &line);
51 /// read from program's stdout until EOF
52 void ExhaustError(std::string &error);
53 /// assert that the program produces no more output on stderr
56 /// send termination signal
58 /// assert that the program has not exited
60 /// assert that the program has exited
61 void AssertTerminated();
62 /// make sure the process terminated with given status
63 void AssertExitStatus(int expected);
65 // the following methods are only valid when a command service is connected
67 /// wait for given message on the command service
68 void WaitCommandMessage(const std::string &line);
69 /// wait for given error on the command service
70 void WaitCommandError(const std::string &line);
71 /// wait for given broadcast on the command service
72 void WaitCommandBroadcast(const std::string &line);
73 /// wait for given line on the command service
74 void WaitCommandLine(const std::string &line);
76 /// send command line to program
77 void SendCommand(const std::string &);
84 LineBuffer<BUFSIZ> out_buf;
85 LineBuffer<BUFSIZ> err_buf;
86 LineBuffer<BUFSIZ> cmd_buf;
88 std::list<std::string> past_out;
89 std::list<std::string> past_err;
90 std::list<std::string> past_cmd;