Module: Autoproj::ArubaMinitest

Defined in:
lib/autoproj/aruba_minitest.rb

Overview

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

Defined Under Namespace

Classes: API

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/autoproj/aruba_minitest.rb', line 58

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

Instance Method Details

#assert_command_finished_successfully(cmd) ⇒ Object



71
72
73
74
# File 'lib/autoproj/aruba_minitest.rb', line 71

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

#assert_command_stops(cmd, fail_on_error: true) ⇒ Object



66
67
68
69
# File 'lib/autoproj/aruba_minitest.rb', line 66

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

#cd(*args) ⇒ Object

also defined by Rake



50
51
52
# File 'lib/autoproj/aruba_minitest.rb', line 50

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

#chmod(*args) ⇒ Object

also defined by Rake



54
55
56
# File 'lib/autoproj/aruba_minitest.rb', line 54

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

#generate_local_gemfileObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/autoproj/aruba_minitest.rb', line 28

def generate_local_gemfile
    path = expand_path("Gemfile.local")
    File.open(path, "w") do |io|
        io.write <<~GEMFILE
        source "https://rubygems.org"
        gem "autoproj", path: "#{File.expand_path('../../', __dir__)}"
        GEMFILE
    end
    path
end

#run_command(*args, **kwargs) ⇒ Object



46
47
48
# File 'lib/autoproj/aruba_minitest.rb', line 46

def run_command(*args, **kwargs)
    @aruba_api.run_command(*args, **kwargs)
end

#run_command_and_stop(*args, fail_on_error: true, **kwargs) ⇒ Object



39
40
41
42
43
44
# File 'lib/autoproj/aruba_minitest.rb', line 39

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

#setupObject



17
18
19
20
21
# File 'lib/autoproj/aruba_minitest.rb', line 17

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

#teardownObject



23
24
25
26
# File 'lib/autoproj/aruba_minitest.rb', line 23

def teardown
    stop_all_commands
    super
end