4 local time = require "socket".gettime; |
4 local time = require "socket".gettime; |
5 local sleep = require "socket".sleep; |
5 local sleep = require "socket".sleep; |
6 |
6 |
7 local result_log_filename = nil; |
7 local result_log_filename = nil; |
8 local server_log_reader = nil; |
8 local server_log_reader = nil; |
|
9 local test_metadata = {}; |
9 local server_log_wait_time = 0.2; |
10 local server_log_wait_time = 0.2; |
10 |
11 |
11 local property_rules = {}; |
12 local property_rules = {}; |
12 |
13 |
13 local function apply_object_properties(class, name, object) |
14 local function apply_object_properties(class, name, object) |
52 last_line_time = time(); |
53 last_line_time = time(); |
53 end |
54 end |
54 end |
55 end |
55 return new_lines; |
56 return new_lines; |
56 end |
57 end |
|
58 elseif opt == "--tag" then |
|
59 local tag = get_value(); |
|
60 local key, value = tag:match("^([^=]+):(.+)$"); |
|
61 if key and value then |
|
62 test_metadata[key] = value; |
|
63 else |
|
64 error("Unable to parse tag: "..tag); |
|
65 end |
57 else |
66 else |
58 error("Unhandled command-line option: "..opt); |
67 error("Unhandled command-line option: "..opt); |
59 end |
68 end |
60 end |
69 end |
61 assert(#arg > 0, "No test script provided"); |
70 assert(#arg > 0, "No test script provided"); |
62 assert(#arg < 2, "Too many parameters"); |
71 assert(#arg < 2, "Too many parameters"); |
|
72 if not test_metadata["Name"] then |
|
73 test_metadata["Name"] = arg[1]; |
|
74 end |
63 end |
75 end |
64 |
76 |
65 function read_script() |
77 function read_script() |
66 io.input(arg[1]); |
78 io.input(arg[1]); |
67 return io.read("*a"); |
79 return io.read("*a"); |
176 result_log:write(" ", json.encode(entry), ",\n"); |
188 result_log:write(" ", json.encode(entry), ",\n"); |
177 result_log:flush(); |
189 result_log:flush(); |
178 end |
190 end |
179 end |
191 end |
180 |
192 |
181 log_data("start"); |
193 log_data("start", { metadata = test_metadata }); |
182 local ok, result, err = pcall(main, log_data); |
194 local ok, result, err = pcall(main, log_data); |
183 |
195 |
184 local exit_code = 0; |
196 local exit_code = 0; |
185 if not ok then |
197 if not ok then |
186 print("TEST ERROR:", result); |
198 print("TEST ERROR:", result); |