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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -2
  3. data/CHANGELOG +9 -0
  4. data/Gemfile.lock +17 -11
  5. data/bin/roku +4 -8
  6. data/lib/roku_builder.rb +16 -24
  7. data/lib/roku_builder/config.rb +213 -0
  8. data/lib/roku_builder/config_parser.rb +304 -267
  9. data/lib/roku_builder/config_validator.rb +149 -126
  10. data/lib/roku_builder/controller.rb +34 -184
  11. data/lib/roku_builder/controller_commands.rb +85 -79
  12. data/lib/roku_builder/error_handler.rb +0 -11
  13. data/lib/roku_builder/errors.rb +12 -0
  14. data/lib/roku_builder/inspector.rb +6 -4
  15. data/lib/roku_builder/keyer.rb +1 -1
  16. data/lib/roku_builder/loader.rb +1 -1
  17. data/lib/roku_builder/logger.rb +32 -0
  18. data/lib/roku_builder/manifest_manager.rb +2 -2
  19. data/lib/roku_builder/monitor.rb +1 -1
  20. data/lib/roku_builder/options.rb +113 -0
  21. data/lib/roku_builder/stager.rb +2 -2
  22. data/lib/roku_builder/tester.rb +57 -11
  23. data/lib/roku_builder/util.rb +3 -4
  24. data/lib/roku_builder/version.rb +1 -1
  25. data/roku_builder.gemspec +2 -1
  26. data/test/roku_builder/test_config.rb +168 -0
  27. data/test/roku_builder/test_config_parser.rb +347 -394
  28. data/test/roku_builder/test_config_validator.rb +193 -190
  29. data/test/roku_builder/test_controller.rb +59 -178
  30. data/test/roku_builder/test_controller_commands.rb +407 -394
  31. data/test/roku_builder/test_error_handler.rb +67 -69
  32. data/test/roku_builder/test_files/config_test/bad.json +2 -0
  33. data/test/roku_builder/test_files/config_test/child.json +11 -0
  34. data/test/roku_builder/test_files/config_test/config.json +29 -0
  35. data/test/roku_builder/test_files/config_test/non_json.json +1 -0
  36. data/test/roku_builder/test_files/config_test/parent.json +21 -0
  37. data/test/roku_builder/test_files/config_test/parent_projects.json +35 -0
  38. data/test/roku_builder/test_files/manifest_manager_test/manifest_template_2 +1 -1
  39. data/test/roku_builder/test_helper.rb +55 -45
  40. data/test/roku_builder/test_inspector.rb +278 -213
  41. data/test/roku_builder/test_keyer.rb +144 -147
  42. data/test/roku_builder/test_linker.rb +91 -95
  43. data/test/roku_builder/test_loader.rb +279 -289
  44. data/test/roku_builder/test_logger.rb +47 -0
  45. data/test/roku_builder/test_manifest_manager.rb +92 -94
  46. data/test/roku_builder/test_monitor.rb +101 -103
  47. data/test/roku_builder/test_navigator.rb +240 -245
  48. data/test/roku_builder/test_options.rb +156 -0
  49. data/test/roku_builder/test_packager.rb +108 -108
  50. data/test/roku_builder/test_profiler.rb +20 -19
  51. data/test/roku_builder/test_scripter.rb +83 -81
  52. data/test/roku_builder/test_stager.rb +299 -311
  53. data/test/roku_builder/test_tester.rb +112 -115
  54. data/test/roku_builder/test_util.rb +18 -17
  55. metadata +39 -6
  56. data/lib/roku_builder/config_manager.rb +0 -161
  57. 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
- 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 = RokuBuilder::ManifestManager.update_build(root_dir: root_dir)
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
- def test_manifest_manager_update_missing_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 = nil
21
- Time.stub(:now, Time.new(2001, 02, 01)) do
22
- build_version = RokuBuilder::ManifestManager.update_build(root_dir: root_dir)
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
- def test_manifest_manager_build_version
29
- root_dir = File.join(File.dirname(__FILE__), "test_files", "manifest_manager_test")
30
- FileUtils.cp(File.join(root_dir, "manifest_template"), File.join(root_dir, "manifest"))
31
- build_version = nil
32
- build_version = RokuBuilder::ManifestManager.build_version(root_dir: root_dir)
33
- assert_equal "010101.1", build_version
34
- FileUtils.rm(File.join(root_dir, "manifest"))
35
- end
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
- def test_manifest_manager_build_version_zip
38
- root_dir = File.join(File.dirname(__FILE__), "test_files", "manifest_manager_test", "test.zip")
39
- build_version = nil
40
- build_version = RokuBuilder::ManifestManager.build_version(root_dir: root_dir)
41
- assert_equal "010101.1", build_version
42
- end
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
- def test_manifest_manager_update_manifest
45
- root_dir = File.join(File.dirname(__FILE__), "test_files", "manifest_manager_test")
46
- FileUtils.cp(File.join(root_dir, "manifest_template"), File.join(root_dir, "manifest"))
47
- attrs = {
48
- title: "New Title",
49
- major_version: 2,
50
- minor_version: 2,
51
- build_version: "020202.0002",
52
- mm_icon_focus_hd: "pkg:/images/focus1.png",
53
- mm_icon_focus_sd: "pkg:/images/focus2.png"
54
- }
55
- RokuBuilder::ManifestManager.update_manifest(root_dir: root_dir, attributes: attrs)
56
- assert FileUtils.compare_file(File.join(root_dir, "manifest"), File.join(root_dir, "updated_title_manifest"))
57
- FileUtils.rm(File.join(root_dir, "manifest"))
58
- end
59
- def test_manifest_manager_update_manifest_overwrite
60
- root_dir = File.join(File.dirname(__FILE__), "test_files", "manifest_manager_test")
61
- attrs = {
62
- title: "New Title",
63
- major_version: 2,
64
- minor_version: 2,
65
- build_version: "020202.0002",
66
- mm_icon_focus_hd: "pkg:/images/focus1.png",
67
- mm_icon_focus_sd: "pkg:/images/focus2.png"
68
- }
69
- RokuBuilder::ManifestManager.update_manifest(root_dir: root_dir, attributes: attrs)
70
- RokuBuilder::ManifestManager.update_manifest(root_dir: root_dir, attributes: attrs)
71
- assert FileUtils.compare_file(File.join(root_dir, "manifest"), File.join(root_dir, "updated_title_manifest"))
72
- FileUtils.rm(File.join(root_dir, "manifest"))
73
- end
74
- def test_manifest_manager_update_manifest_partial
75
- root_dir = File.join(File.dirname(__FILE__), "test_files", "manifest_manager_test")
76
- attrs = {
77
- title: "New Title",
78
- major_version: 2,
79
- minor_version: 2,
80
- build_version: "020202.0002",
81
- mm_icon_focus_hd: "pkg:/images/focus1.png",
82
- mm_icon_focus_sd: "pkg:/images/focus2.png"
83
- }
84
- RokuBuilder::ManifestManager.update_manifest(root_dir: root_dir, attributes: attrs)
85
- attrs = {
86
- title: "New Title",
87
- }
88
- RokuBuilder::ManifestManager.update_manifest(root_dir: root_dir, attributes: attrs)
89
- assert FileUtils.compare_file(File.join(root_dir, "manifest"), File.join(root_dir, "updated_title_manifest"))
90
- FileUtils.rm(File.join(root_dir, "manifest"))
91
- end
92
- def test_manifest_manager_comment_empty
93
- root_dir = File.join(File.dirname(__FILE__), "test_files", "manifest_manager_test")
94
- FileUtils.cp(File.join(root_dir, "manifest_comments"), File.join(root_dir, "manifest"))
95
- result = {}
96
- result["#comment".to_sym] = nil
97
- result[:title] = "title"
98
- result[:other] = ""
99
- result[:other2] = "val#comment"
100
- result[:other3] = "#comment"
101
- manifest = RokuBuilder::ManifestManager.read_manifest(root_dir: root_dir)
102
- assert_equal result, manifest
103
- FileUtils.rm(File.join(root_dir, "manifest"))
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
- class MonitorTest < Minitest::Test
6
- def test_monitor_monit
7
- connection = Minitest::Mock.new
8
- device_config = {
9
- ip: "111.222.333",
10
- user: "user",
11
- password: "password",
12
- logger: Logger.new("/dev/null")
13
- }
14
- monitor = RokuBuilder::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
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
- readline = proc {
22
- sleep(0.1)
23
- "q"
24
- }
21
+ readline = proc {
22
+ sleep(0.1)
23
+ "q"
24
+ }
25
25
 
26
- Readline.stub(:readline, readline) do
27
- Net::Telnet.stub(:new, connection) do
28
- monitor.monitor(type: :main)
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
- connection.verify
33
- end
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
- 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
- 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
- end
50
+ end
52
51
 
53
- readline = proc {
54
- sleep(0.1)
55
- "q"
56
- }
52
+ readline = proc {
53
+ sleep(0.1)
54
+ "q"
55
+ }
57
56
 
58
- Readline.stub(:readline, readline) do
59
- Net::Telnet.stub(:new, connection) do
60
- monitor.stub(:manage_text, "") do
61
- monitor.monitor(type: :main)
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
- def test_monitor_monit_input
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
- readline = proc {
91
- @count ||= 0
92
- sleep(0.1)
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
- Readline.stub(:readline, readline) do
103
- Net::Telnet.stub(:new, connection) do
104
- monitor.monitor(type: :main)
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
- connection.verify
109
- end
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
- def test_monitor_manage_text
112
- mock = Minitest::Mock.new
113
- device_config = {
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
- mock.expect(:puts, nil, ["midline split\n"])
124
+ mock.expect(:puts, nil, ["midline split\n"])
128
125
 
129
- all_text = "midline "
130
- txt = "split\nBrightScript Debugger> "
126
+ all_text = "midline "
127
+ txt = "split\nBrightScript Debugger> "
131
128
 
132
- result = monitor.send(:manage_text, {all_text: all_text, txt: txt})
129
+ result = monitor.send(:manage_text, {all_text: all_text, txt: txt})
133
130
 
134
- assert_equal "", result
131
+ assert_equal "", result
135
132
 
136
- mock.verify
133
+ mock.verify
137
134
 
135
+ end
138
136
  end
139
137
  end