115 std::string list_output;
116 if (!require(run_and_capture({
"public-runner-smoke",
"-list"}, list_output) == EXIT_SUCCESS,
117 "-list should succeed")) {
120 const std::string pass_name =
"Smoke::A-Pass";
121 const std::string fail_name =
"Smoke::B-Fail";
122 const std::size_t pass_pos = list_output.find(pass_name);
123 const std::size_t fail_pos = list_output.find(fail_name);
124 if (!require(pass_pos != std::string::npos,
"-list output missing pass test")) {
127 if (!require(fail_pos != std::string::npos,
"-list output missing fail test")) {
130 if (!require(pass_pos < fail_pos,
"-list output is not alphabetically ordered")) {
133 if (!require(passing_runs == 0 && failing_runs == 0,
134 "-list should not execute any registered tests")) {
138 std::string tagged_list_output;
139 if (!require(run_and_capture({
"public-runner-smoke",
"-list-with-tags"},
140 tagged_list_output) == EXIT_SUCCESS,
141 "-list-with-tags should succeed")) {
144 if (!require(tagged_list_output.find(pass_name +
" [standard]") != std::string::npos,
145 "default test should have the standard tag")) {
148 if (!require(tagged_list_output.find(
"Smoke::B-Fail [sweep]") != std::string::npos,
149 "explicit test tag should be listed")) {
153 std::string normal_output;
154 if (!require(run_and_capture({
"public-runner-smoke",
"-tag",
"standard",
155 "-iter",
"1",
"-stop",
"true"},
156 normal_output) == EXIT_SUCCESS,
157 "standard tag selection should succeed")) {
160 if (!require(normal_output.find(pass_name) != std::string::npos &&
161 normal_output.find(fail_name) == std::string::npos,
162 "standard tag selection chose the wrong tests")) {
165 if (!require(passing_runs == 1 && failing_runs == 0,
166 "standard tag selection run counts are wrong")) {
170 std::string pass_output;
171 if (!require(run_and_capture({
"public-runner-smoke",
"-test",
"Smoke::A-Pass",
"-iter",
"1",
"-stop",
"true"},
172 pass_output) == EXIT_SUCCESS,
173 "filtered passing run should succeed")) {
176 if (!require(pass_output.find(pass_name) != std::string::npos,
177 "filtered passing run did not print the selected test")) {
180 if (!require(pass_output.find(fail_name) == std::string::npos,
181 "filtered passing run executed an unselected test")) {
184 if (!require(passing_runs == 2 && failing_runs == 0,
185 "filtered passing run counts are wrong")) {
189 std::string fail_output;
190 if (!require(run_and_capture({
"public-runner-smoke",
"-test",
"Smoke::B-Fail",
"-iter",
"1",
"-stop",
"true"},
191 fail_output) == EXIT_FAILURE,
192 "filtered failing run should fail")) {
195 if (!require(fail_output.find(fail_name) != std::string::npos,
196 "filtered failing run did not print the selected test")) {
199 if (!require(fail_output.find(
"Options: -replay ") != std::string::npos,
200 "filtered failing run did not preserve seed diagnostics")) {
203 if (!require(fail_output.find(
"-test Smoke::B-Fail") != std::string::npos,
204 "filtered failing run did not preserve test diagnostics")) {
207 if (!require(passing_runs == 2 && failing_runs == 1,
208 "filtered failing run counts are wrong")) {
212 std::string replay_output;
213 if (!require(run_and_capture({
"public-runner-smoke",
"-test",
"Smoke::Replay",
214 "-seed",
"12345",
"-iter",
"2"},
215 replay_output) == EXIT_FAILURE && replay_runs == 2,
216 "seed-sensitive test should fail on its second iteration"))
218 const std::string seed = std::to_string(observed_seed);
219 if (!require(replay_output.find(
"Options: -replay " + seed) != std::string::npos,
220 "failure should report the iteration's initial random state"))
222 if (!require(run_and_capture({
"public-runner-smoke",
"-test",
"Smoke::Replay",
223 "-replay", seed.c_str()}, replay_output) == EXIT_FAILURE &&
224 std::to_string(observed_seed) == seed,
225 "replay should restore the reported random state"))
228 std::string combined_output;
229 if (!require(run_and_capture({
"public-runner-smoke",
"-tag",
"standard",
230 "-tag",
"sweep",
"-iter",
"1",
"-stop",
"true"},
231 combined_output) == EXIT_FAILURE,
232 "multiple tags should select their union")) {
235 if (!require(combined_output.find(pass_name) != std::string::npos &&
236 combined_output.find(fail_name) != std::string::npos,
237 "multiple tag selection did not run both tags")) {
240 if (!require(passing_runs == 3 && failing_runs == 2,
241 "multiple tag selection run counts are wrong")) {
Case output("Data::Output", [](void) { Data d=read("n: int f: float w: word m[2][2]: int repeat n { k: int x[k]: int }", "2 20 a 1 2 3 4 1 5 2 6 7");std::ostringstream z;d.dzn(z);CHECK(z.str().find("f = 20.0;") !=std::string::npos);CHECK(z.str().find("m = [| 1, 2\n | 3, 4 |];") !=std::string::npos);CHECK(z.str().find("% x: array[int] of tuple(array[int] of int)\n" "x = [([5],), ([6, 7],)];") !=std::string::npos);CHECK(z.str().find("w = \"a\";") !=std::string::npos);std::ostringstream zq;read("var: int w: word", "3 a\033b").dzn(zq);CHECK(zq.str().find("'var' = 3;") !=std::string::npos);CHECK(zq.str().find("w = \"a\\x1bb\";") !=std::string::npos);Data e=read("e[2][0]: int repeat 2 { k: int repeat k { list y: int until 0 } }", "1 7 0 2 8 9 0 0");std::ostringstream ze;e.dzn(ze);CHECK(ze.str().find("e = array2d(1..2, 1..0, []);") !=std::string::npos);CHECK(ze.str().find("y = [([([7],)],), ([([8, 9],), ([],)],)];") !=std::string::npos);std::ostringstream z7;read("a[1][1][1][1][1][1][1]: int", "5").dzn(z7);CHECK(z7.str().find("a = [([([([([([([5],)],)],)],)],)],)];") !=std::string::npos);return true;})