Sha256: f67fb5078ecb83c7ce095868553266192167682a43ae512af3c3b7841c3ad1b0

Contents?: true

Size: 1.56 KB

Versions: 7

Compression:

Stored size: 1.56 KB

Contents

# Copyright (c) 2023 M.J.N. Corino, The Netherlands
#
# This software is released under the MIT license.

require 'test/unit'
require 'test/unit/ui/console/testrunner'
require 'wx'

module WxRuby

  module Test

    class App < Wx::App
      def initialize(test_runner, start_mtd)
        super()
        @test_runner = test_runner
        @start_mtd = start_mtd
      end

      def on_init
        @result = @start_mtd.bind(@test_runner).call
        false
      end

      attr_reader :result
    end

    if defined? ::IntelliJ
      require 'test/unit/ui/teamcity/testrunner'
      BaseRunner = ::Test::Unit::UI::TeamCity::TestRunner
    else
      BaseRunner = ::Test::Unit::UI::Console::TestRunner
    end

    class Runner < BaseRunner

      org_start_mtd = instance_method :start
      define_method :start do
        (app = WxRuby::Test::App.new(self, org_start_mtd)).run
        app.result
      end

    end

  end

end

module Test
  module Unit
    AutoRunner.register_runner(:wxapp) do |auto_runner|
      WxRuby::Test::Runner
    end
    AutoRunner.default_runner = :wxapp
    if defined? ::IntelliJ
      class AutoRunner
        alias :wx_initialize :initialize
        private :wx_initialize

        def initialize(*args)
          wx_initialize(*args)
          @runner = AutoRunner.default_runner
        end
      end
    end

    class TestCase

      def self.is_ci_build?
        !!ENV['GITHUB_ACTION']
      end

      def is_ci_build?
        TestCase.is_ci_build?
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wxruby3-0.9.7-x64-mingw-ucrt tests/lib/wxapp_runner.rb
wxruby3-0.9.5-x64-mingw-ucrt tests/lib/wxapp_runner.rb
wxruby3-0.9.4-x64-mingw-ucrt tests/lib/wxapp_runner.rb
wxruby3-0.9.3-x64-mingw-ucrt tests/lib/wxapp_runner.rb
wxruby3-0.9.2-x64-mingw-ucrt tests/lib/wxapp_runner.rb
wxruby3-0.9.1-x64-mingw-ucrt tests/lib/wxapp_runner.rb
wxruby3-0.9.0-x64-mingw-ucrt tests/lib/wxapp_runner.rb