lib/roku_builder/tester.rb in roku_builder-3.3.2 vs lib/roku_builder/tester.rb in roku_builder-3.3.3

- old
+ new

@@ -3,10 +3,15 @@ # Method for running unit tests # This is intended to be used with the brstest librbary but should work # with other testing libraries class Tester < Util + def init() + @end_reg = /\*\*\*\*\* ENDING TESTS \*\*\*\*\*/ + @start_reg = /\*\*\*\*\* STARTING TESTS \*\*\*\*\*/ + end + # Run tests and report results # @param sideload_config [Hash] The config for sideloading the app def run_tests(sideload_config:) telnet_config ={ 'Host' => @roku_ip_address, @@ -16,17 +21,27 @@ loader = Loader.new(**@device_config) connection = Net::Telnet.new(telnet_config) loader.sideload(**sideload_config) in_tests = false - end_reg = /\*\*\*\*\* ENDING TESTS \*\*\*\*\*/ - connection.waitfor(end_reg) do |txt| - txt.split("\n").each do |line| - in_tests = false if line =~ end_reg - @logger.unknown line if in_tests - in_tests = true if line =~ /\*\*\*\*\* STARTING TESTS \*\*\*\*\*/ - end + connection.waitfor(@end_reg) do |txt| + in_tests = handle_text(txt: txt, in_tests: in_tests) end connection.puts("cont\n") + end + + private + + # Handel testing text + # @param txt [String] current text from telnet + # @param in_tests [Boolean] currently parsing test text + # @return [Boolean] currently parsing test text + def handle_text(txt:, in_tests:) + txt.split("\n").each do |line| + in_tests = false if line =~ @end_reg + @logger.unknown line if in_tests + in_tests = true if line =~ @start_reg + end + in_tests end end end