Sha256: d3d8bdce71995c65e06eb91725d673eede4647544fa9c9374e31d831419e1ab3

Contents?: true

Size: 1.47 KB

Versions: 9

Compression:

Stored size: 1.47 KB

Contents

# ********** Copyright Viacom, Inc. Apache 2.0 **********

module RokuBuilder

  # 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

    # Initialize starting and ending regular expressions
    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,
        'Port' => 8085
      }

      loader = Loader.new(**@device_config)
      connection = Net::Telnet.new(telnet_config)
      code, _build_version = loader.sideload(**sideload_config)

      if code == SUCCESS
        in_tests = false
        connection.waitfor(@end_reg) do |txt|
          in_tests = handle_text(txt: txt, in_tests: in_tests)
        end
        connection.puts("cont\n")
      end
    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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
roku_builder-3.12.8 lib/roku_builder/tester.rb
roku_builder-3.12.7 lib/roku_builder/tester.rb
roku_builder-3.12.6 lib/roku_builder/tester.rb
roku_builder-3.12.5 lib/roku_builder/tester.rb
roku_builder-3.12.4 lib/roku_builder/tester.rb
roku_builder-3.12.2 lib/roku_builder/tester.rb
roku_builder-3.12.1 lib/roku_builder/tester.rb
roku_builder-3.12.0 lib/roku_builder/tester.rb
roku_builder-3.11.1 lib/roku_builder/tester.rb