Class: RokuBuilder::Tester
- Extended by:
- Plugin
- Defined in:
- lib/roku_builder/plugins/tester.rb
Overview
Method for running unit tests This is intended to be used with the brstest librbary but should work with other testing libraries
Class Method Summary collapse
Instance Method Summary collapse
-
#init ⇒ Object
Initialize starting and ending regular expressions.
-
#test(options:) ⇒ Object
Run tests and report results.
Methods included from Plugin
commands, dependencies, parse_options, validate
Methods inherited from Util
Constructor Details
This class inherits a constructor from RokuBuilder::Util
Class Method Details
.commands ⇒ Object
11 12 13 |
# File 'lib/roku_builder/plugins/tester.rb', line 11 def self.commands {test: {device: true, source: true, stage: true}} end |
.dependencies ⇒ Object
22 23 24 |
# File 'lib/roku_builder/plugins/tester.rb', line 22 def self.dependencies [Loader, Linker] end |
.parse_options(parser:, options:) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/roku_builder/plugins/tester.rb', line 15 def self.(parser:, options:) parser.separator "Commands:" parser.on("-t", "--test", "Test an app") do [:test] = true end end |
Instance Method Details
#init ⇒ Object
Initialize starting and ending regular expressions
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/roku_builder/plugins/tester.rb', line 27 def init() @end_reg = /\*+\s*End testing\s*\*+/ @start_reg = /\*+\s*Start testing\s*\*+/ @test_logger = ::Logger.new(STDOUT) @test_logger.formatter = proc {|_severity, _datetime, _progname, msg| "%s\n\r" % [msg] } @in_tests = false @logs = [] end |
#test(options:) ⇒ Object
Run tests and report results
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/roku_builder/plugins/tester.rb', line 40 def test(options:) get_device do |device| loader = Loader.new(config: @config) loader.sideload(options: , device: device) linker = Linker.new(config: @config) linker.deeplink(options: Options.new(options: {deeplink: "RunTests:true"}), device: device) telnet_config ={ 'Host' => device.ip, 'Port' => 8085 } connection = Net::Telnet.new(telnet_config) connection.waitfor(@end_reg) do |txt| handle_text(txt: txt) end print_logs connection.puts("cont\n") end end |