roku_builder 3.12.8 → 3.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/CHANGELOG +9 -0
- data/Gemfile.lock +17 -11
- data/bin/roku +4 -8
- data/lib/roku_builder.rb +16 -24
- data/lib/roku_builder/config.rb +213 -0
- data/lib/roku_builder/config_parser.rb +304 -267
- data/lib/roku_builder/config_validator.rb +149 -126
- data/lib/roku_builder/controller.rb +34 -184
- data/lib/roku_builder/controller_commands.rb +85 -79
- data/lib/roku_builder/error_handler.rb +0 -11
- data/lib/roku_builder/errors.rb +12 -0
- data/lib/roku_builder/inspector.rb +6 -4
- data/lib/roku_builder/keyer.rb +1 -1
- data/lib/roku_builder/loader.rb +1 -1
- data/lib/roku_builder/logger.rb +32 -0
- data/lib/roku_builder/manifest_manager.rb +2 -2
- data/lib/roku_builder/monitor.rb +1 -1
- data/lib/roku_builder/options.rb +113 -0
- data/lib/roku_builder/stager.rb +2 -2
- data/lib/roku_builder/tester.rb +57 -11
- data/lib/roku_builder/util.rb +3 -4
- data/lib/roku_builder/version.rb +1 -1
- data/roku_builder.gemspec +2 -1
- data/test/roku_builder/test_config.rb +168 -0
- data/test/roku_builder/test_config_parser.rb +347 -394
- data/test/roku_builder/test_config_validator.rb +193 -190
- data/test/roku_builder/test_controller.rb +59 -178
- data/test/roku_builder/test_controller_commands.rb +407 -394
- data/test/roku_builder/test_error_handler.rb +67 -69
- data/test/roku_builder/test_files/config_test/bad.json +2 -0
- data/test/roku_builder/test_files/config_test/child.json +11 -0
- data/test/roku_builder/test_files/config_test/config.json +29 -0
- data/test/roku_builder/test_files/config_test/non_json.json +1 -0
- data/test/roku_builder/test_files/config_test/parent.json +21 -0
- data/test/roku_builder/test_files/config_test/parent_projects.json +35 -0
- data/test/roku_builder/test_files/manifest_manager_test/manifest_template_2 +1 -1
- data/test/roku_builder/test_helper.rb +55 -45
- data/test/roku_builder/test_inspector.rb +278 -213
- data/test/roku_builder/test_keyer.rb +144 -147
- data/test/roku_builder/test_linker.rb +91 -95
- data/test/roku_builder/test_loader.rb +279 -289
- data/test/roku_builder/test_logger.rb +47 -0
- data/test/roku_builder/test_manifest_manager.rb +92 -94
- data/test/roku_builder/test_monitor.rb +101 -103
- data/test/roku_builder/test_navigator.rb +240 -245
- data/test/roku_builder/test_options.rb +156 -0
- data/test/roku_builder/test_packager.rb +108 -108
- data/test/roku_builder/test_profiler.rb +20 -19
- data/test/roku_builder/test_scripter.rb +83 -81
- data/test/roku_builder/test_stager.rb +299 -311
- data/test/roku_builder/test_tester.rb +112 -115
- data/test/roku_builder/test_util.rb +18 -17
- metadata +39 -6
- data/lib/roku_builder/config_manager.rb +0 -161
- data/test/roku_builder/test_config_manager.rb +0 -372
@@ -0,0 +1,47 @@
|
|
1
|
+
# ********** Copyright Viacom, Inc. Apache 2.0 **********
|
2
|
+
|
3
|
+
require_relative "test_helper.rb"
|
4
|
+
|
5
|
+
module RokuBuilder
|
6
|
+
class LoggerTest < Minitest::Test
|
7
|
+
|
8
|
+
def test_logger
|
9
|
+
logger_a = Logger.instance
|
10
|
+
logger_b = Logger.instance
|
11
|
+
assert_equal logger_a, logger_b
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_set_debug
|
15
|
+
logger = Minitest::Mock.new
|
16
|
+
Logger.class_variable_set(:@@instance, logger)
|
17
|
+
logger.expect(:level=, nil, [::Logger::DEBUG])
|
18
|
+
Logger.set_debug
|
19
|
+
logger.verify
|
20
|
+
Logger.set_testing
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_set_info
|
24
|
+
logger = Minitest::Mock.new
|
25
|
+
Logger.class_variable_set(:@@instance, logger)
|
26
|
+
logger.expect(:level=, nil, [::Logger::INFO])
|
27
|
+
Logger.set_info
|
28
|
+
logger.verify
|
29
|
+
Logger.set_testing
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_set_warn
|
33
|
+
logger = Minitest::Mock.new
|
34
|
+
Logger.class_variable_set(:@@instance, logger)
|
35
|
+
logger.expect(:level=, nil, [::Logger::WARN])
|
36
|
+
Logger.set_warn
|
37
|
+
logger.verify
|
38
|
+
Logger.set_testing
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_logger_testing
|
42
|
+
Logger.set_testing
|
43
|
+
logger = Logger.instance
|
44
|
+
assert_equal "/dev/null", logger.instance_variable_get(:@logdev).instance_variable_get(:@filename)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -1,105 +1,103 @@
|
|
1
1
|
# ********** Copyright Viacom, Inc. Apache 2.0 **********
|
2
2
|
|
3
3
|
require_relative "test_helper.rb"
|
4
|
-
|
5
|
-
class ManifestManagerTest < Minitest::Test
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
module RokuBuilder
|
5
|
+
class ManifestManagerTest < Minitest::Test
|
6
|
+
def test_manifest_manager_update
|
7
|
+
root_dir = File.join(File.dirname(__FILE__), "test_files", "manifest_manager_test")
|
8
|
+
FileUtils.cp(File.join(root_dir, "manifest_template"), File.join(root_dir, "manifest"))
|
9
|
+
build_version = nil
|
10
|
+
Time.stub(:now, Time.new(2001, 02, 01)) do
|
11
|
+
build_version = ManifestManager.update_build(root_dir: root_dir)
|
12
|
+
end
|
13
|
+
assert_equal "020101.2", build_version
|
14
|
+
FileUtils.rm(File.join(root_dir, "manifest"))
|
12
15
|
end
|
13
|
-
assert_equal "020101.2", build_version
|
14
|
-
FileUtils.rm(File.join(root_dir, "manifest"))
|
15
|
-
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
def test_manifest_manager_update_single_part_build_number
|
18
|
+
root_dir = File.join(File.dirname(__FILE__), "test_files", "manifest_manager_test")
|
19
|
+
FileUtils.cp(File.join(root_dir, "manifest_template_2"), File.join(root_dir, "manifest"))
|
20
|
+
build_version = ManifestManager.update_build(root_dir: root_dir)
|
21
|
+
assert_equal "2", build_version
|
22
|
+
FileUtils.rm(File.join(root_dir, "manifest"))
|
23
23
|
end
|
24
|
-
assert_equal "020101.0001", build_version
|
25
|
-
FileUtils.rm(File.join(root_dir, "manifest"))
|
26
|
-
end
|
27
24
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
25
|
+
def test_manifest_manager_build_version
|
26
|
+
root_dir = File.join(File.dirname(__FILE__), "test_files", "manifest_manager_test")
|
27
|
+
FileUtils.cp(File.join(root_dir, "manifest_template"), File.join(root_dir, "manifest"))
|
28
|
+
build_version = nil
|
29
|
+
build_version = ManifestManager.build_version(root_dir: root_dir)
|
30
|
+
assert_equal "010101.1", build_version
|
31
|
+
FileUtils.rm(File.join(root_dir, "manifest"))
|
32
|
+
end
|
36
33
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
34
|
+
def test_manifest_manager_build_version_zip
|
35
|
+
root_dir = File.join(File.dirname(__FILE__), "test_files", "manifest_manager_test", "test.zip")
|
36
|
+
build_version = nil
|
37
|
+
build_version = ManifestManager.build_version(root_dir: root_dir)
|
38
|
+
assert_equal "010101.1", build_version
|
39
|
+
end
|
43
40
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
41
|
+
def test_manifest_manager_update_manifest
|
42
|
+
root_dir = File.join(File.dirname(__FILE__), "test_files", "manifest_manager_test")
|
43
|
+
FileUtils.cp(File.join(root_dir, "manifest_template"), File.join(root_dir, "manifest"))
|
44
|
+
attrs = {
|
45
|
+
title: "New Title",
|
46
|
+
major_version: 2,
|
47
|
+
minor_version: 2,
|
48
|
+
build_version: "020202.0002",
|
49
|
+
mm_icon_focus_hd: "pkg:/images/focus1.png",
|
50
|
+
mm_icon_focus_sd: "pkg:/images/focus2.png"
|
51
|
+
}
|
52
|
+
ManifestManager.update_manifest(root_dir: root_dir, attributes: attrs)
|
53
|
+
assert FileUtils.compare_file(File.join(root_dir, "manifest"), File.join(root_dir, "updated_title_manifest"))
|
54
|
+
FileUtils.rm(File.join(root_dir, "manifest"))
|
55
|
+
end
|
56
|
+
def test_manifest_manager_update_manifest_overwrite
|
57
|
+
root_dir = File.join(File.dirname(__FILE__), "test_files", "manifest_manager_test")
|
58
|
+
attrs = {
|
59
|
+
title: "New Title",
|
60
|
+
major_version: 2,
|
61
|
+
minor_version: 2,
|
62
|
+
build_version: "020202.0002",
|
63
|
+
mm_icon_focus_hd: "pkg:/images/focus1.png",
|
64
|
+
mm_icon_focus_sd: "pkg:/images/focus2.png"
|
65
|
+
}
|
66
|
+
ManifestManager.update_manifest(root_dir: root_dir, attributes: attrs)
|
67
|
+
ManifestManager.update_manifest(root_dir: root_dir, attributes: attrs)
|
68
|
+
assert FileUtils.compare_file(File.join(root_dir, "manifest"), File.join(root_dir, "updated_title_manifest"))
|
69
|
+
FileUtils.rm(File.join(root_dir, "manifest"))
|
70
|
+
end
|
71
|
+
def test_manifest_manager_update_manifest_partial
|
72
|
+
root_dir = File.join(File.dirname(__FILE__), "test_files", "manifest_manager_test")
|
73
|
+
attrs = {
|
74
|
+
title: "New Title",
|
75
|
+
major_version: 2,
|
76
|
+
minor_version: 2,
|
77
|
+
build_version: "020202.0002",
|
78
|
+
mm_icon_focus_hd: "pkg:/images/focus1.png",
|
79
|
+
mm_icon_focus_sd: "pkg:/images/focus2.png"
|
80
|
+
}
|
81
|
+
ManifestManager.update_manifest(root_dir: root_dir, attributes: attrs)
|
82
|
+
attrs = {
|
83
|
+
title: "New Title",
|
84
|
+
}
|
85
|
+
ManifestManager.update_manifest(root_dir: root_dir, attributes: attrs)
|
86
|
+
assert FileUtils.compare_file(File.join(root_dir, "manifest"), File.join(root_dir, "updated_title_manifest"))
|
87
|
+
FileUtils.rm(File.join(root_dir, "manifest"))
|
88
|
+
end
|
89
|
+
def test_manifest_manager_comment_empty
|
90
|
+
root_dir = File.join(File.dirname(__FILE__), "test_files", "manifest_manager_test")
|
91
|
+
FileUtils.cp(File.join(root_dir, "manifest_comments"), File.join(root_dir, "manifest"))
|
92
|
+
result = {}
|
93
|
+
result["#comment".to_sym] = nil
|
94
|
+
result[:title] = "title"
|
95
|
+
result[:other] = ""
|
96
|
+
result[:other2] = "val#comment"
|
97
|
+
result[:other3] = "#comment"
|
98
|
+
manifest = ManifestManager.read_manifest(root_dir: root_dir)
|
99
|
+
assert_equal result, manifest
|
100
|
+
FileUtils.rm(File.join(root_dir, "manifest"))
|
101
|
+
end
|
104
102
|
end
|
105
103
|
end
|
@@ -2,138 +2,136 @@
|
|
2
2
|
|
3
3
|
require_relative "test_helper.rb"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
5
|
+
module RokuBuilder
|
6
|
+
class MonitorTest < Minitest::Test
|
7
|
+
def test_monitor_monit
|
8
|
+
connection = Minitest::Mock.new
|
9
|
+
device_config = {
|
10
|
+
ip: "111.222.333",
|
11
|
+
user: "user",
|
12
|
+
password: "password"
|
13
|
+
}
|
14
|
+
monitor = Monitor.new(**device_config)
|
15
|
+
|
16
|
+
connection.expect(:waitfor, nil) do |config|
|
17
|
+
assert_equal(/./, config['Match'])
|
18
|
+
assert_equal(false, config['Timeout'])
|
19
|
+
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
readline = proc {
|
22
|
+
sleep(0.1)
|
23
|
+
"q"
|
24
|
+
}
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
Readline.stub(:readline, readline) do
|
27
|
+
Net::Telnet.stub(:new, connection) do
|
28
|
+
monitor.monitor(type: :main)
|
29
|
+
end
|
29
30
|
end
|
31
|
+
|
32
|
+
connection.verify
|
30
33
|
end
|
31
34
|
|
32
|
-
|
33
|
-
|
35
|
+
def test_monitor_monit_and_manage
|
36
|
+
connection = Minitest::Mock.new
|
37
|
+
device_config = {
|
38
|
+
ip: "111.222.333",
|
39
|
+
user: "user",
|
40
|
+
password: "password"
|
41
|
+
}
|
42
|
+
monitor = Monitor.new(**device_config)
|
43
|
+
monitor.instance_variable_set(:@show_prompt, true)
|
34
44
|
|
35
|
-
|
36
|
-
connection = Minitest::Mock.new
|
37
|
-
device_config = {
|
38
|
-
ip: "111.222.333",
|
39
|
-
user: "user",
|
40
|
-
password: "password",
|
41
|
-
logger: Logger.new("/dev/null")
|
42
|
-
}
|
43
|
-
monitor = RokuBuilder::Monitor.new(**device_config)
|
44
|
-
monitor.instance_variable_set(:@show_prompt, true)
|
45
|
-
|
46
|
-
connection.expect(:waitfor, nil) do |config, &blk|
|
45
|
+
connection.expect(:waitfor, nil) do |config, &blk|
|
47
46
|
assert_equal(/./, config['Match'])
|
48
47
|
assert_equal(false, config['Timeout'])
|
49
48
|
txt = "Fake Text"
|
50
49
|
blk.call(txt) == ""
|
51
|
-
|
50
|
+
end
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
readline = proc {
|
53
|
+
sleep(0.1)
|
54
|
+
"q"
|
55
|
+
}
|
57
56
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
Readline.stub(:readline, readline) do
|
58
|
+
Net::Telnet.stub(:new, connection) do
|
59
|
+
monitor.stub(:manage_text, "") do
|
60
|
+
monitor.monitor(type: :main)
|
61
|
+
end
|
62
62
|
end
|
63
63
|
end
|
64
|
-
end
|
65
|
-
|
66
|
-
connection.verify
|
67
|
-
end
|
68
64
|
|
69
|
-
|
70
|
-
connection = Minitest::Mock.new
|
71
|
-
device_config = {
|
72
|
-
ip: "111.222.333",
|
73
|
-
user: "user",
|
74
|
-
password: "password",
|
75
|
-
logger: Logger.new("/dev/null")
|
76
|
-
}
|
77
|
-
monitor = RokuBuilder::Monitor.new(**device_config)
|
78
|
-
monitor.instance_variable_set(:@show_prompt, true)
|
79
|
-
|
80
|
-
connection.expect(:waitfor, nil) do |config|
|
81
|
-
assert_equal(/./, config['Match'])
|
82
|
-
assert_equal(false, config['Timeout'])
|
83
|
-
end
|
84
|
-
connection.expect(:puts, nil) do |text|
|
85
|
-
assert_equal("text", text)
|
86
|
-
monitor.instance_variable_set(:@show_prompt, true)
|
65
|
+
connection.verify
|
87
66
|
end
|
88
67
|
|
68
|
+
def test_monitor_monit_input
|
69
|
+
connection = Minitest::Mock.new
|
70
|
+
device_config = {
|
71
|
+
ip: "111.222.333",
|
72
|
+
user: "user",
|
73
|
+
password: "password"
|
74
|
+
}
|
75
|
+
monitor = Monitor.new(**device_config)
|
76
|
+
monitor.instance_variable_set(:@show_prompt, true)
|
89
77
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
case @count
|
94
|
-
when 0
|
95
|
-
@count += 1
|
96
|
-
"text"
|
97
|
-
else
|
98
|
-
"q"
|
78
|
+
connection.expect(:waitfor, nil) do |config|
|
79
|
+
assert_equal(/./, config['Match'])
|
80
|
+
assert_equal(false, config['Timeout'])
|
99
81
|
end
|
100
|
-
|
82
|
+
connection.expect(:puts, nil) do |text|
|
83
|
+
assert_equal("text", text)
|
84
|
+
monitor.instance_variable_set(:@show_prompt, true)
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
readline = proc {
|
89
|
+
@count ||= 0
|
90
|
+
sleep(0.1)
|
91
|
+
case @count
|
92
|
+
when 0
|
93
|
+
@count += 1
|
94
|
+
"text"
|
95
|
+
else
|
96
|
+
"q"
|
97
|
+
end
|
98
|
+
}
|
101
99
|
|
102
|
-
|
103
|
-
|
104
|
-
|
100
|
+
Readline.stub(:readline, readline) do
|
101
|
+
Net::Telnet.stub(:new, connection) do
|
102
|
+
monitor.monitor(type: :main)
|
103
|
+
end
|
105
104
|
end
|
105
|
+
|
106
|
+
connection.verify
|
106
107
|
end
|
107
108
|
|
108
|
-
|
109
|
-
|
109
|
+
def test_monitor_manage_text
|
110
|
+
mock = Minitest::Mock.new
|
111
|
+
device_config = {
|
112
|
+
ip: "111.222.333",
|
113
|
+
user: "user",
|
114
|
+
password: "password"
|
115
|
+
}
|
116
|
+
monitor = Monitor.new(**device_config)
|
117
|
+
monitor.instance_variable_set(:@show_prompt, true)
|
118
|
+
monitor.instance_variable_set(:@mock, mock)
|
110
119
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
ip: "111.222.333",
|
115
|
-
user: "user",
|
116
|
-
password: "password",
|
117
|
-
logger: Logger.new("/dev/null")
|
118
|
-
}
|
119
|
-
monitor = RokuBuilder::Monitor.new(**device_config)
|
120
|
-
monitor.instance_variable_set(:@show_prompt, true)
|
121
|
-
monitor.instance_variable_set(:@mock, mock)
|
122
|
-
|
123
|
-
def monitor.puts(input)
|
124
|
-
@mock.puts(input)
|
125
|
-
end
|
120
|
+
def monitor.puts(input)
|
121
|
+
@mock.puts(input)
|
122
|
+
end
|
126
123
|
|
127
|
-
|
124
|
+
mock.expect(:puts, nil, ["midline split\n"])
|
128
125
|
|
129
|
-
|
130
|
-
|
126
|
+
all_text = "midline "
|
127
|
+
txt = "split\nBrightScript Debugger> "
|
131
128
|
|
132
|
-
|
129
|
+
result = monitor.send(:manage_text, {all_text: all_text, txt: txt})
|
133
130
|
|
134
|
-
|
131
|
+
assert_equal "", result
|
135
132
|
|
136
|
-
|
133
|
+
mock.verify
|
137
134
|
|
135
|
+
end
|
138
136
|
end
|
139
137
|
end
|