Sha256: bc4ab507a9b4f131d6ddc3e50070862974ea6e5a643a5f621ad3c3d70f176c8a

Contents?: true

Size: 1.8 KB

Versions: 18

Compression:

Stored size: 1.8 KB

Contents

require 'aruba/api'

module Autoproj
    # Minitest-usable Aruba wrapper
    #
    # Aruba 0.14 is incompatible with Minitest because of their definition
    # of the #run method This change hacks around the problem, by moving
    # the Aruba API to a side stub object.
    #
    # The run methods are renamed as they have been renamed in Aruba 1.0
    # alpha, run -> run_command and run_simple -> run_command_and_stop
    module ArubaMinitest
        class API
            include ::Aruba::Api
        end

        def setup
            super
            @aruba_api = API.new
            @aruba_api.setup_aruba
        end

        def teardown
            stop_all_commands
            super
        end

        def run_command_and_stop(*args, fail_on_error: true)
            cmd = run_command(*args)
            cmd.stop
            if fail_on_error
                assert_command_finished_successfully(cmd)
            end
            cmd
        end

        def run_command(*args)
            @aruba_api.run(*args)
        end

        def chmod(*args) # also defined by Rake
            @aruba_api.chmod(*args)
        end

        def method_missing(m, *args, &block)
            if @aruba_api.respond_to?(m)
                return @aruba_api.send(m, *args, &block)
            else
                super
            end
        end

        def assert_command_stops(cmd, fail_on_error: true)
            cmd.stop
            if fail_on_error
                assert_command_finished_successfully(cmd)
            end
        end

        def assert_command_finished_successfully(cmd)
            refute cmd.timed_out?, "#{cmd} timed out on stop"
            assert_equal 0, cmd.exit_status, "#{cmd} finished with a non-zero exit status (#{cmd.exit_status})\n-- STDOUT\n#{cmd.stdout}\n-- STDERR\n#{cmd.stderr}"
        end
    end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
autoproj-2.9.0 lib/autoproj/aruba_minitest.rb
autoproj-2.8.8 lib/autoproj/aruba_minitest.rb
autoproj-2.8.7 lib/autoproj/aruba_minitest.rb
autoproj-2.8.6 lib/autoproj/aruba_minitest.rb
autoproj-2.8.5 lib/autoproj/aruba_minitest.rb
autoproj-2.8.5.b1 lib/autoproj/aruba_minitest.rb
autoproj-2.8.4 lib/autoproj/aruba_minitest.rb
autoproj-2.8.3 lib/autoproj/aruba_minitest.rb
autoproj-2.8.2 lib/autoproj/aruba_minitest.rb
autoproj-2.8.1 lib/autoproj/aruba_minitest.rb
autoproj-2.8.0 lib/autoproj/aruba_minitest.rb
autoproj-2.7.1 lib/autoproj/aruba_minitest.rb
autoproj-2.7.0 lib/autoproj/aruba_minitest.rb
autoproj-2.6.1 lib/autoproj/aruba_minitest.rb
autoproj-2.6.0 lib/autoproj/aruba_minitest.rb
autoproj-2.5.1 lib/autoproj/aruba_minitest.rb
autoproj-2.5.0 lib/autoproj/aruba_minitest.rb
autoproj-2.5.0.pre1 lib/autoproj/aruba_minitest.rb