main.lua

changeset 137
091212cef52a
parent 136
2df38fd36b2b
child 144
f7e8b865873f
equal deleted inserted replaced
136:2df38fd36b2b 137:091212cef52a
10 local result_log_filename = nil; 10 local result_log_filename = nil;
11 local server_log_reader = nil; 11 local server_log_reader = nil;
12 local test_metadata = {}; 12 local test_metadata = {};
13 local server_log_wait_time = 0.2; 13 local server_log_wait_time = 0.2;
14 local skip_server_startup_log = false; 14 local skip_server_startup_log = false;
15 local action_timeout = 5; 15 local action_timeout = 10;
16 local verse_log_levels = { "warn", "error" }; 16 local verse_log_levels = { "warn", "error" };
17 local quiet = false; 17 local quiet = false;
18 local force_summary = false; 18 local force_summary = false;
19 local serve_mode = false;
19 20
20 local property_rules = {}; 21 local property_rules = {};
21 22
22 local function apply_object_properties(class, name, object) 23 local function apply_object_properties(class, name, object)
23 for _, rule in ipairs(property_rules) do 24 for _, rule in ipairs(property_rules) do
95 table.insert(files, path.."/"..f); 96 table.insert(files, path.."/"..f);
96 end 97 end
97 end 98 end
98 elseif opt == "--summary" then 99 elseif opt == "--summary" then
99 force_summary = true; 100 force_summary = true;
101 elseif opt == "--serve" then
102 serve_mode = 8007;
103 elseif opt == "--serve-port" then
104 serve_mode = assert(tonumber(get_value()), "expected port number");
100 else 105 else
101 error("Unhandled command-line option: "..opt); 106 error("Unhandled command-line option: "..opt);
102 end 107 end
103 end 108 end
104 for _, file in ipairs(arg) do 109 for _, file in ipairs(arg) do
292 log_data("test-passed"); 297 log_data("test-passed");
293 end 298 end
294 return { name = script.title or script_name, status = status, reason = reason }; 299 return { name = script.title or script_name, status = status, reason = reason };
295 end 300 end
296 301
302
303 if serve_mode then
304 local have_serve, serve = pcall(require, "scansion.serve");
305
306 if not have_serve then
307 error("This version of scansion was not built with --with-server");
308 end
309
310 initialize_verse(function (e)
311 -- This function handles scansion errors,
312 -- but they shouldn't reach here anyway
313 end);
314 serve.run({ port = serve_mode }, run_test_script);
315 os.exit(0);
316 end
317
297 log_data("start", { metadata = test_metadata }); 318 log_data("start", { metadata = test_metadata });
298 319
299 local result_tally = { all = {} }; 320 local result_tally = { all = {} };
300 321
301 assert(#files > 0, "No test script provided"); 322 assert(#files > 0, "No test script provided");
309 table.insert(result_tally.all, ret); 330 table.insert(result_tally.all, ret);
310 end 331 end
311 332
312 log_data("end", { time = time(), summary = result_tally }); 333 log_data("end", { time = time(), summary = result_tally });
313 334
335
314 local exit_code = 0; 336 local exit_code = 0;
315 if result_tally.error then 337 if result_tally.error then
316 exit_code = 2; 338 exit_code = 2;
317 elseif result_tally.fail then 339 elseif result_tally.fail then
318 exit_code = 1; 340 exit_code = 1;
319 end 341 end
320 342
321 os.exit(exit_code); 343 os.exit(exit_code);
344
345

mercurial