-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathsim_test_fixture.rb
More file actions
43 lines (29 loc) · 1.02 KB
/
sim_test_fixture.rb
File metadata and controls
43 lines (29 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require 'open3'
test_file = ARGV.shift
mdb_command = ARGV.shift
timeout = ARGV.shift
stdin, stdout, stderr, wait_thr = Open3.popen3(mdb_command)
stdin.puts "Device #{ARGV.shift}"
stdin.puts "Hwtool #{ARGV.shift}"
ARGV.each_slice(2) do | opt, val |
stdin.puts "set #{opt} #{val}"
end
stdin.puts "Program #{test_file}"
stdin.puts "Break UnityHelperDeadLoop"
stdin.puts "Run"
stdin.puts "Wait #{timeout}"
stdin.puts "Quit"
# Filter out MDB Java logr and NetBeans errors
errors = stderr.readlines.reject { | line | line.match(/(logr|dumb|Preferences)/)}
result = stdout.readlines
Process.waitall
# Remove command prompts
result = result.map {|s| s.gsub(/^>/, "")}
# Results start 2 lines after Running, and end with OK or FAIL
test_start = result.find_index { |line| line.match(/^Running/) }
test_status = result.find_index { |line| line.match(/^(?:OK|FAIL)\n/) }
if (test_start != nil) & (test_status != nil)
result = result[test_start + 2 , (test_status - test_start - 1)]
end
STDOUT.print result.join()
STDERR.print errors.join()